大疆上云API v1.10.0版本 windows本地部署与飞机上云

前端服务环境搭建

1.注册成为DJI开发者

2.生成license

在开发者中心中找到license,获取APP ID,App Key 和 App License

3.安装Node.js 和 npm

node 版本18.6 ;

npm换源

npm config set registry https://registry.npmmirror.com/
npm config get registry

4.前端示例代码下载:

https://github.com/dji-sdk/Cloud-API-Demo-Web

使用 IDE 打开源码。

修改配置文件(src/api/http/config.ts)中的参数,填上申请的appId,appKey 和 appLicense。

将下面两项的ip地址替换为局域网内的ipv4地址,电脑和遥控器在同一网络下。

或者填入服务器公网ip地址,使遥控器能够访问到pilot登录页面即可

  baseURL: 'http://10.10.206.48:6789/',
  websocketURL: 'ws://10.10.206.48:6789/api/v1/ws',

申请高德地图key,注意需要web服务的key

  amapKey: 'cf510a3faaadaa8752fad997ff2a6522',

其他项暂时注释

export const CURRENT_CONFIG = {

  // license
  appId: '949897', // You need to go to the development website to apply.
  appKey: '4f1d1ee0d2djIct38ESl2512232fbf7', // You need to go to the development website to apply.
  appLicense: 'H7tJVpwpntgoCnRTSyjIct38ESl27hu7Jk5upFn801XF+W/KDptYsZgG6jIct38ESl2ecHfXYDyYUE2bsBnqDl5GJjIct38ESl2M6uVpN+/8Oaibb3eXI8KSwMvv/RjXvzpUW/eF+6j632sjIct38ESl2kWlZz+weLyDcc5N+hk=', // You need to go to the development website to apply.

  // http
  baseURL: 'http://10.10.206.48:6789/', // This url must end with "/". Example: 'http://192.168.1.1:6789/'
  websocketURL: 'ws://10.10.206.48:6789/api/v1/ws', // Example: 'ws://192.168.1.1:6789/api/v1/ws'

  // livestreaming
  // RTMP  Note: This IP is the address of the streaming server. If you want to see livestream on web page, you need to convert the RTMP stream to WebRTC stream.
  rtmpURL: 'rtmp://localhost/live/', // Example: 'rtmp://192.168.1.1/live/'
  // GB28181 Note:If you don't know what these parameters mean, you can go to Pilot2 and select the GB28181 page in the cloud platform. Where the parameters same as these parameters.

  // gbServerIp: 'Please enter the server ip.',
  // gbServerPort: 'Please enter the server port.',
  // gbServerId: 'Please enter the server id.',
  // gbAgentId: 'Please enter the agent id',
  // gbPassword: 'Please enter the agent password',
  // gbAgentPort: 'Please enter the local port.',
  // gbAgentChannel: 'Please enter the channel.',
  // // RTSP
  // rtspUserName: 'Please enter the username.',
  // rtspPassword: 'Please enter the password.',
  // rtspPort: '8554',
  // // Agora
  // agoraAPPID: 'Please enter the agora app id.',
  // agoraToken: 'Please enter the agora temporary token.',
  // agoraChannel: 'Please enter the agora channel.',

  // // map
  // // You can apply on the AMap website.
  amapKey: 'cf510a3faaadaa8752fad997ff2a6522',

}

5.在根目录下打开控制台,运行命令安装依赖。

npm install

可能存在缺少的包,如    "moment": "^2.30.1"等,根据提示手动安装即可

npm install moment

安装完成可以在根目录下看到一个node_modules的目录。

运行命令启动服务。

npm run serve

当前版本上云api做了登录验证,因此需要启动后端才能成功登录

后端服务环境搭建

1.Java 安装

建议直接使用 java17 自行安装

https://www.oracle.com/java/technologies/downloads/#java17

2.EMQX 安装

在github里找4.4.18版本,含有windows版本的emqx

https://github.com/emqx/emqx/tags

3.MySQL 安装

版本mysql 8.0.39

https://dev.mysql.com/downloads/installer/

mysql远程机器访问
登入mysql后,更改 “mysql” 数据库里的 “user” 表里的 “host” 项,从”localhost”改称”%”,然后重启mysql这样就允许所有的远程机器进行访问了。

具体解决操作:

跳过ssl

mysql -h10.233.117.225 -P3306 -uroot -p --ssl-mode=DISABLED

步骤1:修改mysql表

mysql -uroot -p   (这是登录mysql,-u后是用户,-p后面是密码)
mysql>use mysql;
mysql>update user set host = "%" where user = "root"; 
mysql>flush privileges;
mysql>select host, user from user;

mysql>quit

步骤2:重启mysql

service mysqld restart

4.Redis 安装

在github上找到redis的windows安装包 Redis 5.0.14 for Windows

https://github.com/tporadowski/redis

Redis 远程机器访问

配置Redis:在安装完成后,您需要对Redis进行配置。找到Redis安装目录下的redis.conf文件,并用文本编辑器打开。在该文件中,找到并编辑以下几行:

bind 127.0.0.1
protected-mode yes

将bind行的IP地址更改为您的本地IP地址,这样Redis将允许来自该IP的连接。将protected-mode设置为no,以便通过IP连接到Redis。保存文件并关闭。

启动Redis:重新启动Redis服务以使配置更改生效。在命令行中运行以下命令:

redis-server /path/to/redis.conf

连接到Redis:现在,您可以使用连接Redis的工具连接到Redis服务器。常见的连接工具有redis-cli(Redis的命令行客户端)和Redis Desktop Manager(可视化客户端)。在命令行中运行以下命令以使用redis-cli连接到Redis:

redis-cli -h your_local_ip_address

将your_local_ip_address替换为您的本地IP地址。

5.初始化数据库

登录 mysql

mysql -u username -p

导入源码中sql目录下的初始化文件 cloud_sample.sql

或者下载navicat for mysql 链接数据库 运行sql文件

source cloud_sample.sql文件路径

6.后端源码启动

后端示例代码下载:https://github.com/dji-sdk/DJI-Cloud-API-Demo

使用 IDEA2023.1版本(包含Lombok插件) 打开源码。

配置好maven和java17   项目结构里要改java版本

打开配置文件(src/main/resources/application.yml),修改配置文件中的mysql配置、mqtt配置、redis配置以及对象存储服务器配置。

注意:如果mqtt不使用匿名登录,还需要修改数据库中,manage_user表中的mqtt账户名和密码。

A.修改mysql配置 IP地址 用户名 密码

      url: jdbc:mysql://10.10.206.48:3306/cloud_sample?useSSL=false&allowPublicKeyRetrieval=true
      username: root
      password: 11111111

B.修改redis配置,host改为redis所在的主机ip

    redis:
    host: 10.10.206.48
    port: 6379

C.修改mqtt配置,host改为mqtt所在的主机ip,使用匿名登录,不用修改username和password

mqtt:
  BASIC:
    protocol: MQTT
    host: 10.10.206.48
    port: 1883
    username: JavaServer
    password: 123456
    client-id: 123456
    # If the protocol is ws/wss, this value is required.
    path:
  DRC:
    protocol: WS
    host: 10.10.206.48
    port: 8083
    path: /mqtt
    username: JavaServer
    password: 123456

D.mqtt  下载MQTTX,可以接收无人机状态信息,和遥控器信息

遥控器向后端发送消息,后端返回消息,遥控器收到消息后成功上云连接

两个服务方式两个端口

订阅sys/product/+/status,thing/product/+/requests

cloud-sdk:
  mqtt:
    inbound-topic: sys/product/+/status,thing/product/+/requests

E.云api 填上申请的appId,appKey 和 appLicense。

cloud-api:
  app:
    id: 1448972
    key: 4f1d196df512d5c8222ee0d9632fbf7
    license: H7tJVpwpntgoCnRTSy7BWrdph1Ow7hu7Jk5upFn801XF+W/KDptYsZgG6TSW3xjIct38TSy7BWrdl2M6uVpN+/8Oaibb3eXey4m4I8KSwMvv/RjXvzpUW/eF+6j63EStgoCnR2sQ9zC8kWlZz+weLyDcc5N+hk=

server:
  port: 6789
spring:
  main:
    allow-bean-definition-overriding: true
  application:
    name: cloud-api-sample
  datasource:
    druid:
      type: com.alibaba.druid.pool.DruidDataSource
      driver-class-name: com.mysql.cj.jdbc.Driver
      #mysql环境
      url: jdbc:mysql://10.10.206.48:3306/cloud_sample?useSSL=false&allowPublicKeyRetrieval=true
      username: root
      password: 11111111
      initial-size: 10
      min-idle: 10
      max-active: 20
      max-wait: 60000

  redis:
    host: 10.10.206.48
    port: 6379
    database: 0
    username: # if you enable
    password:
    lettuce:
      pool:
        max-active: 8
        max-idle: 8
        min-idle: 0

  servlet:
    multipart:
      max-file-size: 2GB
      max-request-size: 2GB

jwt:
  issuer: DJI
  subject: CloudApiSample
  secret: CloudApiSample
  age: 86400

mqtt:
  # @see com.dji.sample.component.mqtt.model.MqttUseEnum
  # BASIC parameters are required.
  BASIC:
    protocol: MQTT # @see com.dji.sample.component.mqtt.model.MqttProtocolEnum
    host: 10.10.206.48
    port: 1883
    username: JavaServer
    password: 123456
    client-id: 123456
    # If the protocol is ws/wss, this value is required.
    path:
  DRC:
    protocol: WS # @see com.dji.sample.component.mqtt.model.MqttProtocolEnum
    host: 10.10.206.48
    port: 8083
    path: /mqtt
    username: JavaServer
    password: 123456

cloud-sdk:
  mqtt:
    # Topics that need to be subscribed when initially connecting to mqtt, multiple topics are divided by ",".
    inbound-topic: sys/product/+/status,thing/product/+/requests

url:
  manage:
    prefix: manage
    version: /api/v1
  map:
    prefix: map
    version: /api/v1
  media:
    prefix: media
    version: /api/v1
  wayline:
    prefix: wayline
    version: /api/v1
  storage:
    prefix: storage
    version: /api/v1
  control:
    prefix: control
    version: /api/v1

# Tutorial: https://www.alibabacloud.com/help/en/object-storage-service/latest/use-a-temporary-credential-provided-by-sts-to-access-oss
oss:
  enable: false
  provider: ALIYUN # @see com.dji.sample.component.OssConfiguration.model.enums.OssTypeEnum
  endpoint: https://oss-cn-hangzhou.aliyuncs.com
  access-key: Please enter your access key.
  secret-key: Please enter your secret key.
  expire: 3600
  region: Please enter your oss region. # cn-hangzhou
  role-session-name: cloudApi
  role-arn: Please enter your role arn. # acs:ram::123456789:role/stsrole
  bucket: Please enter your bucket name.
  object-dir-prefix: Please enter a folder name.

#oss:
#  enable: true
#  provider: aws
#  endpoint: https://s3.us-east-1.amazonaws.com
#  access-key:
#  secret-key:
#  expire: 3600
#  region: us-east-1
#  role-session-name: cloudApi
#  role-arn:
#  bucket: cloudapi-bucket
#  object-dir-prefix: wayline

#oss:
#  enable: true
#  provider: minio
#  endpoint: http://192.168.1.1:9000
#  access-key: minioadmin
#  secret-key: minioadmin
#  bucket: cloud-bucket
#  expire: 3600
#  region: us-east-1
#  object-dir-prefix: wayline

logging:
  level:
    com.dji: debug
  file:
    name: logs/cloud-api-sample.log

ntp:
  server:
    host: Google.mzr.me

# To create a license for an application: https://developer.dji.com/user/apps/#all
cloud-api:
  app:
    id: 144897
    key: 4f1d196df512d5c8222ee0d9632fbf7
    license: H7tJVpwpntgoCnRTSy7BWrdph1Ow7hu7Jk5upFn801XF+W/KDptYsZgG6TSW3xjIct38TSy7BWrdl2M6uVpN+/8Oaibb3eXey4m4I8KSwMvv/RjXvzpUW/eF+6j63EStgoCnR2sQ9zC8kWlZz+weLyDcc5N+hk=

livestream:
  url:
    # It is recommended to use a program to create Token. https://github.com/AgoraIO/Tools/blob/master/DynamicKey/AgoraDynamicKey/java/src/main/java/io/agora/media/RtcTokenBuilder2.java
    agora:
      channel: Please enter the agora channel.
      token: Please enter the agora temporary token.
      uid:  654321

    # RTMP  Note: This IP is the address of the streaming server. If you want to see livestream on web page, you need to convert the RTMP stream to WebRTC stream.
    rtmp:
      url: Please enter the rtmp access address.  # Example: 'rtmp://192.168.1.1/live/'
    rtsp:
      username: Please enter the username.
      password: Please enter the password.
      port: 8554

    # GB28181 Note:If you don't know what these parameters mean, you can go to Pilot2 and select the GB28181 page in the cloud platform. Where the parameters same as these parameters.
#    gb28181:
#      serverIP: Please enter the server ip.
#      serverPort: Please enter the server port.
#      serverID: Please enter the server id.
#      agentID: Please enter the agent id.
#      agentPassword: Please enter the agent password.
#      localPort: Please enter the local port.
#      channel: Please enter the channel.

    # Webrtc: Only supports using whip standard
    whip:
      url: Please enter the rtmp access address. #  Example:http://192.168.1.1:1985/rtc/v1/whip/?app=live&stream=

启动项目后台

打开手柄,点击云服务

url输入相应的ip地址  后面是/pilot-login

登录

  • 29
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值