[WeChat applet control hardware 16] Anxinke ESP32-S development board implements transplantation of Tencent IoT development platform Bluetooth llsync protocol, realizing one-key Bluetooth fast distribution network + remote control. (with source code)

      The WeChat IoT ecology is mainly divided into the WeChat hardware development platform and the Tencent IoT development platform . The former has stopped maintenance, but still has great learning value, while the latter, as the main platform, integrates many functions, including realizing distribution from WeChat applets. network to control;

      In order to take care of more friends and my own study notes, I will keep updating this special note. Welcome to pay attention to my CSDN half heart , and take you into the frontier field and learn the frontier technology!

Self-built WeChat server && WeChat hardware development platform

[ WeChat applet control hardware Part 1 ] The first release on the whole network, with the help of emq message server, it will show you how to build an mqtt server for WeChat applets, and easily control smart hardware!
[ WeChat applet control hardware Part 2 ] Start the journey of WeChat applets, import the source code of the applet Mqtt client, and realize simple verification and communication with the server!
[ WeChat applet control hardware Part 3 ] Build a WeChat applet control esp8266 project from software to hardware, customize the communication protocol, and add points for interview positions and competitions!
[ WeChat Mini Program Control Hardware Part 4 ] In-depth analysis of the principle and process of WeChat public account distribution network Airkiss, how esp8266 can customize callback parameters to WeChat, and realize the first step of binding devices!
[ WeChat applet control hardware Part 5 ] Clarify the architectural ideas that must be followed next, learn the observer mode of JavaScript, and receive device push events on multiple pages of WeChat applets at the same time!
[ WeChat Mini Program Control Hardware Part 6 ] How does the server integrate Qiniu cloud storage SDK, and store user-defined device pictures in a third-party server!
[ WeChat applet control hardware Part 7 ] Let’s make a WeChat applet Mqtt protocol control intelligent hardware framework, and water the dream of a full-stack engineer in my heart! !
[ WeChat Mini Program Control Hardware Chapter 8 】The WeChat applet uses websockets to connect to the mqtt server of the Alibaba Cloud IOT platform, which is so simple to package and use!
[ WeChat applet control hardware Part 9 ] By cleverly using the free connection of Alibaba Cloud IoT platform, the color collection and control esp8266 from the WeChat applet can output colorful lights. How about a live broadcast on the Mid-Autumn Festival? !
[ WeChat public account control hardware Part 10 ] How to connect to the mqtt server tutorial on the WeChat public account web page! !
[ WeChat applet control hardware Part 11 ] The first release on the whole network, the WeChat applet ble bluetooth controls esp32, which can control the brightness switch without the network.
[ WeChat applet control hardware Part 12 ] How to develop WeChat applet Bluetooth control hardware? Comprehensively analyze the use of the WeChat applet Bluetooth API for you.
[ WeChat applet control hardware Part 13 ] [AT chapter] It has nothing to do with the hardware platform, an example of WeChat applet AP distribution network Anxinke Wi-Fi module network access.

Tencent IoT Development Platform

[ Tencent Lianlian-Tencent IoT Development Platform Part 1 ] "Tencent Lianlian" released by Tencent's official Jingjiji is finally here. Follow the official tutorial to teach you how to configure the network and control the ESP8266 in the WeChat applet!
[ Tencent Lianlian-Tencent IoT Development Platform Part 2 ] In-depth analysis of the WeChat applet smartconfig distribution network principle, Anxin can directly connect Tencent IoT development platform with ESP-12S! !
[ Tencent Lianlian-Tencent IoT Development Platform Part 3 ] Anxinke IoT WeChat applet is fully open source, and the applet realizes one-click network configuration + control + binding!
[ Tencent Lianlian-Tencent IoT Development Platform Part 4 ] Note sharing on the secondary development of ESP8266 RTOS C SDK connected to Tencent IoT Development Platform!
[ Tencent Lianlian-Tencent IoT Development Platform Part 5 ] Re-understand the distribution network protocol of the wireless Internet of Things, understand the Bluetooth protocol LLSync SDK of Tencent IoT, and the Tencent Lianlian applet can also be used for Bluetooth distribution.
[ Tencent Lianlian-Tencent IoT Development Platform Part 6 ] Anxinke ESP32-S development board realizes transplantation of Tencent IoT development platform Bluetooth llsync protocol, realizing one-key Bluetooth fast network distribution + remote control.

insert image description here

I. Introduction

    My previous article mentioned how and what is the LLSyncprotocol of the Tencent IoT Development Platform, now let's practice it.

     Link: Re-understand the distribution network protocol of the wireless Internet of Things, understand the LLSync SDK of the Tencent IoT Bluetooth protocol, and the Tencent Lianlian applet can also be used for Bluetooth distribution.

    This project blog post is used as a sample project of Anxinke Technology NodeMCU-ESP32Development Board & Tencent IoT Development Platform Distribution Network + Communication. Based on Anxinke Technology NodeMCU-ESP32Development Board, it demonstrates that terminal devices pass through LLSync SDKand Explorer SDKperform network distribution and communicate with the cloud.

2. Description of the source code directory

├─qcloud-esp32-llsync-mqtt         应用目录
│           
│  ├─components         模块目录
│  │  ├─aithinker_board    安信可NodeMCU ESP32开发板LED驱动
│  │  ├─button    按键驱动
│  │  ├─qcloud_iot_c_sdk  腾讯物联开发平台的 Explorer SDK 
│  │  ├─qcloud_llsync     腾讯物联开发平台的 LLSync SDK 
│  │  │  │ 
│  │  ├─main              应用程序入口
│  │  │  ├─app_main.c     设备程序入口文件
│  │  │  │ 
│  │  │  ├─wifi_config_sample.c  设备控制业务代码
│  │  │  │ 

3. Compilation guide

  1. For installation ESP-IDF, please refer to the official website documentation .
mkdir -p ~/esp
cd ~/esp
git clone --recursive https://github.com/espressif/esp-idf.git

SDKThe branch used release/v4.2in this example commitis2532ddd9f447f6fab02bc2d1654534a7621e033a

Or download the full version of the compressed package directly: https://axk.coding.net/s/c3ce514c-808f-42fe-bc04-1c15ba823e45

  1. Copy qcloud-esp32-llsync-mqttthe folder to the ESP-IDFdirectory.
cp -r qcloud-esp32-llsync-mqtt $IDF_PATH
cd $IDF_PATH/qcloud-esp32-llsync-mqtt
  1. Log in to the IoT development platform , create devices, and get triplet information.

Use the ternary information of the new device to replace qcloud-esp32-llsync-mqtt/components/qcloud_iot_c_sdk/platform/HAL_Device_freertos.cthe device information defined in the macro, compile and burn to the development board.

/* product Id  */
static char sg_product_id[MAX_SIZE_OF_PRODUCT_ID + 1] = "I8YSNLJF5T";
/* device name */
static char sg_device_name[MAX_SIZE_OF_DEVICE_NAME + 1] = "ESP32_D1";
/* device secret of PSK device */
static char sg_device_secret[MAX_SIZE_OF_DEVICE_SECRET + 1] = "4mFTgmh8VFoqEYLdYLOOBA==";
  1. Modify the device distribution network mode on the IoT development platform to the standard BLE auxiliary distribution network.

  2. Search the Tencent Lianlian applet on WeChat to perform network distribution operations.

  3. After the network configuration is successful, the log on the device side is as follows.

    I (962) llsync config net: wifi_init_sta finished.
    I (962) llsync config net: esp_wifi_get_config ok , but null config 
    I (962) gpio: GPIO[0]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:3 
    ERR|1970-01-01 00:15:53|qcloud_wifi_config_log_handle.c|init_dev_log_queue(55): init dev log queue
    
    INF|1970-01-01 00:15:53|HAL_Wifi_api.c|HAL_Wifi_read_err_log(42): HAL_Wifi_read_err_log
    
    INF|1970-01-01 00:15:53|qcloud_wifi_config_error_handle.c|check_err_log(91): invalid magic code: 0x3ffc8be0
    
    I (1002) BTDM_INIT: BT controller compile version [a6525b7]
    I (1352) LLSYNC: create attribute table successfully, the number handle = 6
    
    I (1352) LLSYNC: ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT
    I (1352) broadcast: 02 e8 db 84 3b 3e c2 49 38 59 53 4e 4c 4a 46 35 
    I (1362) broadcast: 54 
    I (1362) adv: 02 01 06 03 03 f0 ff 14 ff e7 fe 02 e8 db 84 3b 
    I (1372) adv: 3e c2 49 38 59 53 4e 4c 4a 46 35 54 02 09 6c 
    I (1372) LLSYNC: start advertising
    qiot info: start wait advertising
    
    I (1382) LLSYNC: SERVICE_START_EVT, status 0, service_handle 40
    I (1382) LLSYNC: Stop adv successfully
    
    I (1392) LLSYNC: ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT
    I (1392) LLSYNC: advertising start successfully
    I (21232) LLSYNC: 52 b6 c9 9e e8 0a 
    I (21352) LLSYNC: ESP_GATTS_MTU_EVT, MTU 517
    qiot err(../components/qcloud_llsync/src/core/ble_qiot_llsync_event.c|77): upload msg negate, device not connected
    
    I (21702) LLSYNC: update connection params status = 0, min_int = 16, max_int = 32,conn_int = 24,latency = 0, timeout = 400
    I (22252) post data: 08 00 0c 02 80 80 08 45 53 50 33 32 5f 44 31 
    qiot info: mtu setting result: 00
    
    I (25972) post data: e0 00 01 00 
    I (26362) llsync config net: wifi info : XuHongIoT , xuhong12345678
    I (26382) post data: e1 00 01 00 
    I (26782) llsync config net: wifi connect
    I (27022) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
    I (27832) wifi:state: init -> auth (b0)
    I (27852) wifi:state: auth -> assoc (0)
    I (27912) wifi:state: assoc -> run (10)
    I (27932) wifi:connected with XuHongIoT, aid = 2, channel 1, BW20, bssid = 9c:9d:7e:40:e8:10
    I (27932) wifi:security: WPA2-PSK, phy: bgn, rssi: -27
    I (27942) wifi:pm start, type: 1
    
    I (28032) wifi:AP's beacon interval = 102400 us, DTIM period = 1
    I (29262) esp_netif_handlers: sta ip: 192.168.31.89, mask: 255.255.255.0, gw: 192.168.31.1
    I (29262) llsync config net: got ip:192.168.31.89
    I (29342) post data: e2 00 0d 01 00 00 09 58 75 48 6f 6e 67 49 6f 54 
    INF|1970-01-01 00:16:21|HAL_TCP_lwip.c|HAL_TCP_Connect(93): connected with TCP server: I8YSNLJF5T.iotcloud.tencentdevices.com:1883
    
    INF|1970-01-01 00:16:21|mqtt_client.c|IOT_MQTT_Construct(125): mqtt connect with id: nj3bE success
    INF|1970-01-01 00:16:21|qcloud_wifi_config_device_bind.c|_setup_mqtt_connect(332): Cloud Device Construct Success
    INF|1970-01-01 00:16:23|qcloud_wifi_config_device_bind.c|_send_token_wait_reply(221): wait for token data...
    INF|1970-01-01 00:16:23|qcloud_wifi_config_device_bind.c|_mqtt_event_handler(68): publish success, packet-id=26846
    INF|1970-01-01 00:16:23|qcloud_wifi_config_device_bind.c|_on_message_callback(101): recv msg topic: $thing/down/service/I8YSNLJF5T/ESP32_D1
    INF|1970-01-01 00:16:23|qcloud_wifi_config_device_bind.c|_on_message_callback(112): msg payload: {
          
          "method":"app_bind_token_reply","clientToken":"ESP32_D1-983694","code":0,"status":"success"}
    INF|1970-01-01 00:16:24|qcloud_wifi_config_device_bind.c|_send_token_wait_reply(249): wait for token sending result...
    INF|1970-01-01 00:16:25|mqtt_client_connect.c|qcloud_iot_mqtt_disconnect(468): mqtt disconnect!
    INF|1970-01-01 00:16:25|mqtt_client.c|IOT_MQTT_Destroy(189): mqtt release!
    INF|1970-01-01 00:16:30|qcloud_wifi_config_device_bind.c|qiot_device_bind(398): WIFI_MQTT_CONNECT_SUCCESS
    ERR|1970-01-01 00:16:30|qcloud_wifi_config_log_handle.c|push_dev_log(98): push dev log 990703|qiot_device_bind(399): WIFI_MQTT_CONNECT_SUCCESS
    ...
    
    

4. Frequently asked questions

  1. How to reset the device into network configuration mode?

This program has been adapted to the Anxinke technology NodeMCU-ESP32development board, long press the development board button IO0 for more than 3 seconds, until the onboard LED flashes, that is, enter the Bluetooth distribution network LLSyncmode.

The relevant code is in the app_main.c file.

  1. Where is the business logic delivered by the server processed?

This program has been adapted to the Anxinke technology NodeMCU-ESP32development board, which can only control the on-off function of the on-board LED light.

The relevant code is in the property_control_handle() of the qcloud-llsync-config-net-esp32\main\wifi_config_sample.c file.

  1. Where is the status reported by the server processed?

This program has been adapted to the Anxinke technology NodeMCU-ESP32development board, you can refer to the following code.

The relevant code is in the property_report of the qcloud-llsync-config-net-esp32\main\wifi_config_sample.c file.

5. Open Source WeChat IoT Control List

open source project address open source time
WeChat applet connects to mqtt server to control esp8266 smart hardware https://github.com/xuhongv/WeChatMiniEsp8266 2018.11
Implementation of WeChat public account airkiss network distribution and near-field discovery in esp8266 rtos3.1 https://github.com/xuhongv/xLibEsp8266Rtos3.1AirKiss 2019.3
Implementation of WeChat public account airkiss network distribution and near-field discovery in esp32 esp-idf https://github.com/xuhongv/xLibEsp32IdfAirKiss 2019.9
WeChat applet controls esp8266 to achieve colorful effect project source code https://github.com/xuhongv/WCMiniColorSetForEsp8266 2019.9
A Wechat applet location tracking display project based on Anxinke Ca-01 https://github.com/xuhongv/Cat.1TracerWcMini 2019.9
WeChat applet bluetooth distribution network blufi implementation in esp32 source code https://github.com/xuhongv/BlufiEsp32WeChat 2019.11
WeChat applet bluetooth ble control esp32 colorful light effect https://blog.csdn.net/xh870189248/article/details/101849759 2019.10
A WeChat applet mqtt disconnection reconnection framework for commercial event distribution https://blog.csdn.net/xh870189248/article/details/88718302 2019.2
The WeChat applet uses websocket to connect to the mqtt server of Alibaba Cloud IOT platform https://blog.csdn.net/xh870189248/article/details/91490697 2019.6
Wechat public account web page realizes connection to mqtt server https://blog.csdn.net/xh870189248/article/details/100738444 2019.9
An example of WeChat applet AP distribution network Anxinke Wi-Fi module network access https://github.com/Ai-Thinker-Open/Ai-Thinker-Open_WeChatMiniAP2Net 2020.5
Anxinke IoT WeChat applet is fully open source, and one-click network distribution + control + binding is realized on the applet https://blog.csdn.net/xh870189248/article/details/107140464 2020.8
WeChat applet Bluetooth + WiFi control Anxinke ESP32-S/C3S module application https://github.com/xuhongv/ESP32WiFiBleControlProject 2021.6
Anxinke ESP32-S module is adapted to Tencent IoT development platform llsync Bluetooth distribution network + MQTT remote control https://github.com/xuhongv/qcloud-esp32-llsync-mqtt 2021.7

In addition, don't take my blog as a learning standard, mine are just notes, and it's hard to be negligent. If there are any, please point them out, and welcome to leave a message!

  • Play esp8266with you, QQjoin the group, friends who don’t like it, don’t spray or add: 434878850
  • Personal E-mail: [email protected] 24 hours online, all emails will be replied!
  • esp8266 source code learning summary (continuously updated, welcome to star): https://github.com/xuhongv/StudyInEsp8266
  • esp32 source code learning summary (continuously updated, welcome to star): https://github.com/xuhongv/StudyInEsp32
  • Pay attention to the QR code of the WeChat public account below, there are a lot of dry goods, and we will push them as soon as possible!

insert image description here

Guess you like

Origin blog.csdn.net/xh870189248/article/details/118489026