[ESP] 使用Ayla API Reference配网和连Ayla云

示例用的文档及链接

  1. US Dev Dashboard(查看oem-id和oem-key)

https://dashboard-dev.aylanetworks.com/

  1. Ayla API Reference(绑定用户,设备和Ayla云)

https://docs.aylanetworks.com/reference

  1. Ayla_demo的官方文档(构建,运行步骤)

https://docs.aylanetworks.com/docs/integrated-agent-v30

  1. Ayla Developer Center(创建template)

https://developer.aylanetworks.com/

Postman用到的url

10.231.227.81是设备AP模式的IP地址。

POST

PUT

GET

请求访问设备的类型

  • LOC_REQ is used for open HTTP requests (just setting up LAN mode).
  • APP_REQ is for LAN mode.
  • ADS_REQ are requests from the cloud, currently via reverse-ReST.
  • SEC_WIFI_REQ is for LAN mode from the AP interface (secure Wi-Fi setup).
  • REQ_SOFT_AP is for open HTTP requests (currently only for property tests),

示例使用SoftAP配网,并且用的是postman作为客户端,所以需要修改一部分代码,运行REQ_SOFT_AP类型支持配网功能(原SDK内部设置的不允许REQ_SOFT_AP进行配网)。

Ayla API Reference登录

  1. 打开链接https://docs.aylanetworks.com/reference/sign-in查看详细步骤
  2. 在”BODY PARAMS”输入账号密码等信息
  3. 点击右边的”Try it!”进行登录,并成功返回状态码200token
  4. 之后将按照格式”auth_token (access_token”后跟着的字符串)”粘贴到”AUTHENTICATION

Ayla_demo构建

  1. idf.py set-target esp32c3
  2. idf.py build
  3. idf.py -p /dev/ttyUSB1 erase_flash flash monitor

Ayla_demo配置

ayla_demo运行起来后通过cli命令进行配置,如oem-id,oem-model等,以下每个指令的说明可以在终端执行help查看。

  • 在不了各种配置的情况下需要严格按照以下步骤执行,防止出错。
  • conf set id/dev_id xxxxxx
  • conf set id/key xxxxx
  • save
  • reset
  • oem xxxxx
  • oem model xxxx
  • oem key xxxx xxx
  • wifi profile ap ssid Ayla-pipisha
  • log -mod client debug
  • setup_mode disable
  • save
  • reset

Ayla_demo配网步骤

在Dashboard查看设备并没有被绑定:

  1. PC通过WIFI连接设备,通过Ayla_demo配置可以知道设备的AP为”Ayla-pipisha”。
  2. Postman通过POST方式发送wifi扫描指令
  3. Postman通过GET方式发送wifi扫描结果
  4. Postman通过POST方式发送连接的wifi名和密码
  5. Postman通过GET方式获取配置的wifi名是否和发送的一致
  6. 在终端执行指令wifi enable启动配网
  7. Postman通过GET方式获取配网结果
  8. 在”Ayla API Reference”的”Register device to user”页面填写设备的DSN和用户的uuid,然后点击右边的”Try it!”,返回204表示成功。
  9. Dashboard确定绑定设备成功
posted @ 2023-07-11 17:06  空水  阅读(83)  评论(0编辑  收藏  举报