├── .gitignore ├── app ├── bt_discovery │ ├── main │ │ ├── CMakeLists.txt │ │ ├── component.mk │ │ └── bt_discovery.c │ ├── Makefile │ ├── CMakeLists.txt │ ├── sdkconfig.defaults │ ├── README.rst │ ├── run.sh │ └── sdkconfig ├── tencent_jm_xxj │ ├── my_src │ │ ├── examples │ │ │ ├── jm_xxj │ │ │ │ ├── main │ │ │ │ │ ├── CMakeLists.txt │ │ │ │ │ ├── wifi_server.h │ │ │ │ │ ├── app_timing.h │ │ │ │ │ ├── app_driver.h │ │ │ │ │ ├── app_fragrance.h │ │ │ │ │ ├── app_main.c │ │ │ │ │ ├── app_fragrance.c │ │ │ │ │ ├── app_timing.c │ │ │ │ │ ├── Kconfig.projbuild │ │ │ │ │ ├── wifi_server.c │ │ │ │ │ └── app_driver.c │ │ │ │ ├── FW │ │ │ │ │ ├── bootloader.bin │ │ │ │ │ ├── led_light.bin │ │ │ │ │ ├── partition-table.bin │ │ │ │ │ ├── ota_data_initial.bin │ │ │ │ │ └── flash.bat │ │ │ │ ├── data_template_light.json │ │ │ │ └── CMakeLists.txt │ │ │ └── common_components │ │ │ │ ├── cmp_rtc │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ │ └── cmp_rtc.h │ │ │ │ └── src │ │ │ │ │ └── cmp_rtc.c │ │ │ │ ├── ic_tm1650 │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ │ ├── ic_tm1650.h │ │ │ │ │ └── ic_tm1650_config.h │ │ │ │ └── src │ │ │ │ │ └── ic_tm1650.c │ │ │ │ ├── ic_ds1302 │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ │ ├── ic_ds1302.h │ │ │ │ │ └── ic_ds1302_config.h │ │ │ │ └── src │ │ │ │ │ └── ic_ds1302.c │ │ │ │ ├── cmp_timing │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ │ └── cmp_timing.h │ │ │ │ └── src │ │ │ │ │ └── cmp_timing.c │ │ │ │ └── cmp_xxj_bt │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── include │ │ │ │ └── bt_gap.h │ │ │ │ └── src │ │ │ │ ├── bt_server.c │ │ │ │ ├── bt_gatt.c │ │ │ │ └── bt_gap.c │ │ ├── src │ │ │ ├── mqtt │ │ │ │ └── esp_qcloud_mqtt.c │ │ │ └── iothub │ │ │ │ └── esp_qcloud_device.c │ │ └── include │ │ │ └── esp_qcloud_iothub.h │ ├── README.md │ └── run.sh ├── aliyun_demo │ ├── my_src │ │ ├── config.esp32.aos │ │ └── mqtt_example.c │ └── run.sh └── aliyun_dd_xxj │ ├── my_src │ ├── config.esp32.aos │ └── mqtt_example.c │ └── run.sh ├── readme.md └── tool └── run.sh /.gitignore: -------------------------------------------------------------------------------- 1 | sdk 2 | tool/xtensa-esp32-elf/ 3 | sdkconfig.old 4 | app/*/build/ 5 | esp-aliyun 6 | iotkit-embedded 7 | -------------------------------------------------------------------------------- /app/bt_discovery/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(COMPONENT_SRCS "bt_discovery.c") 2 | set(COMPONENT_ADD_INCLUDEDIRS ".") 3 | 4 | register_component() 5 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/jm_xxj/main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRC_DIRS "." 2 | INCLUDE_DIRS ".") 3 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/common_components/cmp_rtc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRC_DIRS "src" 2 | INCLUDE_DIRS "include") 3 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/common_components/ic_tm1650/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRC_DIRS "src" 2 | INCLUDE_DIRS "include") 3 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/jm_xxj/FW/bootloader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nbtool/esp32_linux_tool/HEAD/app/tencent_jm_xxj/my_src/examples/jm_xxj/FW/bootloader.bin -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/jm_xxj/FW/led_light.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nbtool/esp32_linux_tool/HEAD/app/tencent_jm_xxj/my_src/examples/jm_xxj/FW/led_light.bin -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/jm_xxj/FW/partition-table.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nbtool/esp32_linux_tool/HEAD/app/tencent_jm_xxj/my_src/examples/jm_xxj/FW/partition-table.bin -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/jm_xxj/FW/ota_data_initial.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nbtool/esp32_linux_tool/HEAD/app/tencent_jm_xxj/my_src/examples/jm_xxj/FW/ota_data_initial.bin -------------------------------------------------------------------------------- /app/bt_discovery/main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # "main" pseudo-component makefile. 3 | # 4 | # (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) 5 | 6 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/README.md: -------------------------------------------------------------------------------- 1 | 1) 下载 esp-qcloud, 切换到 43e218d 2 | 2) 对 esp-qcloud 雕刻: `cp -r my_src/* ./esp-qcloud/` 3 | 3) 确认 IDF 版本是否是 `realease/v4.3`, 不是则切换,切换之后进行安装 4 | 5 | PS:不仅 demo 有变,组件还有增加,一些 src 也有变 6 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/common_components/ic_ds1302/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRC_DIRS "src" 2 | INCLUDE_DIRS "include" 3 | REQUIRES cmp_rtc) 4 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/common_components/cmp_timing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRC_DIRS "src" 2 | INCLUDE_DIRS "include" 3 | REQUIRES cmp_rtc) 4 | 5 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/common_components/cmp_xxj_bt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRC_DIRS "src" 2 | INCLUDE_DIRS "include" "../../../include/" 3 | REQUIRES bt cmp_rtc) 4 | -------------------------------------------------------------------------------- /app/bt_discovery/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This is a project Makefile. It is assumed the directory this Makefile resides in is a 3 | # project subdirectory. 4 | # 5 | 6 | PROJECT_NAME := bt_discovery 7 | 8 | include $(IDF_PATH)/make/project.mk 9 | 10 | -------------------------------------------------------------------------------- /app/bt_discovery/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's CMakeLists 2 | # in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 6 | project(bt_discovery) 7 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/jm_xxj/FW/flash.bat: -------------------------------------------------------------------------------- 1 | esptool.py -p (PORT) -b 460800 --before default_reset --after hard_reset --chip esp32 write_flash --flash_mode dio --flash_size detect --flash_freq 80m 0x1000 bootloader.bin 0xc000 partition-table.bin 0x1d000 ota_data_initial.bin 0x20000 led_light.bin 2 | -------------------------------------------------------------------------------- /app/bt_discovery/sdkconfig.defaults: -------------------------------------------------------------------------------- 1 | # Override some defaults so BT stack is enabled and 2 | # Classic BT is enabled and BT_DRAM_RELEASE is disabled 3 | CONFIG_BT_ENABLED=y 4 | CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY= 5 | CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=y 6 | CONFIG_BTDM_CONTROLLER_MODE_BTDM= 7 | CONFIG_CLASSIC_BT_ENABLED=y 8 | CONFIG_A2DP_ENABLE=n 9 | CONFIG_GATTS_ENABLE=n 10 | CONFIG_GATTC_ENABLE=n 11 | CONFIG_BLE_SMP_ENABLE=n 12 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/jm_xxj/main/wifi_server.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: wifi_server.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Sun 05 Mar 2023 19:35:33 HKT 6 | ************************************************************************/ 7 | 8 | #ifndef _WIFI_SERVER_H 9 | #define _WIFI_SERVER_H 10 | 11 | void app_wifi_server_init(void); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/common_components/ic_ds1302/include/ic_ds1302.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: ic_ds1302.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Tue 01 Aug 2023 15:06:30 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _IC_DS1302_H 9 | #define _IC_DS1302_H 10 | 11 | #include "cmp_rtc.h" 12 | 13 | 14 | void gc1302_init( cmp_rtc_date_s *date); 15 | void gc1302_test(); 16 | 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/jm_xxj/main/app_timing.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: app_timing.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Sat 04 Mar 2023 10:16:32 HKT 6 | ************************************************************************/ 7 | 8 | #ifndef _APP_TIMING_H 9 | #define _APP_TIMING_H 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | 18 | void app_timing_init(void); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/jm_xxj/main/app_driver.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: app_driver.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Sun 04 Dec 2022 16:09:36 HKT 6 | ************************************************************************/ 7 | 8 | #ifndef _APP_DRIVER_H 9 | #define _APP_DRIVER_H 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | 18 | esp_err_t app_driver_init(void); 19 | void app_driver_set_wifi_state(char state); 20 | void app_driver_set_fragrance_onoff(char device, bool on); 21 | void app_driver_set_fan_speed(int speed); 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/jm_xxj/main/app_fragrance.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: app_fragrance.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Sat 03 Dec 2022 22:03:26 HKT 6 | ************************************************************************/ 7 | 8 | #ifndef _APP_FRAGRANCE_H 9 | #define _APP_FRAGRANCE_H 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | 18 | esp_err_t app_fragrance_set_onoff(bool on); 19 | esp_err_t app_fragrance_set_fan_speed(int speed); 20 | esp_err_t app_fragrance_set_work_model(char *work_model); 21 | esp_err_t app_fragrance_init(void); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /app/aliyun_demo/my_src/config.esp32.aos: -------------------------------------------------------------------------------- 1 | CONFIG_ENV_CFLAGS += \ 2 | -DBOARD_ESP32 -u call_user_start \ 3 | -fno-inline-functions \ 4 | -ffunction-sections \ 5 | -fdata-sections \ 6 | -mlongcalls \ 7 | -DESPOS_FOR_ESP32 -Wl,-static \ 8 | -DXT_USE_THREAD_SAFE_CLIB=0 \ 9 | 10 | CONFIG_ENV_CFLAGS += \ 11 | -Os \ 12 | -DCONFIG_HTTP_AUTH_TIMEOUT=500 \ 13 | -DCONFIG_MID_HTTP_TIMEOUT=500 \ 14 | -DCONFIG_GUIDER_AUTH_TIMEOUT=500 \ 15 | -DCONFIG_MQTT_TX_MAXLEN=640 \ 16 | -DCONFIG_MQTT_RX_MAXLEN=1200 \ 17 | 18 | CONFIG_src/ref-impl/tls := 19 | CONFIG_src/ref-impl/hal := 20 | CONFIG_examples := 21 | CONFIG_tests := 22 | CONFIG_src/tools/linkkit_tsl_convert := 23 | 24 | CROSS_PREFIX := xtensa-esp32-elf- 25 | -------------------------------------------------------------------------------- /app/bt_discovery/README.rst: -------------------------------------------------------------------------------- 1 | ESP-IDF BT-INQUIRY demo 2 | ====================== 3 | 4 | Demo of Classic Bluetooth Device and Service Discovery 5 | 6 | This is the demo for user to use ESP_APIs to perform inquiry to search for a target device and then performs service search via SDP. 7 | 8 | Options choose step: 9 | 1. make menuconfig. 10 | 2. enter menuconfig "Component config", choose "Bluetooth" 11 | 3. enter menu Bluetooth, choose "Classic Bluetooth" and do not choose "Release DRAM from Classic BT controller" 12 | 4. choose your options. 13 | 14 | After the program started, the device will start inquiry to search for a device with Major device type "PHONE" in the Class of Device Field. Then it will cancel the inquiry and started to perform service discovering on this remote device. 15 | -------------------------------------------------------------------------------- /app/aliyun_dd_xxj/my_src/config.esp32.aos: -------------------------------------------------------------------------------- 1 | CONFIG_ENV_CFLAGS += \ 2 | -DBOARD_ESP32 -u call_user_start \ 3 | -fno-inline-functions \ 4 | -ffunction-sections \ 5 | -fdata-sections \ 6 | -mlongcalls \ 7 | -DESPOS_FOR_ESP32 -Wl,-static \ 8 | -DXT_USE_THREAD_SAFE_CLIB=0 \ 9 | 10 | CONFIG_ENV_CFLAGS += \ 11 | -Os \ 12 | -DCONFIG_HTTP_AUTH_TIMEOUT=500 \ 13 | -DCONFIG_MID_HTTP_TIMEOUT=500 \ 14 | -DCONFIG_GUIDER_AUTH_TIMEOUT=500 \ 15 | -DCONFIG_MQTT_TX_MAXLEN=640 \ 16 | -DCONFIG_MQTT_RX_MAXLEN=1200 \ 17 | 18 | CONFIG_src/ref-impl/tls := 19 | CONFIG_src/ref-impl/hal := 20 | CONFIG_examples := 21 | CONFIG_tests := 22 | CONFIG_src/tools/linkkit_tsl_convert := 23 | 24 | CROSS_PREFIX := xtensa-esp32-elf- 25 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/common_components/cmp_xxj_bt/include/bt_gap.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: bt_gap.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Sun 19 Feb 2023 01:40:34 HKT 6 | ************************************************************************/ 7 | 8 | #ifndef _BT_GAP_H 9 | #define _BT_GAP_H 10 | 11 | #include "nimble/ble.h" 12 | #include "modlog/modlog.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | /* XXJ configuration */ 19 | #define GATT_XXJ_UUID 0xFCF0 20 | #define GATT_XXJ_NOTIFY_UUID 0xFCF1 21 | #define GATT_XXJ_WRITE_NO_ACK_UUID 0xFCF2 22 | #define GATT_DEVICE_INFO_UUID 0x180A 23 | #define GATT_MANUFACTURER_NAME_UUID 0x2A29 24 | #define GATT_MODEL_NUMBER_UUID 0x2A24 25 | 26 | extern uint16_t xxj_handle; 27 | extern int bt_gatt_init(void); 28 | 29 | 30 | void app_bt_gap_init(void); 31 | void app_bt_gatt_send(uint8_t *datas, uint8_t len); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/common_components/ic_tm1650/include/ic_tm1650.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: ic_tm1650.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Mon 05 Dec 2022 00:47:47 HKT 6 | ************************************************************************/ 7 | 8 | #ifndef _IC_TM1650_H 9 | #define _IC_TM1650_H 10 | 11 | //显示参数 12 | #define TM1650_BRIGHT1 0x11 /*一级亮度,打开LED显示*/ 13 | #define TM1650_BRIGHT2 0x21 /*二级亮度,打开LED显示*/ 14 | #define TM1650_BRIGHT3 0x31 /*三级亮度,打开LED显示*/ 15 | #define TM1650_BRIGHT4 0x41 /*四级亮度,打开LED显示*/ 16 | #define TM1650_BRIGHT5 0x51 /*五级亮度,打开LED显示*/ 17 | #define TM1650_BRIGHT6 0x61 /*六级亮度,打开LED显示*/ 18 | #define TM1650_BRIGHT7 0x71 /*七级亮度,打开LED显示*/ 19 | #define TM1650_BRIGHT8 0x01 /*八级亮度,打开LED显示*/ 20 | #define TM1650_DSP_OFF 0x00 /*关闭LED显示*/ 21 | 22 | //数码管位选 23 | #define TM1650_DIG1 0 24 | #define TM1650_DIG2 1 25 | #define TM1650_DIG3 2 26 | #define TM1650_DIG4 3 27 | 28 | void TM1650_init(void); 29 | void TM1650_cfg_display(unsigned char param); 30 | void TM1650_clear(void); 31 | void TM1650_print(unsigned char dig,unsigned char seg_data); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/common_components/cmp_timing/include/cmp_timing.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: cmp_timing.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Mon 27 Feb 2023 00:31:07 HKT 6 | ************************************************************************/ 7 | 8 | #ifndef _CMP_TIMING_H 9 | #define _CMP_TIMING_H 10 | 11 | // 12 | //enum{ 13 | // TIMING_STATE_NO = 0x00, 14 | // TIMING_STATE_IN = 0x01, 15 | // TIMING_STATE_END = 0x02, 16 | //}; 17 | 18 | // 19 | struct ITiming{ 20 | unsigned char enable:1; //是否使能该定时动作 21 | unsigned char repet:1; //是否重复定时 22 | unsigned char timing_state:4; //当前定时的状态 23 | unsigned char day; //一周中有哪些天是重复定时 24 | unsigned short time; //分钟来计算的一天的时间 25 | unsigned char (*timing_end_cb)(unsigned char index); //定时触发回调函数 26 | }; 27 | 28 | struct ITimingFunc{ 29 | void (*init)(struct ITiming *pITiming, unsigned char num); 30 | void (*set)(struct ITiming *pITiming,unsigned char enable,unsigned short time,unsigned char repet,unsigned char day,unsigned char (*cb)(unsigned char index)); 31 | void (*kill)(struct ITiming *pITiming); 32 | }; 33 | 34 | 35 | extern struct ITimingFunc mITimingFunc; 36 | 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | #### 1. Brief introduction 2 | 3 | The project provides a esp32 APP command-line development environment based on Linux system. 4 | 5 | You can directly create、write、build、install APP(HEX/BIN) without using IDE. 6 | 7 | 8 | #### 2. How to use 9 | 10 | If it is the first time to compile, It is recommended to run goto tool directly, and then run the 'bash run.sh tool' to download gcc、SDK、build-tools etc. 11 | 12 | cd tool 13 | python3.9 -m venv ./pvevn 14 | cd pvevn 15 | source ./bin/activate 16 | cd - 17 | bash run.sh help 18 | bash run.sh tool 19 | 20 | Create the project from the sdk examples(for example:hello_world): 21 | 22 | bash run.sh create ../sdk/esp-idf/examples/get-started/hello_world hello_world 23 | cd ../app/hello_world 24 | ./run.sh help 25 | 26 | Install the APP: 27 | 28 | ./run.sh flash 29 | 30 | Monitor and watch log: 31 | 32 | ./run.sh monitor 33 | 34 | Clean: 35 | 36 | ./run.sh clean 37 | 38 | 39 | **more:**[xxxxxxxxxx](xxxxxxxxxxxx) 40 | 41 | 42 | #### 3. Demo-Apps 43 | 44 | - bt_discovery : 10s-loop to discovery the ble device 45 | 46 | #### 4. Links 47 | 48 | [[1]. espressif esp-idf github][#1] 49 | [[2]. ESP-IDF Programming Guide][#2] 50 | [[3]. Ali-IOT platform product creation experience, Linux SDK parsing, transplanting aliyun-esp based on ESP32 to achieve hardware and cloud interaction (hard core, dry goods)][#3] 51 | 52 | 53 | 54 | 55 | 56 | [#1]:https://github.com/espressif/esp-idf 57 | [#2]:https://docs.espressif.com/projects/esp-idf/en/v3.1.1/index.html 58 | [#3]:https://www.cnblogs.com/zjutlitao/p/10269835.html 59 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/jm_xxj/data_template_light.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "profile": { 4 | "ProductId": "65BEMES9XM", 5 | "CategoryId": "141" 6 | }, 7 | "properties": [{ 8 | "id": "power_switch", 9 | "name": "电灯开关", 10 | "desc": "控制电灯开灭", 11 | "required": true, 12 | "mode": "rw", 13 | "define": { 14 | "type": "bool", 15 | "mapping": { 16 | "0": "关", 17 | "1": "开" 18 | } 19 | } 20 | }, { 21 | "id": "saturation", 22 | "name": "饱和度", 23 | "desc": "", 24 | "mode": "rw", 25 | "define": { 26 | "type": "int", 27 | "min": "0", 28 | "max": "100", 29 | "start": "0", 30 | "step": "1", 31 | "unit": "" 32 | }, 33 | "required": false 34 | }, { 35 | "id": "value", 36 | "name": "明度", 37 | "desc": "", 38 | "mode": "rw", 39 | "define": { 40 | "type": "int", 41 | "min": "0", 42 | "max": "100", 43 | "start": "0", 44 | "step": "1", 45 | "unit": "" 46 | }, 47 | "required": false 48 | }, { 49 | "id": "hue", 50 | "name": "色调", 51 | "desc": "", 52 | "mode": "rw", 53 | "define": { 54 | "type": "int", 55 | "min": "0", 56 | "max": "360", 57 | "start": "0", 58 | "step": "1", 59 | "unit": "" 60 | }, 61 | "required": false 62 | }], 63 | "events": [{ 64 | "id": "hardware_fault", 65 | "name": "Hardware_fault", 66 | "desc": "Report hardware fault", 67 | "type": "fault", 68 | "required": false, 69 | "params": [{ 70 | "id": "name", 71 | "name": "Name", 72 | "desc": "Name like: memory,tf card, censors ...", 73 | "define": { 74 | "type": "string", 75 | "min": "0", 76 | "max": "64" 77 | } 78 | }, { 79 | "id": "error_code", 80 | "name": "Error_Code", 81 | "desc": "Error code for fault", 82 | "define": { 83 | "type": "int", 84 | "unit": "", 85 | "step": "1", 86 | "min": "0", 87 | "max": "2000", 88 | "start": "1" 89 | } 90 | }] 91 | }], 92 | "actions": [] 93 | } 94 | -------------------------------------------------------------------------------- /app/bt_discovery/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #I don't like to set environment variables in the system, 4 | #so I put the environment variables in run.sh. 5 | #Every time I use run.sh, the enviroment variables will be set, after use that will be unsetted. 6 | 7 | 8 | PROJECT_ROOT=../.. 9 | TOOLS_PATH=$PROJECT_ROOT/tool 10 | SDK_PATH=$PROJECT_ROOT/sdk 11 | APP_PATH=$PROJECT_ROOT/app 12 | 13 | XTENSA_ESP32_ELF_PATH=$TOOLS_PATH/xtensa-esp32-elf 14 | ESP_IDF_PATH=$SDK_PATH/esp-idf 15 | 16 | the_sdk_path=`cd $ESP_IDF_PATH; pwd` 17 | the_tool_chain_path=`cd $XTENSA_ESP32_ELF_PATH/bin; pwd` 18 | 19 | export PATH="$PATH:$the_tool_chain_path" 20 | export IDF_PATH="$the_sdk_path" 21 | 22 | 23 | if [ "$1" == "config" ]; then 24 | make menuconfig 25 | elif [ "$1" == "build" ]; then 26 | make all 27 | elif [ "$1" == "flash" ]; then 28 | make flash 29 | elif [ "$1" == "build-app" ]; then 30 | make app 31 | elif [ "$1" == "flash-app" ]; then 32 | make app-flash 33 | elif [ "$1" == "monitor" ]; then 34 | make monitor 35 | elif [ "$1" == "clean" ]; then 36 | make clean 37 | elif [ "$1" == "help" ]; then 38 | echo "bash run.sh config" 39 | echo " |- basic configuration by GUI, if we use -j4 to build and flash, we must first config then build or flash!!!" 40 | echo "bash run.sh build" 41 | echo " |- build all" 42 | echo "bash run.sh flash" 43 | echo " |- build all and flash the program" 44 | echo "bash run.sh build-app" 45 | echo " |- just build app, not build bootloader and partition table" 46 | echo "bash run.sh flash-app" 47 | echo " |- just flash app, when bootloader and partition table have not changed, no need to flash" 48 | echo " |- more infomation:https://docs.espressif.com/projects/esp-idf/zh_CN/v3.1.1/get-started/make-project.html" 49 | echo "bash run.sh monitor" 50 | echo " |- monitor the program, 'Ctrl+]' to stop" 51 | echo " |- IDF Monitor:https://docs.espressif.com/projects/esp-idf/zh_CN/v3.1.1/get-started/idf-monitor.html" 52 | else 53 | echo "error, try bash run.sh help" 54 | fi 55 | 56 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/common_components/ic_ds1302/include/ic_ds1302_config.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: ic_ds1302_config.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Tue 01 Aug 2023 15:21:40 CST 6 | ************************************************************************/ 7 | 8 | #ifndef _IC_DS1302_CONFIG_H 9 | #define _IC_DS1302_CONFIG_H 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | 18 | #define GPIO_I2C_GC_SCL 13 19 | #define GPIO_I2C_GC_IO 32 20 | #define GPIO_I2C_GC_CE 27 21 | 22 | 23 | //==========【配置IIC驱动引脚】======== 24 | #include "string.h" 25 | #define GPIO_BIT(x) (1ULL << (x)) 26 | #define DS1302_IIC_IO_INIT \ 27 | do{ \ 28 | gpio_config_t io_conf; \ 29 | memset(&io_conf, 0, sizeof(gpio_config_t));\ 30 | io_conf.mode = GPIO_MODE_OUTPUT;\ 31 | io_conf.pin_bit_mask =\ 32 | GPIO_BIT(GPIO_I2C_GC_CE) |\ 33 | GPIO_BIT(GPIO_I2C_GC_IO) |\ 34 | GPIO_BIT(GPIO_I2C_GC_SCL);\ 35 | gpio_config(&io_conf);\ 36 | }while(0) 37 | 38 | //===================================== 39 | 40 | #define DS1302_IIC_IO_IN do{\ 41 | gpio_set_direction(GPIO_I2C_GC_IO,GPIO_MODE_INPUT);\ 42 | gpio_set_pull_mode(GPIO_I2C_GC_CE,GPIO_PULLUP_ONLY);\ 43 | }while(0) 44 | #define DS1302_IIC_IO_OUTPUT do{\ 45 | gpio_set_direction(GPIO_I2C_GC_IO,GPIO_MODE_OUTPUT);\ 46 | }while(0) 47 | 48 | #define DS1302_IIC_SCL_HIGH gpio_set_level(GPIO_I2C_GC_SCL,1) 49 | #define DS1302_IIC_IO_HIGH gpio_set_level(GPIO_I2C_GC_IO,1) 50 | #define DS1302_IIC_CE_HIGH gpio_set_level(GPIO_I2C_GC_CE,1) 51 | 52 | #define DS1302_IIC_SCL_LOW gpio_set_level(GPIO_I2C_GC_SCL,0) 53 | #define DS1302_IIC_IO_LOW gpio_set_level(GPIO_I2C_GC_IO,0) 54 | #define DS1302_IIC_CE_LOW gpio_set_level(GPIO_I2C_GC_CE,0) 55 | 56 | #define DS1302_IIC_IO_WRITE(bit) gpio_set_level(GPIO_I2C_GC_IO,bit) 57 | #define DS1302_IIC_IO_READ gpio_get_level(GPIO_I2C_GC_IO) 58 | 59 | #define DS1302_IIC_DELAY_200US ets_delay_us(200) 60 | #define DS1302_IIC_DELAY_100US ets_delay_us(100) 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/jm_xxj/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's CMakeLists 2 | # in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | add_compile_options(-fdiagnostics-color=always) 5 | 6 | if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/../../config/) 7 | set(QCLOUD_PATH ${CMAKE_CURRENT_LIST_DIR}/../..) 8 | elseif(EXISTS ${CMAKE_CURRENT_LIST_DIR}/components/qcloud) 9 | set(QCLOUD_PATH ${CMAKE_CURRENT_LIST_DIR}/components/qcloud) 10 | elseif(EXISTS ${CMAKE_CURRENT_LIST_DIR}/components/esp-qcloud) 11 | set(QCLOUD_PATH ${CMAKE_CURRENT_LIST_DIR}/components/esp-qcloud) 12 | elseif(EXISTS $ENV{IDF_PATH}/components/qcloud) 13 | set(QCLOUD_PATH $ENV{IDF_PATH}/components/qcloud) 14 | elseif(EXISTS $ENV{IDF_PATH}/components/esp-qcloud) 15 | set(QCLOUD_PATH $ENV{IDF_PATH}/components/esp-qcloud) 16 | else() 17 | message(FATAL_ERROR "Please configure the path of `QCLOUD_PATH`") 18 | endif() 19 | 20 | if(NOT DEFINED IDF_TARGET) 21 | set(IDF_TARGET "esp32") 22 | endif() 23 | 24 | # Add QCloud components and other common application components 25 | # This example uses an extra component for common functions such as led and button. 26 | set(EXTRA_COMPONENT_DIRS ${QCLOUD_PATH} 27 | ${QCLOUD_PATH}/examples/common_components/ic_tm1650 28 | ${QCLOUD_PATH}/examples/common_components/ic_ds1302 29 | ${QCLOUD_PATH}/examples/common_components/cmp_rtc 30 | ${QCLOUD_PATH}/examples/common_components/cmp_timing 31 | ${QCLOUD_PATH}/examples/common_components/cmp_xxj_bt 32 | ${QCLOUD_PATH}/examples/common_components/led 33 | ${QCLOUD_PATH}/examples/common_components/button) 34 | 35 | # Performance Options 36 | if(NOT DEFINED PERF) 37 | set(PERF "defaults") 38 | endif() 39 | set(SDKCONFIG_DEFAULTS ${QCLOUD_PATH}/config/sdkconfig_defaults/sdkconfig.${PERF}.${IDF_TARGET}) 40 | 41 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 42 | string(REGEX REPLACE ".*/\(.*\)" "\\1" CURDIR ${CMAKE_CURRENT_SOURCE_DIR}) 43 | project(${CURDIR}) 44 | 45 | git_describe(PROJECT_VERSION ${COMPONENT_DIR}) 46 | message("Project commit: " ${PROJECT_VERSION}) 47 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/common_components/ic_tm1650/include/ic_tm1650_config.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: ic_tm1650_config.h 3 | > Author: https://blog.csdn.net/luliplus/article/details/124023411 4 | > Mail: 5 | > Created Time: Mon 05 Dec 2022 01:21:11 HKT 6 | ************************************************************************/ 7 | 8 | #ifndef _IC_TM1650_CONFIG_H 9 | #define _IC_TM1650_CONFIG_H 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #define GPIO_I2C_DG_SCL 23 18 | #define GPIO_I2C_DG_SDA 22 19 | 20 | //==========【配置IIC驱动引脚】======== 21 | 22 | //配置驱动SCL的gpio为开漏输出模式 23 | #define TM1650_IIC_SCL_MODE_OD \ 24 | do{\ 25 | gpio_set_direction(GPIO_I2C_DG_SCL, GPIO_MODE_INPUT_OUTPUT_OD);\ 26 | gpio_set_pull_mode(GPIO_I2C_DG_SCL, GPIO_FLOATING);\ 27 | }while(0) 28 | 29 | //配置驱动SDA的gpio为开漏输出模式 30 | #define TM1650_IIC_SDA_MODE_OD \ 31 | do{ \ 32 | gpio_set_direction(GPIO_I2C_DG_SDA, GPIO_MODE_INPUT_OUTPUT_OD);\ 33 | gpio_set_pull_mode(GPIO_I2C_DG_SDA, GPIO_FLOATING);\ 34 | }while(0) 35 | 36 | //===================================== 37 | 38 | 39 | //========【配置IIC总线的信号读写和时序】======= 40 | //主机拉高SCL 41 | #define TM1650_IIC_SCL_HIGH gpio_set_level(GPIO_I2C_DG_SCL,1) 42 | 43 | //主机拉低SCL 44 | #define TM1650_IIC_SCL_LOW gpio_set_level(GPIO_I2C_DG_SCL,0) 45 | 46 | 47 | //主机拉高SDA 48 | #define TM1650_IIC_SDA_HIGH gpio_set_level(GPIO_I2C_DG_SDA,1) 49 | 50 | //主机拉低SDA 51 | #define TM1650_IIC_SDA_LOW gpio_set_level(GPIO_I2C_DG_SDA,0) 52 | 53 | //参数b为0时主机拉低SDA,非0则拉高SDA 54 | #define TM1650_IIC_SDA_WR(b) do{ \ 55 | if(b) gpio_set_level(GPIO_I2C_DG_SDA,1); \ 56 | else gpio_set_level(GPIO_I2C_DG_SDA,0); \ 57 | }while(0) 58 | 59 | 60 | //主机读取SDA线电平状态,返回值为0为低电平,非0则为高电平 61 | #define TM1650_IIC_SDA_RD() gpio_get_level(GPIO_I2C_DG_SDA) 62 | 63 | //软件延时2us 64 | #define TM1650_IIC_DELAY_2US ets_delay_us(2) 65 | 66 | //软件延时4us 67 | #define TM1650_IIC_DELAY_4US ets_delay_us(4) 68 | //================================ 69 | 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/jm_xxj/main/app_main.c: -------------------------------------------------------------------------------- 1 | /* LED Light Example 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #include 11 | #include 12 | #include "esp_qcloud_log.h" 13 | #include "esp_qcloud_console.h" 14 | #include "esp_qcloud_storage.h" 15 | #include "esp_qcloud_iothub.h" 16 | #include "esp_qcloud_prov.h" 17 | 18 | #include "app_fragrance.h" 19 | #include "app_timing.h" 20 | #include "app_driver.h" 21 | #include "bt_gap.h" 22 | #include "wifi_server.h" 23 | 24 | 25 | #ifdef CONFIG_BT_ENABLE 26 | #include "esp_bt.h" 27 | #endif 28 | 29 | static const char *TAG = "app_main"; 30 | 31 | /* 32 | * driver -> app_fragrance -> wifi_server -> app_main 33 | * driver -> app_timing -> cmp_xxj_bt -> app_main 34 | */ 35 | void app_main() 36 | { 37 | /** 38 | * @brief Add debug function, you can use serial command and remote debugging. 39 | */ 40 | esp_qcloud_log_config_t log_config = { 41 | .log_level_uart = ESP_LOG_INFO, 42 | }; 43 | ESP_ERROR_CHECK(esp_qcloud_log_init(&log_config)); 44 | /** 45 | * @brief Set log level 46 | * @note This function can not raise log level above the level set using 47 | * CONFIG_LOG_DEFAULT_LEVEL setting in menuconfig. 48 | */ 49 | esp_log_level_set("*", ESP_LOG_VERBOSE); 50 | 51 | #ifdef CONFIG_LIGHT_DEBUG 52 | ESP_ERROR_CHECK(esp_qcloud_console_init()); 53 | esp_qcloud_print_system_info(10000); 54 | #endif /**< CONFIG_LIGHT_DEBUG */ 55 | 56 | 57 | /**< Continuous power off and restart more than five times to reset the device */ 58 | if (esp_qcloud_reboot_unbroken_count() >= 3) { 59 | ESP_LOGW(TAG, "Erase information saved in flash"); 60 | esp_qcloud_storage_erase(CONFIG_QCLOUD_NVS_NAMESPACE); 61 | } else if (esp_qcloud_reboot_is_exception(false)) { 62 | ESP_LOGE(TAG, "The device has been restarted abnormally"); 63 | } else { 64 | } 65 | 66 | app_driver_init(); 67 | app_fragrance_init(); 68 | app_timing_init(); 69 | app_bt_gap_init(); 70 | app_wifi_server_init(); 71 | } 72 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #I don't like to set environment variables in the system, 4 | #so I put the environment variables in run.sh. 5 | #Every time I use run.sh, the enviroment variables will be set, after use that will be unsetted. 6 | 7 | 8 | PROJECT_ROOT=../.. 9 | TOOLS_PATH=$PROJECT_ROOT/tool 10 | SDK_PATH=$PROJECT_ROOT/sdk 11 | APP_PATH=$PROJECT_ROOT/app 12 | 13 | XTENSA_ESP32_ELF_PATH=$TOOLS_PATH/xtensa-esp32-elf 14 | ESP_IDF_PATH=$SDK_PATH/esp-idf 15 | 16 | the_sdk_path=`cd $ESP_IDF_PATH; pwd` 17 | the_tool_chain_path=`cd $XTENSA_ESP32_ELF_PATH/bin; pwd` 18 | 19 | export PATH="$PATH:$the_tool_chain_path" 20 | export IDF_PATH="$the_sdk_path" 21 | 22 | GIT_ESP_QCLOUD_LINK=https://github.com/oldprogram/esp-qcloud.git 23 | 24 | #-------------------------------------------------------------------------- 25 | function install_project_from_github(){ 26 | echo "> install project form github ..." 27 | if [ ! -d "./esp-qcloud/" ]; then 28 | git clone $GIT_ESP_QCLOUD_LINK 29 | cd esp-qcloud 30 | git checkout 43e218d 31 | cd - 32 | cp -r my_src/* ./esp-qcloud/ 33 | fi 34 | 35 | cd $ESP_IDF_PATH 36 | if git rev-parse --verify release/v4.3;then 37 | echo "> in right brach" 38 | else 39 | echo "> change to right brach" 40 | git checkout release/v4.3 41 | fi 42 | 43 | python --version 44 | bash install.sh 45 | #. ./export.sh 46 | echo '' 47 | echo '> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 48 | echo '> you should run source '$TOOLS_PATH'/pvevn/bin/active in every new terminal' 49 | echo '> you should run . '$ESP_IDF_PATH'/export.sh in every new terminal' 50 | echo '> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 51 | cd - 52 | } 53 | 54 | function app_op(){ 55 | #. $ESP_IDF_PATH/export.sh 56 | echo ">> SDK_OP "$1 57 | 58 | cd ./esp-qcloud/examples/jm_xxj/ 59 | if [ "$1" == "make" ]; then 60 | idf.py build 61 | elif [ "$1" == "flash" ]; then 62 | idf.py flash 63 | elif [ "$1" == "monitor" ]; then 64 | idf.py monitor 65 | elif [ "$1" == "clean" ]; then 66 | idf.py fullclean 67 | else 68 | echo "error, try bash run.sh help" 69 | fi 70 | cd - 71 | } 72 | 73 | if [ "$1" == "create" ]; then 74 | install_project_from_github 75 | elif [ "$1" == "app" ];then 76 | app_op $2 77 | elif [ "$1" == "help" ];then 78 | echo "|----------------------------------------------------" 79 | echo "| ./run.sh op param" 80 | echo "| op:" 81 | echo "| create : downloads qcloud and cp my_src to qcloud" 82 | echo "| clean : make clean" 83 | echo "| examples:" 84 | echo "| first create project: create" 85 | echo "| second : app make -> app flash -> app monitor" 86 | echo "|----------------------------------------------------" 87 | echo '' 88 | echo '> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 89 | echo '> you should run source '$TOOLS_PATH'/pvevn/bin/active in every new terminal' 90 | echo '> you should run . '$ESP_IDF_PATH'/export.sh in every new terminal' 91 | echo '> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' 92 | else 93 | echo "error, try bash run.sh help" 94 | fi 95 | 96 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/common_components/ic_tm1650/src/ic_tm1650.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: ic_tm1650.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Mon 05 Dec 2022 00:47:43 HKT 6 | ************************************************************************/ 7 | #include "ic_tm1650.h" 8 | #include "ic_tm1650_config.h" 9 | 10 | 11 | //产生IIC总线起始信号 12 | static void TM1650_IIC_start(void){ 13 | TM1650_IIC_SCL_HIGH; //SCL=1 14 | TM1650_IIC_SDA_HIGH; //SDA=1 15 | TM1650_IIC_DELAY_4US; 16 | TM1650_IIC_SDA_LOW; //SDA=0 17 | TM1650_IIC_DELAY_4US; 18 | TM1650_IIC_SCL_LOW; //SCL=0 19 | } 20 | 21 | //产生IIC总线结束信号 22 | static void TM1650_IIC_stop(void){ 23 | TM1650_IIC_SCL_LOW; //SCL=0 24 | TM1650_IIC_SDA_LOW; //SDA=0 25 | TM1650_IIC_DELAY_4US; 26 | TM1650_IIC_SCL_HIGH; //SCL=1 27 | TM1650_IIC_DELAY_4US; 28 | TM1650_IIC_SDA_HIGH; //SDA=1 29 | } 30 | 31 | //通过IIC总线发送一个字节 32 | static void TM1650_IIC_write_byte(unsigned char dat){ 33 | unsigned char i; 34 | 35 | TM1650_IIC_SCL_LOW; 36 | for(i=0;i<8;i++){ 37 | TM1650_IIC_SDA_WR(dat&0x80); 38 | dat<<=1; 39 | 40 | TM1650_IIC_DELAY_2US; 41 | TM1650_IIC_SCL_HIGH; 42 | TM1650_IIC_DELAY_2US; 43 | TM1650_IIC_SCL_LOW; 44 | TM1650_IIC_DELAY_2US; 45 | } 46 | } 47 | 48 | //通过IIC总线接收从机响应的ACK信号 49 | static unsigned char TM1650_IIC_wait_ack(void){ 50 | unsigned char ack_signal = 0; 51 | 52 | TM1650_IIC_SDA_HIGH; //SDA=1 53 | TM1650_IIC_DELAY_2US; 54 | TM1650_IIC_SCL_HIGH; 55 | TM1650_IIC_DELAY_2US; 56 | if(TM1650_IIC_SDA_RD()) ack_signal = 1; //如果读取到的是NACK信号 57 | TM1650_IIC_SCL_LOW; 58 | TM1650_IIC_DELAY_2US; 59 | return ack_signal; 60 | } 61 | 62 | 63 | //TM1650初始化 64 | void TM1650_init(void){ 65 | TM1650_IIC_SCL_MODE_OD; //SCL开漏输出 66 | TM1650_IIC_SDA_MODE_OD; //SDA开漏输出 67 | 68 | TM1650_IIC_SDA_HIGH; //释放SDA线 69 | TM1650_IIC_SCL_HIGH; //释放SCL线 70 | 71 | TM1650_cfg_display(TM1650_BRIGHT5); //初始化为5级亮度,打开显示 72 | TM1650_clear(); //将显存内容清0 73 | } 74 | 75 | 76 | //作用:设置显示参数 77 | //备注:这个操作不影响显存中的数据 78 | //用例: 79 | // 设置亮度并打开显示:TM1650_cfg_display(TM1650_BRIGHTx) 80 | // 关闭显示:TM1650_cfg_display(TM1650_DSP_OFF) 81 | void TM1650_cfg_display(unsigned char param){ 82 | TM1650_IIC_start(); 83 | TM1650_IIC_write_byte(0x48); TM1650_IIC_wait_ack(); //固定命令 84 | TM1650_IIC_write_byte(param); TM1650_IIC_wait_ack(); //参数值 85 | TM1650_IIC_stop(); 86 | } 87 | 88 | 89 | //将显存数据全部刷为0,清空显示 90 | void TM1650_clear(void){ 91 | unsigned char dig; 92 | for(dig = TM1650_DIG1 ; dig<= TM1650_DIG4 ;dig++){ 93 | TM1650_print(dig,0); //将显存数据刷为0 94 | } 95 | } 96 | 97 | //往一个指定的数码管位写入指定的显示数据 98 | //共阴数码管段码表: 99 | //const unsigned char TUBE_TABLE_0[10] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //共阴,0~9的数字 100 | //const unsigned char TUBE_TABLE_0[16] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; //共阴,0~9~A~F 101 | //用例: 102 | // 在DIG1位上显示数字3: TM1650_print(TM1650_DIG1,TUBE_TABLE_0[3]); 103 | void TM1650_print(unsigned char dig,unsigned char seg_data){ 104 | TM1650_IIC_start(); 105 | TM1650_IIC_write_byte(dig*2+0x68); TM1650_IIC_wait_ack(); //显存起始地址为0x68 106 | TM1650_IIC_write_byte(seg_data); TM1650_IIC_wait_ack(); //发送段码 107 | TM1650_IIC_stop(); 108 | } 109 | 110 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/common_components/cmp_rtc/include/cmp_rtc.h: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: cmp_rtc.h 3 | > Author: 4 | > Mail: 5 | > Created Time: Mon 20 Feb 2023 23:57:19 HKT 6 | ************************************************************************/ 7 | 8 | #ifndef _CMP_RTC_H 9 | #define _CMP_RTC_H 10 | 11 | 12 | typedef struct{ 13 | void *a; 14 | }cmp_rtc_params_s; 15 | 16 | //from 2000/01/01/00/00/00 epoch time 17 | typedef struct{ 18 | unsigned char second;//0~59 19 | unsigned char minute;//0~59 20 | unsigned char hour;//0~23 21 | unsigned char weekday;//1~7(7:星期天) 22 | unsigned char monthday;//1~31 23 | unsigned char month;//1~12 24 | unsigned short year;// 25 | }cmp_rtc_date_s; 26 | 27 | #define CMP_RTC_Month_January ((unsigned char)0x01) 28 | #define CMP_RTC_Month_February ((unsigned char)0x02) 29 | #define CMP_RTC_Month_March ((unsigned char)0x03) 30 | #define CMP_RTC_Month_April ((unsigned char)0x04) 31 | #define CMP_RTC_Month_May ((unsigned char)0x05) 32 | #define CMP_RTC_Month_June ((unsigned char)0x06) 33 | #define CMP_RTC_Month_July ((unsigned char)0x07) 34 | #define CMP_RTC_Month_August ((unsigned char)0x08) 35 | #define CMP_RTC_Month_September ((unsigned char)0x09) 36 | #define CMP_RTC_Month_October ((unsigned char)0x10) 37 | #define CMP_RTC_Month_November ((unsigned char)0x11) 38 | #define CMP_RTC_Month_December ((unsigned char)0x12) 39 | 40 | #define CMP_RTC_Weekday_Monday ((unsigned char)0x01) 41 | #define CMP_RTC_Weekday_Tuesday ((unsigned char)0x02) 42 | #define CMP_RTC_Weekday_Wednesday ((unsigned char)0x03) 43 | #define CMP_RTC_Weekday_Thursday ((unsigned char)0x04) 44 | #define CMP_RTC_Weekday_Friday ((unsigned char)0x05) 45 | #define CMP_RTC_Weekday_Saturday ((unsigned char)0x06) 46 | #define CMP_RTC_Weekday_Sunday ((unsigned char)0x07) 47 | 48 | #define CMP_RTC_IS_SECOND(N) ((N) < 60) 49 | #define CMP_RTC_IS_MINUTE(N) ((N) < 60) 50 | #define CMP_RTC_IS_HOUR(N) ((N) < 24) 51 | #define CMP_RTC_IS_WEEKDAY(N) (((N) > 0) && ((N) < 8)) 52 | #define CMP_RTC_IS_MONTHDAY(N) (((N) > 0) && ((N) < 32)) 53 | #define CMP_RTC_IS_MONTH(N) (((N) > 0) && ((N) < 13)) 54 | #define CMP_RTC_IS_YEAR(N) (((N) > 0) && ((N) < 4000)) 55 | 56 | #define CMP_RTC_IS_MATCH_WEEKDAY(N) ((N) < 8) 57 | #define CMP_RTC_IS_MATCH_MONTHDAY(N) ((N) < 32) 58 | #define CMP_RTC_IS_MATCH_MONTH(N) ((N) < 13) 59 | #define CMP_RTC_IS_MATCH_YEAR(N) ((N) < 4000) 60 | 61 | 62 | #define cmp_rtc_cmp_kind_s unsigned char 63 | #define CMP_RTC_IS_SAME_SECOND ((unsigned char)0x00) 64 | #define CMP_RTC_IS_SAME_MINUTE ((unsigned char)0x02) 65 | #define CMP_RTC_IS_SAME_HOUR ((unsigned char)0x03) 66 | #define CMP_RTC_IS_SAME_DAY ((unsigned char)0x04) 67 | #define CMP_RTC_IS_SAME_MONTH ((unsigned char)0x05) 68 | #define CMP_RTC_IS_SAME_YEAR ((unsigned char)0x06) 69 | 70 | typedef struct{ 71 | unsigned char (*init)(cmp_rtc_params_s *param); 72 | void (*set_date)(cmp_rtc_date_s date); 73 | void (*get_date)(cmp_rtc_date_s *date); 74 | void (*date_to_utc)(cmp_rtc_date_s date, unsigned int *utc_time);//utc - second 75 | void (*utc_to_date)(unsigned int utc_time, cmp_rtc_date_s *date); 76 | unsigned char (*is_same)(cmp_rtc_date_s *time_stamp1, cmp_rtc_date_s *time_stamp2, cmp_rtc_cmp_kind_s kind); 77 | }cmp_rtc_s; 78 | 79 | extern cmp_rtc_s cmp_rtc; 80 | 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/common_components/cmp_timing/src/cmp_timing.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: cmp_timing.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Mon 27 Feb 2023 00:31:19 HKT 6 | ************************************************************************/ 7 | #include "string.h" 8 | #include "cmp_rtc.h" 9 | #include "cmp_timing.h" 10 | #include "esp_log.h" 11 | #include "freertos/FreeRTOS.h" 12 | #include "freertos/timers.h" 13 | 14 | 15 | 16 | void ty_timing_init(struct ITiming *pITiming, unsigned char num); 17 | void ty_timing_set(struct ITiming *pITiming,unsigned char enable,unsigned short time,unsigned char repet,unsigned char day,unsigned char (*cb)(unsigned char index)); 18 | void ty_timing_kill(struct ITiming *pITiming); 19 | 20 | 21 | static const char *TAG = "cmp_timing"; 22 | 23 | /////////////////////////////////////////////////////////////////////// 24 | struct ITimingFunc mITimingFunc = { 25 | .init = &ty_timing_init, 26 | .set = &ty_timing_set, 27 | .kill = &ty_timing_kill, 28 | }; 29 | 30 | static unsigned char timing_num = 0; 31 | struct ITiming *pITimings = NULL; 32 | /////////////////////////////////////////////////////////////////////// 33 | 34 | 35 | static void cmp_timing_timer_cb(void *timer){ 36 | static unsigned int cyc_send_time=0; 37 | static unsigned char pre_minute = 61;//防止同一分钟执行多次动作 38 | 39 | //1.获取当前星期和Hour:Minute 40 | cmp_rtc_date_s date; 41 | cmp_rtc.get_date(&date); 42 | 43 | if(pre_minute == date.minute || date.year == 0)return; 44 | 45 | unsigned short time = (unsigned short)date.hour*60+(unsigned short)date.minute; 46 | pre_minute = date.minute; 47 | 48 | for(unsigned char i=0;ienable == 1){ 51 | // ESP_LOGI(TAG, "[T_N] %x \r\n", time); 52 | // ESP_LOGI(TAG, "[T_T] %x \r\n", p->time); 53 | //2.比较是否到达定时 54 | if(time == p->time){ 55 | //ESP_LOGI(TAG, "[T=T]\r\n"); 56 | //3.分别处理重复定时和非重复定时 57 | if(p->repet == 1){ 58 | //4.判断week是否匹配 59 | if((((p->day)>>(8-date.weekday))&0x01) == 0x01){ 60 | //5.如果匹配执行动作 61 | if(p->timing_end_cb != NULL) 62 | p->timing_end_cb(i); 63 | } 64 | }else{ 65 | //4.判断week是否匹配 66 | if((((p->day)>>(7-date.weekday))&0x01) == 0x01){ 67 | //5.如果匹配执行动作 68 | if(p->timing_end_cb != NULL) 69 | p->timing_end_cb(i); 70 | //6.失能 71 | p->enable = 0; 72 | } 73 | } 74 | } 75 | } 76 | } 77 | } 78 | 79 | /////////////////////////////////////////////////////////// 80 | //对外函数 81 | /////////////////////////////////////////////////////////// 82 | void ty_timing_init(struct ITiming *pITiming, unsigned char num){ 83 | for(unsigned char i=0;ienable = (enable == 0?0:1); 99 | pITiming->time = time; 100 | pITiming->repet = (repet == 0?0:1); 101 | pITiming->day = day; 102 | pITiming->timing_end_cb = cb; 103 | } 104 | 105 | void ty_timing_kill(struct ITiming *pITiming){ 106 | pITiming->enable = 0; 107 | } 108 | 109 | -------------------------------------------------------------------------------- /app/aliyun_demo/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #I don't like to set environment variables in the system, 4 | #so I put the environment variables in run.sh. 5 | #Every time I use run.sh, the enviroment variables will be set, after use that will be unsetted. 6 | 7 | 8 | PROJECT_ROOT=../.. 9 | TOOLS_PATH=$PROJECT_ROOT/tool 10 | SDK_PATH=$PROJECT_ROOT/sdk 11 | APP_PATH=$PROJECT_ROOT/app 12 | 13 | XTENSA_ESP32_ELF_PATH=$TOOLS_PATH/xtensa-esp32-elf 14 | ESP_IDF_PATH=$SDK_PATH/esp-idf 15 | 16 | the_sdk_path=`cd $ESP_IDF_PATH; pwd` 17 | the_tool_chain_path=`cd $XTENSA_ESP32_ELF_PATH/bin; pwd` 18 | 19 | export PATH="$PATH:$the_tool_chain_path" 20 | export IDF_PATH="$the_sdk_path" 21 | 22 | GIT_IOTKIT_EMBEDDED_LINK=https://github.com/oldprogram/iotkit-embedded.git 23 | GIT_ESP_ALIYUN_LINK=https://github.com/oldprogram/esp-aliyun.git 24 | #GIT_ESP_ALIYUN_LINK=https://github.com/espressif/esp-aliyun.git 25 | #GIT_IOTKIT_EMBEDDED_LINK=https://github.com/aliyun/iotkit-embedded.git 26 | 27 | #-------------------------------------------------------------------------- 28 | function install_project_from_github(){ 29 | echo "> install project form github ..." 30 | if [ ! -d "./esp-aliyun/" ]; then 31 | git clone $GIT_ESP_ALIYUN_LINK 32 | 33 | # remove the iotkit-git link 34 | # make a link iotkit-embedded->../iotkit-embedded to ./esp-aliyun/iotkit-embedded 35 | rm -rf ./esp-aliyun/iotkit-embedded/ 36 | ln -s ../iotkit-embedded ./esp-aliyun/iotkit-embedded 37 | 38 | # remove the mqtt_example.c 39 | # move cp mqtt_example.c replace pre-one 40 | rm -rf ./esp-aliyun/examples/mqtt_example/main/mqtt_example.c 41 | cp ./my_src/mqtt_example.c ./esp-aliyun/examples/mqtt_example/main/ 42 | fi 43 | 44 | if [ ! -d "./iotkit-embedded/" ]; then 45 | git clone $GIT_IOTKIT_EMBEDDED_LINK 46 | 47 | # cp config.esp32.aos to ./iotkit-embedded/src/board/ 48 | cp ./my_src/config.esp32.aos ./iotkit-embedded/src/board/ 49 | fi 50 | 51 | cd $ESP_IDF_PATH 52 | git checkout release/v3.3 53 | python --version 54 | python -m pip install -r $ESP_IDF_PATH/requirements.txt 55 | git submodule update 56 | cd - 57 | } 58 | 59 | function sdk_op(){ 60 | echo ">> APP_OP "$1 61 | 62 | cd ./iotkit-embedded/ 63 | if [ "$1" == "reconfig" ]; then 64 | make reconfig 65 | elif [ "$1" == "config" ]; then 66 | make menuconfig 67 | elif [ "$1" == "make" ]; then 68 | make 69 | elif [ "$1" == "clean" ]; then 70 | make distclean 71 | else 72 | echo "error, try bash run.sh help" 73 | fi 74 | cd - 75 | } 76 | 77 | function app_op(){ 78 | echo ">> SDK_OP "$1 79 | 80 | cd ./esp-aliyun/examples/mqtt_example/ 81 | if [ "$1" == "defconfig" ]; then 82 | make defconfig 83 | elif [ "$1" == "config" ]; then 84 | make menuconfig 85 | elif [ "$1" == "make" ]; then 86 | make 87 | elif [ "$1" == "erase" ]; then 88 | make erase 89 | elif [ "$1" == "flash" ]; then 90 | make flash 91 | elif [ "$1" == "monitor" ]; then 92 | make monitor 93 | elif [ "$1" == "clean" ]; then 94 | make clean 95 | else 96 | echo "error, try bash run.sh help" 97 | fi 98 | cd - 99 | } 100 | 101 | if [ "$1" == "create" ]; then 102 | install_project_from_github 103 | elif [ "$1" == "sdk" ]; then 104 | sdk_op $2 105 | elif [ "$1" == "app" ];then 106 | app_op $2 107 | elif [ "$1" == "help" ];then 108 | echo "|----------------------------------------------------" 109 | echo "| ./run.sh op param" 110 | echo "| op:" 111 | echo "| create : downloads iotkit and aliyun-esp32 from github and make some change" 112 | echo "| sdk : param = reconfig/config/make/clean" 113 | echo "| app : param = deconfig/config/make/erase/flash/monitor/clean" 114 | echo "| examples:" 115 | echo "| first create sdk lib : create -> sdk reconfig -> sdk config -> sdk make" 116 | echo "| second create app : config -> make -> flash -> monitor" 117 | echo "|----------------------------------------------------" 118 | else 119 | echo "error, try bash run.sh help" 120 | fi 121 | 122 | -------------------------------------------------------------------------------- /app/aliyun_dd_xxj/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #I don't like to set environment variables in the system, 4 | #so I put the environment variables in run.sh. 5 | #Every time I use run.sh, the enviroment variables will be set, after use that will be unsetted. 6 | 7 | 8 | PROJECT_ROOT=../.. 9 | TOOLS_PATH=$PROJECT_ROOT/tool 10 | SDK_PATH=$PROJECT_ROOT/sdk 11 | APP_PATH=$PROJECT_ROOT/app 12 | 13 | XTENSA_ESP32_ELF_PATH=$TOOLS_PATH/xtensa-esp32-elf 14 | ESP_IDF_PATH=$SDK_PATH/esp-idf 15 | 16 | the_sdk_path=`cd $ESP_IDF_PATH; pwd` 17 | the_tool_chain_path=`cd $XTENSA_ESP32_ELF_PATH/bin; pwd` 18 | 19 | export PATH="$PATH:$the_tool_chain_path" 20 | export IDF_PATH="$the_sdk_path" 21 | 22 | GIT_IOTKIT_EMBEDDED_LINK=https://github.com/oldprogram/iotkit-embedded.git 23 | GIT_ESP_ALIYUN_LINK=https://github.com/oldprogram/esp-aliyun.git 24 | #GIT_ESP_ALIYUN_LINK=https://github.com/espressif/esp-aliyun.git 25 | #GIT_IOTKIT_EMBEDDED_LINK=https://github.com/aliyun/iotkit-embedded.git 26 | 27 | #-------------------------------------------------------------------------- 28 | function install_project_from_github(){ 29 | echo "> install project form github ..." 30 | if [ ! -d "./esp-aliyun/" ]; then 31 | git clone $GIT_ESP_ALIYUN_LINK 32 | 33 | # remove the iotkit-git link 34 | # make a link iotkit-embedded->../iotkit-embedded to ./esp-aliyun/iotkit-embedded 35 | rm -rf ./esp-aliyun/iotkit-embedded/ 36 | ln -s ../iotkit-embedded ./esp-aliyun/iotkit-embedded 37 | 38 | # remove the mqtt_example.c 39 | # move cp mqtt_example.c replace pre-one 40 | rm -rf ./esp-aliyun/examples/mqtt_example/main/mqtt_example.c 41 | cp ./my_src/mqtt_example.c ./esp-aliyun/examples/mqtt_example/main/ 42 | fi 43 | 44 | if [ ! -d "./iotkit-embedded/" ]; then 45 | git clone $GIT_IOTKIT_EMBEDDED_LINK 46 | 47 | # cp config.esp32.aos to ./iotkit-embedded/src/board/ 48 | cp ./my_src/config.esp32.aos ./iotkit-embedded/src/board/ 49 | fi 50 | 51 | cd $ESP_IDF_PATH 52 | git checkout release/v3.3 53 | python --version 54 | python -m pip install -r $ESP_IDF_PATH/requirements.txt 55 | git submodule update 56 | cd - 57 | } 58 | 59 | function sdk_op(){ 60 | echo ">> APP_OP "$1 61 | 62 | cd ./iotkit-embedded/ 63 | if [ "$1" == "reconfig" ]; then 64 | make reconfig 65 | elif [ "$1" == "config" ]; then 66 | make menuconfig 67 | elif [ "$1" == "make" ]; then 68 | make 69 | elif [ "$1" == "clean" ]; then 70 | make distclean 71 | else 72 | echo "error, try bash run.sh help" 73 | fi 74 | cd - 75 | } 76 | 77 | function app_op(){ 78 | echo ">> SDK_OP "$1 79 | 80 | cd ./esp-aliyun/examples/mqtt_example/ 81 | if [ "$1" == "defconfig" ]; then 82 | make defconfig 83 | elif [ "$1" == "config" ]; then 84 | make menuconfig 85 | elif [ "$1" == "make" ]; then 86 | make 87 | elif [ "$1" == "erase" ]; then 88 | make erase 89 | elif [ "$1" == "flash" ]; then 90 | make flash 91 | elif [ "$1" == "monitor" ]; then 92 | make monitor 93 | elif [ "$1" == "clean" ]; then 94 | make clean 95 | else 96 | echo "error, try bash run.sh help" 97 | fi 98 | cd - 99 | } 100 | 101 | if [ "$1" == "create" ]; then 102 | install_project_from_github 103 | elif [ "$1" == "sdk" ]; then 104 | sdk_op $2 105 | elif [ "$1" == "app" ];then 106 | app_op $2 107 | elif [ "$1" == "help" ];then 108 | echo "|----------------------------------------------------" 109 | echo "| ./run.sh op param" 110 | echo "| op:" 111 | echo "| create : downloads iotkit and aliyun-esp32 from github and make some change" 112 | echo "| sdk : param = reconfig/config/make/clean" 113 | echo "| app : param = deconfig/config/make/erase/flash/monitor/clean" 114 | echo "| examples:" 115 | echo "| first create sdk lib : create -> sdk reconfig -> sdk config -> sdk make" 116 | echo "| second create app : config -> make -> flash -> monitor" 117 | echo "|----------------------------------------------------" 118 | else 119 | echo "error, try bash run.sh help" 120 | fi 121 | 122 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/jm_xxj/main/app_fragrance.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: app_fragrance.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Sat 03 Dec 2022 22:03:22 HKT 6 | ************************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | #include "freertos/FreeRTOS.h" 15 | #include "freertos/queue.h" 16 | #include "freertos/task.h" 17 | #include "freertos/timers.h" 18 | 19 | #include "esp_qcloud_utils.h" 20 | #include "esp_qcloud_storage.h" 21 | 22 | #include "cJSON.h" 23 | 24 | #include "app_driver.h" 25 | 26 | static const char *TAG = "app_fragrance"; 27 | 28 | typedef struct{ 29 | bool onoff; 30 | char device1; 31 | int start1; 32 | int stop1; 33 | char device2; 34 | int start2; 35 | int stop2; 36 | }work_model_s; 37 | 38 | static work_model_s app_work_model; 39 | static TimerHandle_t g_fragrance_timer = NULL; 40 | static int count = 0; 41 | 42 | 43 | 44 | static void app_fragrance_timer_cb(void *timer){ 45 | if(app_work_model.onoff == 1){ 46 | if(count == 0){//第一个设备,开始工作 47 | app_driver_set_fragrance_onoff(app_work_model.device1,1); 48 | } 49 | if(count == app_work_model.start1){//第一个设备,开始休息 50 | app_driver_set_fragrance_onoff(app_work_model.device1,0); 51 | } 52 | if(count == app_work_model.start1 + app_work_model.stop1){//第二个设备,开始工作 53 | app_driver_set_fragrance_onoff(app_work_model.device2,1); 54 | } 55 | if(count == app_work_model.start1 + app_work_model.stop1 + app_work_model.start2){//第二个设备,开始休息 56 | app_driver_set_fragrance_onoff(app_work_model.device2,0); 57 | } 58 | if(count >= app_work_model.start1 + app_work_model.stop1 + app_work_model.start2 + app_work_model.stop2){//第一个设备,开始工作 59 | count = -1; 60 | } 61 | 62 | count++; 63 | } 64 | } 65 | 66 | esp_err_t app_fragrance_set_onoff(bool on){ 67 | esp_err_t ret = ESP_OK; 68 | 69 | ESP_LOGW(TAG, "SET ONOFF:%d",on); 70 | app_work_model.onoff = on; 71 | 72 | if(on == 0){ 73 | app_driver_set_fragrance_onoff('A',0); 74 | app_driver_set_fragrance_onoff('B',0); 75 | } 76 | 77 | return ESP_OK; 78 | } 79 | 80 | esp_err_t app_fragrance_set_fan_speed(int speed){ 81 | app_driver_set_fan_speed(speed); 82 | return ESP_OK; 83 | } 84 | 85 | esp_err_t app_fragrance_set_work_model(cJSON *work_model){ 86 | esp_err_t ret = ESP_OK; 87 | 88 | work_model_s *p_work_model = &app_work_model; 89 | for (cJSON *item = work_model; item; item = item->next) { 90 | char *key = item->string; 91 | ESP_LOGW(TAG,"SET WORK MODEL:%s",key); 92 | if (!strcmp(key, "fragrance1")) { 93 | p_work_model->device1 = item->valuestring[0]; 94 | }else if (!strcmp(key, "work_time1")) { 95 | p_work_model->start1 = item->valueint; 96 | }else if (!strcmp(key, "stop_time1")) { 97 | p_work_model->stop1 = item->valueint; 98 | }else if (!strcmp(key, "fragrance2")) { 99 | p_work_model->device2 = item->valuestring[0]; 100 | }else if (!strcmp(key, "work_time2")) { 101 | p_work_model->start2 = item->valueint; 102 | }else if (!strcmp(key, "stop_time2")) { 103 | p_work_model->stop2 = item->valueint; 104 | } 105 | } 106 | 107 | app_driver_set_fragrance_onoff('A',0); 108 | app_driver_set_fragrance_onoff('B',0); 109 | count = 0; 110 | 111 | ESP_LOGW(TAG, "SET WORK MODEL:[ONOFF:%d]-[%c %ds %ds]-[%c %ds %ds]", 112 | p_work_model->onoff, 113 | p_work_model->device1, 114 | p_work_model->start1, 115 | p_work_model->stop1, 116 | p_work_model->device2, 117 | p_work_model->start2, 118 | p_work_model->stop2); 119 | 120 | return ESP_OK; 121 | } 122 | 123 | 124 | esp_err_t app_fragrance_init(void){ 125 | g_fragrance_timer = xTimerCreate("app fragrance timer", 1000, true, NULL, app_fragrance_timer_cb);//1S 126 | xTimerStart(g_fragrance_timer, 0); 127 | 128 | return ESP_OK; 129 | } 130 | -------------------------------------------------------------------------------- /tool/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | PROJECT_ROOT=.. 6 | TOOLS_PATH=$PROJECT_ROOT/tool 7 | SDK_PATH=$PROJECT_ROOT/sdk 8 | APP_PATH=$PROJECT_ROOT/app 9 | 10 | XTENSA_ESP32_ELF_PATH=$TOOLS_PATH/xtensa-esp32-elf 11 | ESP_IDF_PATH=$SDK_PATH/esp-idf 12 | 13 | XTENSA_ESP32_ELF_LINK=https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz 14 | ESP_IDF_LINK=https://github.com/espressif/esp-idf.git 15 | 16 | #-------------------------------------------------------------------------- 17 | function install_tool_chain(){ 18 | echo "> install tool chain ..." 19 | echo "> web page: https://docs.espressif.com/projects/esp-idf/zh_CN/v3.1.1/get-started/linux-setup.html" 20 | if [ ! -d $XTENSA_ESP32_ELF_PATH ]; then 21 | wget $XTENSA_ESP32_ELF_LINK 22 | tar -xzf xtensa-esp32-elf*.tar.gz 23 | rm xtensa-esp32-elf*.tar.gz 24 | fi 25 | } 26 | 27 | function install_esp_idf(){ 28 | echo "> install esp idf ..." 29 | echo "> web page: https://github.com/espressif/esp-idf" 30 | if [ ! -d $ESP_IDF_PATH ]; then 31 | git clone $ESP_IDF_LINK 32 | mv esp-idf $SDK_PATH/ 33 | fi 34 | } 35 | 36 | function create_project(){ 37 | if [ "$1" == "" ] || [ "$2" == "" ]; then 38 | echo "input error" 39 | elif [ -d $1 ] && [ ! -d "$APP_PATH/$2" ]; then 40 | cp -r $1 $APP_PATH/$2 41 | 42 | 43 | file=$APP_PATH/$2/run.sh 44 | the_sdk_path=`cd $ESP_IDF_PATH; pwd` 45 | the_tool_chain_path=`cd $XTENSA_ESP32_ELF_PATH/bin; pwd` 46 | 47 | cat > $file < File Name: timing_work_mode.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Tue 19 Nov 2019 17:03:36 CST 6 | ************************************************************************/ 7 | #include "cmp_timing.h" 8 | #include "cmp_rtc.h" 9 | #include "ic_ds1302.h" 10 | #include "esp_log.h" 11 | #include 12 | #include "freertos/FreeRTOS.h" 13 | #include "freertos/timers.h" 14 | 15 | #include "app_driver.h" 16 | 17 | static const char *TAG = "app_timing"; 18 | 19 | typedef struct{ 20 | unsigned char level; 21 | unsigned char work; 22 | unsigned char not_work; 23 | unsigned char count; 24 | unsigned char is_timing; 25 | }work_s; 26 | 27 | #define MAX_WORK_NUM 8 28 | work_s work[MAX_WORK_NUM]; 29 | struct ITiming timing[2*MAX_WORK_NUM]; 30 | 31 | unsigned char timing_start_cb(unsigned char index){ 32 | ESP_LOGI(TAG,"TIMING[%d] CB!",index); 33 | cmp_rtc_date_s date2; 34 | cmp_rtc.get_date(&date2); 35 | 36 | ESP_LOGI(TAG,"%04d/%02d/%02d %02d:%02d:%02d [WEEK:%d]", 37 | date2.year, 38 | date2.month, 39 | date2.monthday, 40 | date2.hour, 41 | date2.minute, 42 | date2.second, 43 | date2.weekday); 44 | 45 | //bee_work_mode_set('A'+work[index/2].level); 46 | //bee_work_mode_start(index/2); 47 | work[index/2].is_timing = 1; 48 | app_driver_set_fragrance_onoff((index/2)<3?'A':'B',1); 49 | return 1; 50 | } 51 | 52 | unsigned char timing_end_cb(unsigned char index){ 53 | ESP_LOGI(TAG,"TIMING[%d] CB!",index); 54 | cmp_rtc_date_s date2; 55 | cmp_rtc.get_date(&date2); 56 | 57 | ESP_LOGI(TAG,"%04d/%02d/%02d %02d:%02d:%02d [WEEK:%d]", 58 | date2.year, 59 | date2.month, 60 | date2.monthday, 61 | date2.hour, 62 | date2.minute, 63 | date2.second, 64 | date2.weekday); 65 | //bee_work_mode_set('X'); 66 | //bee_work_mode_stop(index/2); 67 | app_driver_set_fragrance_onoff((index/2)<3?'A':'B',0); 68 | work[index/2].is_timing = 0; 69 | return 1; 70 | } 71 | 72 | static void work_timer_cb(void *timer){ 73 | for(unsigned char i=0;i= 8)return 0; 119 | 120 | mITimingFunc.set(&timing[2*timer_id],1,time_from,is_repet,day,&timing_start_cb); 121 | mITimingFunc.set(&timing[2*timer_id+1],1,time_to,is_repet,day,&timing_end_cb); 122 | work[timer_id].level = level+'0'; 123 | work[timer_id].work = _work; 124 | work[timer_id].not_work = _not_work; 125 | 126 | cmp_rtc_date_s date2; 127 | cmp_rtc.get_date(&date2); 128 | ESP_LOGI(TAG,"->%04d/%02d/%02d %02d:%02d:%02d [WEEK:%d]", 129 | date2.year, 130 | date2.month, 131 | date2.monthday, 132 | date2.hour, 133 | date2.minute, 134 | date2.second, 135 | date2.weekday); 136 | if(((day>> (8-date2.weekday)) & 0x01) == 0x01){ 137 | unsigned short cur_time = date2.hour*60+ date2.minute; 138 | if(time_from File Name: bt_cmd.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Mon 27 Feb 2023 01:51:58 HKT 6 | ************************************************************************/ 7 | #include 8 | #include "string.h" 9 | #include "cmp_rtc.h" 10 | #include "bt_gap.h" 11 | 12 | #include "host/ble_hs.h" 13 | #include "esp_qcloud_storage.h" 14 | 15 | void bt_server_cmd(uint8_t *datas, uint8_t len); 16 | 17 | char WORK_DATA_KEY[12] = "work_data_0"; 18 | static uint8_t _check_sum(uint8_t *datas, uint8_t len){ 19 | uint8_t sum = 0; 20 | for(uint8_t i=0;ivalue,len); 51 | uint8_t cmd = datas[0]; 52 | uint8_t* params = &(datas[1]); 53 | 54 | switch(cmd){ 55 | case 0x01:{//start stop 56 | uint8_t moto_onoff = 1; 57 | 58 | if(params[0] == 0){//stop 59 | moto_onoff = 0; 60 | }else if(params[0] == 1){//start 61 | moto_onoff = 1; 62 | } 63 | 64 | send[0] = 0x01; 65 | send[1] = moto_onoff; 66 | send[13] = _check_sum(send,13); 67 | app_bt_gatt_send(send,14); 68 | } 69 | break; 70 | case 0x02:{//read level 71 | extern int hell1; 72 | extern int hell2; 73 | send[0] = 0x02; 74 | send[1] = hell1; 75 | send[2] = hell2; 76 | send[13] = _check_sum(send,13); 77 | app_bt_gatt_send(send,14); 78 | } 79 | break; 80 | case 0x04:{//fan control 81 | uint8_t fan_level = 0; 82 | if(params[0] < 0x04){ 83 | fan_level = params[0]; 84 | } 85 | send[0] = 0x04; 86 | send[1] = fan_level; 87 | send[13] = _check_sum(send,13); 88 | app_bt_gatt_send(send,14); 89 | } 90 | break; 91 | case 0x05:{//set work 92 | extern unsigned char timing_work_mode_set(unsigned char timer_id,unsigned char is_on,unsigned short time_from,unsigned short time_to,unsigned char is_repet,unsigned char day, unsigned char level,unsigned short _work, unsigned short _not_work); 93 | uint8_t index = params[0]; 94 | uint16_t time_from = params[1]*60+params[2]; 95 | uint16_t time_to = params[3]*60+params[4]; 96 | uint16_t _work = params[6]*256+params[5]; 97 | uint16_t _not_work = params[8]*256+params[7]; 98 | uint8_t week = params[9]; 99 | uint8_t level = params[10]; 100 | uint8_t is_on = 1; 101 | uint8_t is_repet = 1; 102 | timing_work_mode_set(index,is_on,time_from,time_to,is_repet,week,level,_work,_not_work); 103 | 104 | MODLOG_DFLT(INFO,"SET WORK:[%d] %d->%d ^%dv%d W[%x] P[%d]\n", 105 | index, 106 | time_from, 107 | time_to, 108 | _work, 109 | _not_work, 110 | week, 111 | level); 112 | WORK_DATA_KEY[10] = '0'+index; 113 | if(esp_qcloud_storage_set(WORK_DATA_KEY,datas , 14) == ESP_OK){ 114 | MODLOG_DFLT(INFO, "WRITE OK:%s\n",WORK_DATA_KEY); 115 | } 116 | } 117 | break; 118 | case 0x06:{//read work 119 | uint8_t index = params[0]; 120 | WORK_DATA_KEY[10] = '0'+index; 121 | if(esp_qcloud_storage_get(WORK_DATA_KEY, send, 14) != ESP_OK){ 122 | memset(send,0,14); 123 | }else{ 124 | MODLOG_DFLT(INFO, "READ OK:%s\n",WORK_DATA_KEY); 125 | } 126 | send[0] = 0x06; 127 | send[13] = _check_sum(send,13); 128 | MODLOG_DFLT(INFO, "upload:[14]={"); 129 | for(int i=0;i<14;i++){ 130 | printf("%02x ",send[i]); 131 | } 132 | printf("\n"); 133 | 134 | app_bt_gatt_send(send,14); 135 | } 136 | break; 137 | case 0x07:{//set time 138 | cmp_rtc_date_s date1; 139 | date1.year = params[0]*100+params[1]; 140 | date1.month = params[2]; 141 | date1.monthday = params[3]; 142 | date1.weekday = 0; 143 | date1.hour = params[4]; 144 | date1.minute = params[5]; 145 | date1.second = params[6]; 146 | cmp_rtc.set_date(date1); 147 | 148 | MODLOG_DFLT(INFO,"SET TIME:%04d/%02d/%02d %02d:%02d:%02d [XQ:%d]\n", 149 | date1.year, 150 | date1.month, 151 | date1.monthday, 152 | date1.hour, 153 | date1.minute, 154 | date1.second, 155 | date1.weekday); 156 | 157 | } 158 | break; 159 | case 0x08:{//read time 160 | cmp_rtc_date_s date2; 161 | cmp_rtc.get_date(&date2); 162 | 163 | MODLOG_DFLT(INFO,"GET TIME:%04d/%02d/%02d %02d:%02d:%02d [XQ:%d]\n", 164 | date2.year, 165 | date2.month, 166 | date2.monthday, 167 | date2.hour, 168 | date2.minute, 169 | date2.second, 170 | date2.weekday); 171 | 172 | send[0] = 0x08; 173 | send[1] = date2.year/100; 174 | send[2] = date2.year%100; 175 | send[3] = date2.month; 176 | send[4] = date2.monthday; 177 | send[5] = date2.hour; 178 | send[6] = date2.minute; 179 | send[7] = date2.second; 180 | send[13] = _check_sum(send,13); 181 | app_bt_gatt_send(send,14); 182 | } 183 | break; 184 | default:break; 185 | } 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/common_components/cmp_xxj_bt/src/bt_gatt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #include 21 | #include 22 | #include 23 | #include "host/ble_hs.h" 24 | #include "host/ble_uuid.h" 25 | #include "services/gap/ble_svc_gap.h" 26 | #include "services/gatt/ble_svc_gatt.h" 27 | #include "bt_gap.h" 28 | 29 | 30 | 31 | static const char *manuf_name = "Chen Xian Mu Yue XXJ"; 32 | static const char *model_num = "JM1-XXXXXX"; 33 | uint16_t xxj_handle; 34 | 35 | static int 36 | gatt_svr_chr_access_cb(uint16_t conn_handle, uint16_t attr_handle, 37 | struct ble_gatt_access_ctxt *ctxt, void *arg); 38 | 39 | static int 40 | gatt_svr_chr_access_device_info(uint16_t conn_handle, uint16_t attr_handle, 41 | struct ble_gatt_access_ctxt *ctxt, void *arg); 42 | 43 | extern void bt_server_init(void); 44 | extern void bt_server_cmd(uint8_t *datas, uint8_t len); 45 | 46 | static const struct ble_gatt_svc_def gatt_svr_svcs[] = { 47 | { 48 | /* Service: Heart-rate */ 49 | .type = BLE_GATT_SVC_TYPE_PRIMARY, 50 | .uuid = BLE_UUID16_DECLARE(GATT_XXJ_UUID), 51 | .characteristics = (struct ble_gatt_chr_def[]) 52 | { { 53 | /* Characteristic: notify */ 54 | .uuid = BLE_UUID16_DECLARE(GATT_XXJ_NOTIFY_UUID), 55 | .access_cb = gatt_svr_chr_access_cb, 56 | .val_handle = &xxj_handle, 57 | .flags = BLE_GATT_CHR_F_NOTIFY, 58 | }, { 59 | /* Characteristic: write no ack */ 60 | .uuid = BLE_UUID16_DECLARE(GATT_XXJ_WRITE_NO_ACK_UUID), 61 | .access_cb = gatt_svr_chr_access_cb, 62 | .flags = BLE_GATT_CHR_F_WRITE_NO_RSP, 63 | }, { 64 | 0, /* No more characteristics in this service */ 65 | }, 66 | } 67 | }, 68 | 69 | { 70 | /* Service: Device Information */ 71 | .type = BLE_GATT_SVC_TYPE_PRIMARY, 72 | .uuid = BLE_UUID16_DECLARE(GATT_DEVICE_INFO_UUID), 73 | .characteristics = (struct ble_gatt_chr_def[]) 74 | { { 75 | /* Characteristic: * Manufacturer name */ 76 | .uuid = BLE_UUID16_DECLARE(GATT_MANUFACTURER_NAME_UUID), 77 | .access_cb = gatt_svr_chr_access_device_info, 78 | .flags = BLE_GATT_CHR_F_READ, 79 | }, { 80 | /* Characteristic: Model number string */ 81 | .uuid = BLE_UUID16_DECLARE(GATT_MODEL_NUMBER_UUID), 82 | .access_cb = gatt_svr_chr_access_device_info, 83 | .flags = BLE_GATT_CHR_F_READ, 84 | }, { 85 | 0, /* No more characteristics in this service */ 86 | }, 87 | } 88 | }, 89 | 90 | { 91 | 0, /* No more services */ 92 | }, 93 | }; 94 | 95 | int 96 | gatt_svr_chr_access_cb(uint16_t conn_handle, uint16_t attr_handle, 97 | struct ble_gatt_access_ctxt *ctxt, void *arg) 98 | { 99 | /* Sensor location, set to "Chest" */ 100 | static uint8_t body_sens_loc = 0x01; 101 | uint16_t uuid; 102 | int rc; 103 | 104 | uuid = ble_uuid_u16(ctxt->chr->uuid); 105 | 106 | if (uuid == GATT_XXJ_WRITE_NO_ACK_UUID) { 107 | rc = os_mbuf_append(ctxt->om, &body_sens_loc, sizeof(body_sens_loc)); 108 | 109 | uint8_t *rev_data = ctxt->om->om_data; 110 | uint8_t rev_len = ctxt->om->om_len-1; 111 | 112 | bt_server_cmd(rev_data,rev_len); 113 | //ctxt->om.om_len; 114 | return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES; 115 | } 116 | 117 | assert(0); 118 | return BLE_ATT_ERR_UNLIKELY; 119 | } 120 | 121 | static int 122 | gatt_svr_chr_access_device_info(uint16_t conn_handle, uint16_t attr_handle, 123 | struct ble_gatt_access_ctxt *ctxt, void *arg) 124 | { 125 | uint16_t uuid; 126 | int rc; 127 | 128 | uuid = ble_uuid_u16(ctxt->chr->uuid); 129 | 130 | if (uuid == GATT_MODEL_NUMBER_UUID) { 131 | rc = os_mbuf_append(ctxt->om, model_num, strlen(model_num)); 132 | return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES; 133 | } 134 | 135 | if (uuid == GATT_MANUFACTURER_NAME_UUID) { 136 | rc = os_mbuf_append(ctxt->om, manuf_name, strlen(manuf_name)); 137 | return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES; 138 | } 139 | 140 | assert(0); 141 | return BLE_ATT_ERR_UNLIKELY; 142 | } 143 | 144 | void 145 | gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *arg) 146 | { 147 | char buf[BLE_UUID_STR_LEN]; 148 | 149 | switch (ctxt->op) { 150 | case BLE_GATT_REGISTER_OP_SVC: 151 | MODLOG_DFLT(DEBUG, "registered service %s with handle=%d\n", 152 | ble_uuid_to_str(ctxt->svc.svc_def->uuid, buf), 153 | ctxt->svc.handle); 154 | break; 155 | 156 | case BLE_GATT_REGISTER_OP_CHR: 157 | MODLOG_DFLT(DEBUG, "registering characteristic %s with " 158 | "def_handle=%d val_handle=%d\n", 159 | ble_uuid_to_str(ctxt->chr.chr_def->uuid, buf), 160 | ctxt->chr.def_handle, 161 | ctxt->chr.val_handle); 162 | break; 163 | 164 | case BLE_GATT_REGISTER_OP_DSC: 165 | MODLOG_DFLT(DEBUG, "registering descriptor %s with handle=%d\n", 166 | ble_uuid_to_str(ctxt->dsc.dsc_def->uuid, buf), 167 | ctxt->dsc.handle); 168 | break; 169 | 170 | default: 171 | assert(0); 172 | break; 173 | } 174 | } 175 | 176 | 177 | int 178 | bt_gatt_init(void) 179 | { 180 | int rc; 181 | 182 | ble_svc_gap_init(); 183 | ble_svc_gatt_init(); 184 | 185 | rc = ble_gatts_count_cfg(gatt_svr_svcs); 186 | if (rc != 0) { 187 | return rc; 188 | } 189 | 190 | rc = ble_gatts_add_svcs(gatt_svr_svcs); 191 | if (rc != 0) { 192 | return rc; 193 | } 194 | 195 | bt_server_init(); 196 | 197 | return 0; 198 | } 199 | 200 | 201 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/common_components/cmp_rtc/src/cmp_rtc.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: cmp_rtc.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Mon 20 Feb 2023 23:57:15 HKT 6 | ************************************************************************/ 7 | 8 | #include "cmp_rtc.h" 9 | #include 10 | #include "esp_log.h" 11 | #include "freertos/FreeRTOS.h" 12 | #include "freertos/timers.h" 13 | 14 | unsigned char cmp_rtc_init(cmp_rtc_params_s *param); 15 | void cmp_rtc_set_date(cmp_rtc_date_s date); 16 | void cmp_rtc_get_date(cmp_rtc_date_s *date); 17 | void cmp_rtc_date_to_utc(cmp_rtc_date_s date, unsigned int *utc_time); 18 | void cmp_rtc_utc_to_date(unsigned int utc_time, cmp_rtc_date_s *date); 19 | unsigned char cmp_rtc_is_same(cmp_rtc_date_s *time_stamp1, cmp_rtc_date_s *time_stamp2, cmp_rtc_cmp_kind_s kind); 20 | void cmp_rtc_run(void); 21 | 22 | typedef struct{ 23 | unsigned int cur_utc_time; 24 | }_this_s; 25 | 26 | static _this_s _this = { 27 | .cur_utc_time = 0, 28 | }; 29 | static _this_s *p_this = &_this; 30 | 31 | static const char *TAG = "cmp_rtc"; 32 | 33 | /////////////////////////////////////////////////////////// 34 | //对外功能函数实现 35 | /////////////////////////////////////////////////////////// 36 | cmp_rtc_s cmp_rtc = { 37 | .init = &cmp_rtc_init, 38 | .set_date = &cmp_rtc_set_date, 39 | .get_date = &cmp_rtc_get_date, 40 | .date_to_utc = &cmp_rtc_date_to_utc, 41 | .utc_to_date = &cmp_rtc_utc_to_date, 42 | .is_same = &cmp_rtc_is_same, 43 | }; 44 | 45 | /////////////////////////////////////////////////////////// 46 | //UTC和普通时间进行转换的内部函数 47 | /////////////////////////////////////////////////////////// 48 | //1970/1/1 8:0:0 0x0000000 星期4 49 | #define UTC_TIME2000 946656000 50 | typedef struct 51 | { 52 | unsigned char second; // 0-59 53 | unsigned char minute; // 0-59 54 | unsigned char hour; // 0-23 55 | unsigned char day; // 1-31 56 | unsigned char month; // 1-12 57 | unsigned char year; // 0-99 (representing 2000-2099) 58 | }date_time_t; 59 | 60 | static unsigned short days[4][12] = 61 | { 62 | { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}, 63 | { 366, 397, 425, 456, 486, 517, 547, 578, 609, 639, 670, 700}, 64 | { 731, 762, 790, 821, 851, 882, 912, 943, 974,1004,1035,1065}, 65 | {1096,1127,1155,1186,1216,1247,1277,1308,1339,1369,1400,1430}, 66 | }; 67 | 68 | unsigned int date_time_to_epoch(date_time_t* date_time) 69 | { 70 | unsigned int second = date_time->second; // 0-59 71 | unsigned int minute = date_time->minute; // 0-59 72 | unsigned int hour = date_time->hour; // 0-23 73 | unsigned int day = date_time->day-1; // 0-30 74 | unsigned int month = date_time->month-1; // 0-11 75 | unsigned int year = date_time->year; // 0-99 76 | return (((year/4*(365*4+1)+days[year%4][month]+day)*24+hour)*60+minute)*60+second; 77 | } 78 | 79 | void epoch_to_date_time(date_time_t* date_time,unsigned int epoch) 80 | { 81 | date_time->second = epoch%60; epoch /= 60; 82 | date_time->minute = epoch%60; epoch /= 60; 83 | date_time->hour = epoch%24; epoch /= 24; 84 | 85 | unsigned int years = epoch/(365*4+1)*4; epoch %= 365*4+1; 86 | 87 | unsigned int year; 88 | for (year=3; year>0; year--) 89 | { 90 | if (epoch >= days[year][0]) 91 | break; 92 | } 93 | 94 | unsigned int month; 95 | for (month=11; month>0; month--) 96 | { 97 | if (epoch >= days[year][month]) 98 | break; 99 | } 100 | 101 | date_time->year = years+year; 102 | date_time->month = month+1; 103 | date_time->day = epoch-days[year][month]+1; 104 | } 105 | 106 | static void cmp_rtc_timer_cb(void *timer){ 107 | if(p_this->cur_utc_time < UTC_TIME2000)return; 108 | static unsigned char times = 0; 109 | 110 | times++; 111 | if(times > 4){ 112 | times = 0; 113 | p_this->cur_utc_time++; 114 | 115 | //ESP_LOGI(TAG, "%d\n",p_this->cur_utc_time); 116 | } 117 | } 118 | /////////////////////////////////////////////////////////// 119 | //对外函数 120 | /////////////////////////////////////////////////////////// 121 | unsigned char cmp_rtc_init(cmp_rtc_params_s *param){ 122 | TimerHandle_t g_rtc_timer = NULL; 123 | g_rtc_timer = xTimerCreate("cmp_rtc timer", 200, true, NULL, cmp_rtc_timer_cb);//200ms 124 | xTimerStart(g_rtc_timer, 0); 125 | 126 | return 0; 127 | } 128 | 129 | void cmp_rtc_set_date(cmp_rtc_date_s date){ 130 | unsigned int cur_utc_time; 131 | cmp_rtc_date_to_utc(date,&cur_utc_time); 132 | p_this->cur_utc_time = cur_utc_time; 133 | } 134 | 135 | void cmp_rtc_get_date(cmp_rtc_date_s *date){ 136 | cmp_rtc_utc_to_date(p_this->cur_utc_time,date); 137 | date->weekday = ((p_this->cur_utc_time+8*60*60)/(24*60*60) + 4)%7; 138 | if(date->weekday == 0)date->weekday = 7; 139 | } 140 | 141 | void cmp_rtc_date_to_utc(cmp_rtc_date_s date, unsigned int *utc_time){ 142 | if(date.year < 2000){ 143 | *utc_time = 0; 144 | return; 145 | } 146 | date_time_t now_time; 147 | now_time.second = date.second; 148 | now_time.minute = date.minute; 149 | now_time.hour = date.hour; 150 | now_time.day = date.monthday; 151 | now_time.month = date.month; 152 | now_time.year = date.year - 2000;//from 2000/01/01/00/00/00 epoch time 153 | 154 | unsigned int epoch; 155 | epoch = date_time_to_epoch(&now_time); 156 | epoch += UTC_TIME2000; 157 | 158 | *utc_time = epoch; 159 | } 160 | 161 | void cmp_rtc_utc_to_date(unsigned int utc_time, cmp_rtc_date_s *date){ 162 | if(utc_time < UTC_TIME2000){ 163 | memset(date,0,sizeof(cmp_rtc_date_s)); 164 | return; 165 | } 166 | 167 | utc_time -= UTC_TIME2000; 168 | date_time_t now_time; 169 | epoch_to_date_time(&now_time,utc_time); 170 | 171 | date->second = now_time.second; 172 | date->minute = now_time.minute; 173 | date->hour = now_time.hour; 174 | date->monthday = now_time.day; 175 | date->month = now_time.month; 176 | date->year = (unsigned short)now_time.year + 2000; 177 | } 178 | 179 | unsigned char cmp_rtc_is_same(cmp_rtc_date_s *time_stamp1, cmp_rtc_date_s *time_stamp2, cmp_rtc_cmp_kind_s kind){ 180 | switch(kind){ 181 | case CMP_RTC_IS_SAME_SECOND: 182 | if(time_stamp1->second != time_stamp2->second)return 0; 183 | case CMP_RTC_IS_SAME_MINUTE: 184 | if(time_stamp1->minute != time_stamp2->minute)return 0; 185 | case CMP_RTC_IS_SAME_HOUR: 186 | if(time_stamp1->hour != time_stamp2->hour)return 0; 187 | case CMP_RTC_IS_SAME_DAY: 188 | if(time_stamp1->monthday != time_stamp2->monthday)return 0; 189 | case CMP_RTC_IS_SAME_MONTH: 190 | if(time_stamp1->month != time_stamp2->month)return 0; 191 | case CMP_RTC_IS_SAME_YEAR: 192 | if(time_stamp1->year != time_stamp2->year)return 0; 193 | else return 1; 194 | default:break; 195 | } 196 | return 0; 197 | } 198 | 199 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/common_components/ic_ds1302/src/ic_ds1302.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: ic_ds1302.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Tue 01 Aug 2023 15:06:13 CST 6 | ************************************************************************/ 7 | #include "ic_ds1302.h" 8 | #include "ic_ds1302_config.h" 9 | 10 | #define DS1302_STOP 0x80 11 | 12 | #define DS1302_READ_BURST 0xBF 13 | #define DS1302_WRITE_BURST 0xBE 14 | #define DS1302_WRITE_SEC 0x80 15 | #define DS1302_READ_SEC 0x81 16 | #define DS1302_WRITE_MINUTE 0x82 17 | #define DS1302_READ_MINUTE 0x83 18 | #define DS1302_WRITE_HOUR 0x84 19 | #define DS1302_READ_HOUR 0x85 20 | #define DS1302_WRITE_DATE 0x86 21 | #define DS1302_READ_DATE 0x87 22 | #define DS1302_WRITE_MONTH 0x88 23 | #define DS1302_READ_MONTH 0x89 24 | #define DS1302_WRITE_WEEK 0x8A 25 | #define DS1302_READ_WEEK 0x8B 26 | #define DS1302_WRITE_YEAR 0x8C 27 | #define DS1302_READ_YEAR 0x8D 28 | 29 | #define DS1302_WRITE_CHARGE 0x90 30 | #define DS1302_READ_CHARGE 0x91 31 | 32 | static const char *TAG = "ic_ds1302"; 33 | #define PR_DEBUG(...) ESP_LOGI(TAG,##__VA_ARGS__) 34 | 35 | void DS1302_Start() { // START , CE = 1 36 | DS1302_IIC_CE_LOW; 37 | DS1302_IIC_SCL_LOW; 38 | DS1302_IIC_DELAY_200US; 39 | DS1302_IIC_CE_HIGH; 40 | DS1302_IIC_DELAY_200US; 41 | } 42 | 43 | void DS1302_Over(){ // OVER, CE = 0 44 | DS1302_IIC_CE_LOW; 45 | DS1302_IIC_IO_LOW; 46 | DS1302_IIC_SCL_LOW; 47 | } 48 | 49 | unsigned char gc1302_read_byte(unsigned char cmd){ // 读相应的寄存器数据 50 | DS1302_Start(); 51 | unsigned char i = 0; 52 | // write cmd 53 | for(i=0;i<8;i++){ 54 | DS1302_IIC_IO_WRITE(cmd&0x01); 55 | cmd >>= 1; 56 | DS1302_IIC_DELAY_100US; 57 | DS1302_IIC_SCL_HIGH; 58 | if(i == 7) { // 注意,当命令字的第7位在上升沿结束后,需要在下降沿之前马上把该IO设置为输入模式 59 | DS1302_IIC_IO_IN; 60 | DS1302_IIC_DELAY_200US; 61 | }else{ 62 | // 在上升沿和下降沿之间延时200us,即周期为400us,频率为2.5KHz左右 63 | // 该频率可以随意设置,只要不超过最大值即可 64 | DS1302_IIC_DELAY_200US; 65 | } 66 | DS1302_IIC_SCL_LOW; 67 | DS1302_IIC_DELAY_100US; 68 | } 69 | // read data 70 | unsigned char data = 0; 71 | for(i=0;i<8;i++){ 72 | data >>= 1; 73 | if(DS1302_IIC_IO_READ){ 74 | data |= 0x80; 75 | } 76 | DS1302_IIC_DELAY_100US; 77 | DS1302_IIC_SCL_HIGH; 78 | DS1302_IIC_DELAY_200US; 79 | DS1302_IIC_SCL_LOW; 80 | DS1302_IIC_DELAY_100US; 81 | } 82 | DS1302_IIC_IO_OUTPUT; 83 | DS1302_Over(); 84 | return data; 85 | } 86 | 87 | void gc1302_send_byte(unsigned char data_byte){ // 写一个字节的时序 88 | for(unsigned char i=0;i<8;i++){ 89 | DS1302_IIC_IO_WRITE(data_byte&0x01); 90 | data_byte >>= 1; 91 | DS1302_IIC_DELAY_100US; 92 | DS1302_IIC_SCL_HIGH; 93 | DS1302_IIC_DELAY_200US; 94 | DS1302_IIC_SCL_LOW; 95 | DS1302_IIC_DELAY_100US; 96 | //DS1302_IIC_DELAY_200US; 97 | } 98 | } 99 | 100 | void gc1302_write_byte(unsigned char cmd, unsigned char data){ // 写相应的寄存器数据 101 | DS1302_Start(); 102 | gc1302_send_byte(cmd); 103 | gc1302_send_byte(data); 104 | DS1302_Over(); 105 | } 106 | 107 | void DS1302_ClearWriteProtection(){ 108 | DS1302_Start(); 109 | gc1302_send_byte(0x8E); 110 | gc1302_send_byte(0x00); 111 | DS1302_Over(); 112 | } 113 | 114 | void DS1302_SetWriteProtection(){ // 设置写保护 115 | DS1302_Start(); 116 | gc1302_send_byte(0x8E); 117 | gc1302_send_byte(0x80); 118 | DS1302_Over(); 119 | } 120 | 121 | static unsigned char bcd2int(unsigned char bcd){ 122 | return (bcd & 0x0F) + ((bcd>>4)*10); 123 | } 124 | 125 | static unsigned char int2bcd(unsigned char inx){ 126 | return ((inx/10)<<4) | (inx%10); 127 | } 128 | 129 | void gc1302_update( cmp_rtc_date_s *date){ 130 | DS1302_ClearWriteProtection(); // 清除写保护 131 | gc1302_write_byte(DS1302_WRITE_SEC, DS1302_STOP); // 停止计时 132 | 133 | gc1302_write_byte(DS1302_WRITE_YEAR,int2bcd(date->year-2000)); //2000+ DCD 134 | gc1302_write_byte(DS1302_WRITE_MONTH,int2bcd(date->month)); 135 | gc1302_write_byte(DS1302_WRITE_DATE, int2bcd(date->monthday)); // 设置天 136 | //gc1302_write_byte(DS1302_WRITE_WEEK, int2bcd(week)); 137 | gc1302_write_byte(DS1302_WRITE_HOUR, int2bcd(date->hour)); // 设置时 138 | gc1302_write_byte(DS1302_WRITE_MINUTE, int2bcd(date->minute)); // 设置分 139 | gc1302_write_byte(DS1302_WRITE_SEC, int2bcd(date->second)); // 设置秒,并开始计时 140 | 141 | PR_DEBUG("DS1302 WRITE:%d-%d-%d %d:%d:%d\n", 142 | date->year, date->month, date->monthday, date->hour, date->minute, date->second); 143 | } 144 | 145 | 146 | void gc1302_init( cmp_rtc_date_s *date){ 147 | DS1302_IIC_IO_INIT; 148 | 149 | if(22 > bcd2int(gc1302_read_byte(DS1302_READ_YEAR))){ 150 | PR_DEBUG("NO TIME\n"); 151 | gc1302_update(date); 152 | } 153 | 154 | DS1302_ClearWriteProtection(); // 清除写保护 155 | gc1302_write_byte(DS1302_WRITE_CHARGE, 0xA5); // 使能充电(3.3-0.7)/8K 156 | 157 | date->year = bcd2int(gc1302_read_byte(DS1302_READ_YEAR)) + 2000; 158 | date->month = bcd2int(gc1302_read_byte(DS1302_READ_MONTH)); 159 | date->monthday = bcd2int(gc1302_read_byte(DS1302_READ_DATE)); 160 | //read_data[3] = bcd2int(gc1302_read_byte(DS1302_READ_WEEK)); 161 | date->hour = bcd2int(gc1302_read_byte(DS1302_READ_HOUR)); 162 | date->minute = bcd2int(gc1302_read_byte(DS1302_READ_MINUTE)); 163 | date->second = bcd2int(gc1302_read_byte(DS1302_READ_SEC)); 164 | 165 | PR_DEBUG("DS1302 READ:%d-%d-%d %d:%d:%d\n", 166 | date->year, date->month, date->monthday, date->hour, date->minute, date->second); 167 | } 168 | 169 | void gc1302_test(){ 170 | unsigned char read_data[7] = {0}; 171 | 172 | if(22 != bcd2int(gc1302_read_byte(DS1302_READ_YEAR))){ 173 | PR_DEBUG("NO TIME\n"); 174 | unsigned char year = 22; 175 | unsigned char month = 12; 176 | unsigned char day = 17; 177 | unsigned char week = 6; 178 | unsigned char hour = 3; 179 | unsigned char minute = 1; 180 | unsigned char sec = 20; 181 | 182 | DS1302_ClearWriteProtection(); // 清除写保护 183 | gc1302_write_byte(DS1302_WRITE_SEC, DS1302_STOP); // 停止计时 184 | 185 | gc1302_write_byte(DS1302_WRITE_YEAR,int2bcd(year)); //2000+ DCD 186 | gc1302_write_byte(DS1302_WRITE_MONTH,int2bcd(month)); 187 | gc1302_write_byte(DS1302_WRITE_DATE, int2bcd(day)); // 设置天 188 | gc1302_write_byte(DS1302_WRITE_WEEK, int2bcd(week)); 189 | gc1302_write_byte(DS1302_WRITE_HOUR, int2bcd(hour)); // 设置时 190 | gc1302_write_byte(DS1302_WRITE_MINUTE, int2bcd(minute)); // 设置分 191 | gc1302_write_byte(DS1302_WRITE_SEC, int2bcd(sec)); // 设置秒,并开始计时 192 | } 193 | 194 | DS1302_ClearWriteProtection(); // 清除写保护 195 | gc1302_write_byte(DS1302_WRITE_CHARGE, 0xA5); // 使能充电(3.3-0.7)/8K 196 | 197 | read_data[0] = bcd2int(gc1302_read_byte(DS1302_READ_YEAR)); 198 | read_data[1] = bcd2int(gc1302_read_byte(DS1302_READ_MONTH)); 199 | read_data[2] = bcd2int(gc1302_read_byte(DS1302_READ_DATE)); 200 | read_data[3] = bcd2int(gc1302_read_byte(DS1302_READ_WEEK)); 201 | read_data[4] = bcd2int(gc1302_read_byte(DS1302_READ_HOUR)); 202 | read_data[5] = bcd2int(gc1302_read_byte(DS1302_READ_MINUTE)); 203 | read_data[6] = bcd2int(gc1302_read_byte(DS1302_READ_SEC)); 204 | 205 | PR_DEBUG("DS1302:%d %d %d %d %d %d %d\n", 206 | read_data[0],read_data[1],read_data[2],read_data[3],read_data[4],read_data[5],read_data[6]); 207 | } 208 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/common_components/cmp_xxj_bt/src/bt_gap.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | #include "esp_log.h" 21 | #include "nvs_flash.h" 22 | #include "freertos/FreeRTOSConfig.h" 23 | /* BLE */ 24 | #include "esp_nimble_hci.h" 25 | #include "nimble/nimble_port.h" 26 | #include "nimble/nimble_port_freertos.h" 27 | #include "host/ble_hs.h" 28 | #include "host/util/util.h" 29 | #include "console/console.h" 30 | #include "services/gap/ble_svc_gap.h" 31 | #include "bt_gap.h" 32 | 33 | 34 | static const char *tag = "BT GAP"; 35 | 36 | uint16_t conn_handle; 37 | static bool notify_state; 38 | static const char *device_name = "JM1-000001"; 39 | static int blexxj_gap_event(struct ble_gap_event *event, void *arg); 40 | static uint8_t blexxj_addr_type; 41 | 42 | /* 43 | * Enables advertising with parameters: 44 | * o General discoverable mode 45 | * o Undirected connectable mode 46 | */ 47 | static void 48 | blexxj_advertise(void) 49 | { 50 | struct ble_gap_adv_params adv_params; 51 | struct ble_hs_adv_fields fields; 52 | int rc; 53 | 54 | /* 55 | * Set the advertisement data included in our advertisements: 56 | * o Flags (indicates advertisement type and other general info) 57 | * o Advertising tx power 58 | * o Device name 59 | */ 60 | memset(&fields, 0, sizeof(fields)); 61 | 62 | /* 63 | * Advertise two flags: 64 | * o Discoverability in forthcoming advertisement (general) 65 | * o BLE-only (BR/EDR unsupported) 66 | */ 67 | fields.flags = BLE_HS_ADV_F_DISC_GEN | 68 | BLE_HS_ADV_F_BREDR_UNSUP; 69 | 70 | /* 71 | * Indicate that the TX power level field should be included; have the 72 | * stack fill this value automatically. This is done by assigning the 73 | * special value BLE_HS_ADV_TX_PWR_LVL_AUTO. 74 | */ 75 | //fields.tx_pwr_lvl_is_present = 1; 76 | //fields.tx_pwr_lvl = BLE_HS_ADV_TX_PWR_LVL_AUTO; 77 | 78 | fields.uuids16 = (ble_uuid16_t[]) { 79 | BLE_UUID16_INIT(GATT_XXJ_UUID) 80 | }; 81 | fields.num_uuids16 = 1; 82 | fields.uuids16_is_complete = 1; 83 | 84 | fields.svc_data_uuid16 =(uint8_t[]){0xE1,0xFF,0x00,0x00,0x00,0x00,0x00,0x00}; 85 | fields.svc_data_uuid16_len = 8; 86 | 87 | fields.name = (uint8_t *)device_name; 88 | fields.name_len = strlen(device_name); 89 | fields.name_is_complete = 1; 90 | 91 | rc = ble_gap_adv_set_fields(&fields); 92 | if (rc != 0) { 93 | MODLOG_DFLT(ERROR, "error setting advertisement data; rc=%d\n", rc); 94 | return; 95 | } 96 | 97 | /* Begin advertising */ 98 | memset(&adv_params, 0, sizeof(adv_params)); 99 | adv_params.conn_mode = BLE_GAP_CONN_MODE_UND; 100 | adv_params.disc_mode = BLE_GAP_DISC_MODE_GEN; 101 | rc = ble_gap_adv_start(blexxj_addr_type, NULL, BLE_HS_FOREVER, 102 | &adv_params, blexxj_gap_event, NULL); 103 | if (rc != 0) { 104 | MODLOG_DFLT(ERROR, "error enabling advertisement; rc=%d\n", rc); 105 | return; 106 | } 107 | } 108 | 109 | static int 110 | blexxj_gap_event(struct ble_gap_event *event, void *arg) 111 | { 112 | switch (event->type) { 113 | case BLE_GAP_EVENT_CONNECT: 114 | /* A new connection was established or a connection attempt failed */ 115 | MODLOG_DFLT(INFO, "connection %s; status=%d\n", 116 | event->connect.status == 0 ? "established" : "failed", 117 | event->connect.status); 118 | 119 | if (event->connect.status != 0) { 120 | /* Connection failed; resume advertising */ 121 | blexxj_advertise(); 122 | } 123 | conn_handle = event->connect.conn_handle; 124 | break; 125 | 126 | case BLE_GAP_EVENT_DISCONNECT: 127 | MODLOG_DFLT(INFO, "disconnect; reason=%d\n", event->disconnect.reason); 128 | 129 | /* Connection terminated; resume advertising */ 130 | blexxj_advertise(); 131 | break; 132 | 133 | case BLE_GAP_EVENT_ADV_COMPLETE: 134 | MODLOG_DFLT(INFO, "adv complete\n"); 135 | blexxj_advertise(); 136 | break; 137 | 138 | case BLE_GAP_EVENT_SUBSCRIBE: 139 | MODLOG_DFLT(INFO, "subscribe event; cur_notify=%d\n value handle; " 140 | "val_handle=%d\n", 141 | event->subscribe.cur_notify, xxj_handle); 142 | if (event->subscribe.attr_handle == xxj_handle) { 143 | notify_state = event->subscribe.cur_notify; 144 | } else if (event->subscribe.attr_handle != xxj_handle) { 145 | notify_state = event->subscribe.cur_notify; 146 | } 147 | ESP_LOGI("BLE_GAP_SUBSCRIBE_EVENT", "conn_handle from subscribe=%d", conn_handle); 148 | break; 149 | 150 | case BLE_GAP_EVENT_MTU: 151 | MODLOG_DFLT(INFO, "mtu update event; conn_handle=%d mtu=%d\n", 152 | event->mtu.conn_handle, 153 | event->mtu.value); 154 | break; 155 | 156 | } 157 | 158 | return 0; 159 | } 160 | 161 | static void 162 | blexxj_on_sync(void) 163 | { 164 | int rc; 165 | 166 | rc = ble_hs_id_infer_auto(0, &blexxj_addr_type); 167 | assert(rc == 0); 168 | 169 | uint8_t addr_val[6] = {0}; 170 | rc = ble_hs_id_copy_addr(blexxj_addr_type, addr_val, NULL); 171 | 172 | MODLOG_DFLT(INFO, "Device Address: "); 173 | //print_addr(addr_val); 174 | MODLOG_DFLT(INFO, "\n"); 175 | 176 | /* Begin advertising */ 177 | blexxj_advertise(); 178 | } 179 | 180 | static void 181 | blexxj_on_reset(int reason) 182 | { 183 | MODLOG_DFLT(ERROR, "Resetting state; reason=%d\n", reason); 184 | } 185 | 186 | void blexxj_host_task(void *param) 187 | { 188 | ESP_LOGI(tag, "BLE Host Task Started"); 189 | /* This function will return only when nimble_port_stop() is executed */ 190 | nimble_port_run(); 191 | 192 | nimble_port_freertos_deinit(); 193 | } 194 | 195 | void app_bt_gatt_send(uint8_t *datas, uint8_t len) 196 | { 197 | if(!notify_state)return; 198 | int rc; 199 | struct os_mbuf *om; 200 | 201 | om = ble_hs_mbuf_from_flat(datas, len); 202 | rc = ble_gattc_notify_custom(conn_handle, xxj_handle, om); 203 | 204 | assert(rc == 0); 205 | } 206 | 207 | void app_bt_gap_init(void) 208 | { 209 | int rc; 210 | 211 | ESP_ERROR_CHECK(esp_nimble_hci_and_controller_init()); 212 | 213 | nimble_port_init(); 214 | /* Initialize the NimBLE host configuration */ 215 | ble_hs_cfg.sync_cb = blexxj_on_sync; 216 | ble_hs_cfg.reset_cb = blexxj_on_reset; 217 | 218 | rc = bt_gatt_init(); 219 | assert(rc == 0); 220 | 221 | /* Set the default device name */ 222 | rc = ble_svc_gap_device_name_set(device_name); 223 | assert(rc == 0); 224 | 225 | /* Start the task */ 226 | nimble_port_freertos_init(blexxj_host_task); 227 | 228 | } 229 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/jm_xxj/main/wifi_server.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: wifi_server.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Sun 05 Mar 2023 19:29:08 HKT 6 | ************************************************************************/ 7 | #include "cJSON.h" 8 | #include "string.h" 9 | 10 | #include "esp_qcloud_log.h" 11 | #include "esp_qcloud_console.h" 12 | #include "esp_qcloud_storage.h" 13 | #include "esp_qcloud_iothub.h" 14 | #include "esp_qcloud_prov.h" 15 | 16 | #include "app_driver.h" 17 | #include "app_fragrance.h" 18 | 19 | static const char *TAG = "cmp_xxj_wifi_server"; 20 | 21 | 22 | /* Callback to handle commands received from the QCloud cloud */ 23 | static esp_err_t wifi_cmd_get_param(const char *id, esp_qcloud_param_val_t *val){ 24 | #if 0 25 | if (!strcmp(id, "power_switch")) { 26 | val->b = light_driver_get_switch(); 27 | } else if (!strcmp(id, "value")) { 28 | val->i = light_driver_get_value(); 29 | } else if (!strcmp(id, "hue")) { 30 | val->i = light_driver_get_hue(); 31 | } else if (!strcmp(id, "saturation")) { 32 | val->i = light_driver_get_saturation(); 33 | } 34 | #endif 35 | ESP_LOGI(TAG, "Report id: %s, val: %d", id, val->i); 36 | 37 | return ESP_OK; 38 | } 39 | 40 | /* Callback to handle commands received from the QCloud cloud */ 41 | static esp_err_t wifi_cmd_set_param(const char *id, const esp_qcloud_param_val_t *val){ 42 | esp_err_t err = ESP_FAIL; 43 | ESP_LOGI(TAG, "Received id: %s, val: %d", id, val->i); 44 | 45 | if (!strcmp(id, "onoff")) { 46 | err = app_fragrance_set_onoff(val->b); 47 | } else if (!strcmp(id, "work_model")) { 48 | err = app_fragrance_set_work_model(val->obj); 49 | } else if (!strcmp(id,"wind")){ 50 | err = app_fragrance_set_fan_speed(val->i); 51 | } else { 52 | ESP_LOGW(TAG, "This parameter is not supported"); 53 | } 54 | 55 | return err; 56 | } 57 | 58 | /* Event handler for catching QCloud events */ 59 | static void event_handler(void *arg, esp_event_base_t event_base, 60 | int32_t event_id, void *event_data){ 61 | switch (event_id) { 62 | case QCLOUD_EVENT_IOTHUB_INIT_DONE: 63 | esp_qcloud_iothub_report_device_info(); 64 | ESP_LOGI(TAG, "QCloud Initialised"); 65 | break; 66 | 67 | case QCLOUD_EVENT_IOTHUB_BOND_DEVICE: 68 | ESP_LOGI(TAG, "Device binding successful"); 69 | break; 70 | 71 | case QCLOUD_EVENT_IOTHUB_UNBOND_DEVICE: 72 | ESP_LOGW(TAG, "Device unbound with iothub"); 73 | esp_qcloud_wifi_reset(); 74 | esp_restart(); 75 | break; 76 | 77 | case QCLOUD_EVENT_IOTHUB_BIND_EXCEPTION: 78 | ESP_LOGW(TAG, "Device bind fail"); 79 | esp_qcloud_wifi_reset(); 80 | esp_restart(); 81 | break; 82 | 83 | case QCLOUD_EVENT_IOTHUB_RECEIVE_STATUS: 84 | ESP_LOGI(TAG, "receive status message: %s",(char*)event_data); 85 | break; 86 | 87 | default: 88 | ESP_LOGW(TAG, "Unhandled QCloud Event: %d", event_id); 89 | } 90 | } 91 | 92 | static esp_err_t get_wifi_config(wifi_config_t *wifi_cfg, uint32_t wait_ms){ 93 | ESP_QCLOUD_PARAM_CHECK(wifi_cfg); 94 | 95 | if (esp_qcloud_storage_get("wifi_config", wifi_cfg, sizeof(wifi_config_t)) == ESP_OK) { 96 | 97 | #ifdef CONFIG_BT_ENABLE 98 | esp_bt_controller_mem_release(ESP_BT_MODE_BTDM); 99 | #endif 100 | 101 | return ESP_OK; 102 | } 103 | 104 | /**< Reset wifi and restart wifi */ 105 | esp_wifi_restore(); 106 | esp_wifi_start(); 107 | 108 | /**< The yellow light flashes to indicate that the device enters the state of configuring the network */ 109 | app_driver_set_wifi_state(2); /**< 0- NOT CONNECT; 1-CONNECT; 2-PAIRING*/ 110 | 111 | /**< Note: Smartconfig and softapconfig working at the same time will affect the configure network performance */ 112 | 113 | #ifdef CONFIG_LIGHT_PROVISIONING_SOFTAPCONFIG 114 | char softap_ssid[32 + 1] = CONFIG_LIGHT_PROVISIONING_SOFTAPCONFIG_SSID; 115 | // uint8_t mac[6] = {0}; 116 | // ESP_ERROR_CHECK(esp_wifi_get_mac(WIFI_IF_STA, mac)); 117 | // sprintf(softap_ssid, "tcloud_%s_%02x%02x", light_driver_get_type(), mac[4], mac[5]); 118 | 119 | esp_qcloud_prov_softapconfig_start(SOFTAPCONFIG_TYPE_ESPRESSIF_TENCENT, 120 | softap_ssid, 121 | CONFIG_LIGHT_PROVISIONING_SOFTAPCONFIG_PASSWORD); 122 | esp_qcloud_prov_print_wechat_qr(softap_ssid, "softap"); 123 | #endif 124 | 125 | #ifdef CONFIG_LIGHT_PROVISIONING_SMARTCONFIG 126 | esp_qcloud_prov_smartconfig_start(SC_TYPE_ESPTOUCH_AIRKISS); 127 | #endif 128 | 129 | #ifdef CONFIG_LIGHT_PROVISIONING_BLECONFIG 130 | char local_name[32 + 1] = CONFIG_LIGHT_PROVISIONING_BLECONFIG_NAME; 131 | esp_qcloud_prov_bleconfig_start(BLECONFIG_TYPE_ESPRESSIF_TENCENT, local_name); 132 | #endif 133 | 134 | ESP_ERROR_CHECK(esp_qcloud_prov_wait(wifi_cfg, wait_ms)); 135 | 136 | #ifdef CONFIG_LIGHT_PROVISIONING_SMARTCONFIG 137 | esp_qcloud_prov_smartconfig_stop(); 138 | #endif 139 | 140 | #ifdef CONFIG_LIGHT_PROVISIONING_SOFTAPCONFIG 141 | esp_qcloud_prov_softapconfig_stop(); 142 | #endif 143 | 144 | /**< Store the configure of the device */ 145 | esp_qcloud_storage_set("wifi_config", wifi_cfg, sizeof(wifi_config_t)); 146 | 147 | /**< Configure the network successfully to stop the light flashing */ 148 | app_driver_set_wifi_state(1); /**< stop blink */ 149 | 150 | return ESP_OK; 151 | } 152 | 153 | 154 | void app_wifi_server_init(void){ 155 | /* 156 | * @breif Create a device through the server and obtain configuration parameters 157 | * server: https://console.cloud.tencent.com/iotexplorer 158 | */ 159 | /**< Create and configure device authentication information */ 160 | ESP_ERROR_CHECK(esp_qcloud_create_device()); 161 | /**< Configure the version of the device, and use this information to determine whether to OTA */ 162 | ESP_ERROR_CHECK(esp_qcloud_device_add_fw_version("0.0.5")); 163 | /**< Register the properties of the device */ 164 | ESP_ERROR_CHECK(esp_qcloud_device_add_property("onoff", QCLOUD_VAL_TYPE_BOOLEAN)); 165 | ESP_ERROR_CHECK(esp_qcloud_device_add_property("work_model", QCLOUD_VAL_TYPE_STRUCT)); 166 | ESP_ERROR_CHECK(esp_qcloud_device_add_property("a_left", QCLOUD_VAL_TYPE_INTEGER)); 167 | ESP_ERROR_CHECK(esp_qcloud_device_add_property("b_left", QCLOUD_VAL_TYPE_INTEGER)); 168 | ESP_ERROR_CHECK(esp_qcloud_device_add_property("wind", QCLOUD_VAL_TYPE_INTEGER)); 169 | /**< The processing function of the communication between the device and the server */ 170 | ESP_ERROR_CHECK(esp_qcloud_device_add_property_cb(wifi_cmd_get_param, wifi_cmd_set_param)); 171 | 172 | /** 173 | * @brief Initialize Wi-Fi. 174 | */ 175 | ESP_ERROR_CHECK(esp_qcloud_wifi_init()); 176 | ESP_ERROR_CHECK(esp_event_handler_register(QCLOUD_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL)); 177 | 178 | /** 179 | * @brief Get the router configuration 180 | */ 181 | wifi_config_t wifi_cfg = {0}; 182 | ESP_ERROR_CHECK(get_wifi_config(&wifi_cfg, portMAX_DELAY)); 183 | 184 | /** 185 | * @brief Connect to router 186 | */ 187 | ESP_ERROR_CHECK(esp_qcloud_wifi_start(&wifi_cfg)); 188 | ESP_ERROR_CHECK(esp_qcloud_timesync_start()); 189 | 190 | /** 191 | * @brief Connect to Tencent Cloud Iothub 192 | */ 193 | ESP_ERROR_CHECK(esp_qcloud_iothub_init()); 194 | ESP_ERROR_CHECK(esp_qcloud_iothub_start()); 195 | ESP_ERROR_CHECK(esp_qcloud_iothub_ota_enable()); 196 | } 197 | -------------------------------------------------------------------------------- /app/bt_discovery/main/bt_discovery.c: -------------------------------------------------------------------------------- 1 | /* 2 | This example code is in the Public Domain (or CC0 licensed, at your option.) 3 | 4 | Unless required by applicable law or agreed to in writing, this 5 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 6 | CONDITIONS OF ANY KIND, either express or implied. 7 | */ 8 | 9 | 10 | 11 | /**************************************************************************** 12 | * 13 | * This file is for Classic Bluetooth device and service discovery Demo. 14 | * 15 | ****************************************************************************/ 16 | 17 | #include 18 | #include 19 | #include "freertos/FreeRTOS.h" 20 | #include "freertos/task.h" 21 | #include "nvs.h" 22 | #include "nvs_flash.h" 23 | #include "esp_system.h" 24 | #include "esp_log.h" 25 | #include "esp_bt.h" 26 | #include "esp_bt_main.h" 27 | #include "esp_bt_device.h" 28 | #include "esp_gap_bt_api.h" 29 | 30 | #define GAP_TAG "GAP" 31 | 32 | typedef enum { 33 | APP_GAP_STATE_IDLE = 0, 34 | APP_GAP_STATE_DEVICE_DISCOVERING, 35 | APP_GAP_STATE_DEVICE_DISCOVER_COMPLETE, 36 | } app_gap_state_t; 37 | 38 | typedef struct { 39 | bool dev_found; 40 | uint8_t bdname_len; 41 | uint8_t eir_len; 42 | uint8_t rssi; 43 | uint32_t cod; 44 | uint8_t eir[ESP_BT_GAP_EIR_DATA_LEN]; 45 | uint8_t bdname[ESP_BT_GAP_MAX_BDNAME_LEN + 1]; 46 | esp_bd_addr_t bda; 47 | app_gap_state_t state; 48 | } app_gap_cb_t; 49 | 50 | static app_gap_cb_t m_dev_info; 51 | 52 | static char *bda2str(esp_bd_addr_t bda, char *str, size_t size) 53 | { 54 | if (bda == NULL || str == NULL || size < 18) { 55 | return NULL; 56 | } 57 | 58 | uint8_t *p = bda; 59 | sprintf(str, "%02x:%02x:%02x:%02x:%02x:%02x", 60 | p[0], p[1], p[2], p[3], p[4], p[5]); 61 | return str; 62 | } 63 | 64 | static void update_device_info(esp_bt_gap_cb_param_t *param) 65 | { 66 | char bda_str[18]; 67 | uint32_t cod = 0; 68 | int32_t rssi = -129; /* invalid value */ 69 | esp_bt_gap_dev_prop_t *p; 70 | 71 | ESP_LOGI(GAP_TAG, "Device found: %s", bda2str(param->disc_res.bda, bda_str, 18)); 72 | for (int i = 0; i < param->disc_res.num_prop; i++) { 73 | p = param->disc_res.prop + i; 74 | switch (p->type) { 75 | case ESP_BT_GAP_DEV_PROP_COD: 76 | cod = *(uint32_t *)(p->val); 77 | ESP_LOGI(GAP_TAG, "--Class of Device: 0x%x", cod); 78 | break; 79 | case ESP_BT_GAP_DEV_PROP_RSSI: 80 | rssi = *(int8_t *)(p->val); 81 | ESP_LOGI(GAP_TAG, "--RSSI: %d", rssi); 82 | break; 83 | case ESP_BT_GAP_DEV_PROP_BDNAME: 84 | default: 85 | break; 86 | } 87 | } 88 | 89 | /* search for device with MAJOR service class as "rendering" in COD */ 90 | app_gap_cb_t *p_dev = &m_dev_info; 91 | if (p_dev->dev_found && 0 != memcmp(param->disc_res.bda, p_dev->bda, ESP_BD_ADDR_LEN)) { 92 | return; 93 | } 94 | 95 | if (!esp_bt_gap_is_valid_cod(cod) || 96 | !(esp_bt_gap_get_cod_major_dev(cod) == ESP_BT_COD_MAJOR_DEV_PHONE)) { 97 | return; 98 | } 99 | 100 | memcpy(p_dev->bda, param->disc_res.bda, ESP_BD_ADDR_LEN); 101 | p_dev->dev_found = true; 102 | for (int i = 0; i < param->disc_res.num_prop; i++) { 103 | p = param->disc_res.prop + i; 104 | switch (p->type) { 105 | case ESP_BT_GAP_DEV_PROP_COD: 106 | p_dev->cod = *(uint32_t *)(p->val); 107 | break; 108 | case ESP_BT_GAP_DEV_PROP_RSSI: 109 | p_dev->rssi = *(int8_t *)(p->val); 110 | break; 111 | case ESP_BT_GAP_DEV_PROP_BDNAME: { 112 | uint8_t len = (p->len > ESP_BT_GAP_MAX_BDNAME_LEN) ? ESP_BT_GAP_MAX_BDNAME_LEN : 113 | (uint8_t)p->len; 114 | memcpy(p_dev->bdname, (uint8_t *)(p->val), len); 115 | p_dev->bdname[len] = '\0'; 116 | p_dev->bdname_len = len; 117 | break; 118 | } 119 | case ESP_BT_GAP_DEV_PROP_EIR: { 120 | memcpy(p_dev->eir, (uint8_t *)(p->val), p->len); 121 | p_dev->eir_len = p->len; 122 | break; 123 | } 124 | default: 125 | break; 126 | } 127 | } 128 | } 129 | 130 | void bt_app_gap_init(void) 131 | { 132 | app_gap_cb_t *p_dev = &m_dev_info; 133 | memset(p_dev, 0, sizeof(app_gap_cb_t)); 134 | } 135 | 136 | void bt_app_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param) 137 | { 138 | app_gap_cb_t *p_dev = &m_dev_info; 139 | switch (event) { 140 | case ESP_BT_GAP_DISC_RES_EVT: { 141 | update_device_info(param); 142 | break; 143 | } 144 | case ESP_BT_GAP_DISC_STATE_CHANGED_EVT: { 145 | ESP_LOGE(GAP_TAG, "%d", p_dev->state); 146 | if(p_dev->state == APP_GAP_STATE_IDLE){ 147 | ESP_LOGE(GAP_TAG, "discovery start ..."); 148 | p_dev->state = APP_GAP_STATE_DEVICE_DISCOVERING; 149 | }else if(p_dev->state == APP_GAP_STATE_DEVICE_DISCOVERING){ 150 | ESP_LOGE(GAP_TAG, "discovery timeout ..."); 151 | p_dev->state = APP_GAP_STATE_DEVICE_DISCOVER_COMPLETE; 152 | esp_bt_gap_start_discovery(ESP_BT_INQ_MODE_GENERAL_INQUIRY, 10, 0); 153 | }else{ 154 | ESP_LOGE(GAP_TAG, "discovery again ..."); 155 | p_dev->state = APP_GAP_STATE_IDLE; 156 | } 157 | break; 158 | } 159 | case ESP_BT_GAP_RMT_SRVCS_EVT: { 160 | break; 161 | } 162 | case ESP_BT_GAP_RMT_SRVC_REC_EVT: 163 | default: { 164 | break; 165 | } 166 | } 167 | return; 168 | } 169 | 170 | void bt_app_gap_start_up(void) 171 | { 172 | char *dev_name = "ESP_GAP_INQRUIY"; 173 | esp_bt_dev_set_device_name(dev_name); 174 | 175 | /* set discoverable and connectable mode, wait to be connected */ 176 | esp_bt_gap_set_scan_mode(ESP_BT_NON_CONNECTABLE,ESP_BT_GENERAL_DISCOVERABLE); 177 | 178 | /* register GAP callback function */ 179 | esp_bt_gap_register_callback(bt_app_gap_cb); 180 | 181 | /* inititialize device information and status */ 182 | app_gap_cb_t *p_dev = &m_dev_info; 183 | memset(p_dev, 0, sizeof(app_gap_cb_t)); 184 | 185 | /* start to discover nearby Bluetooth devices */ 186 | p_dev->state = APP_GAP_STATE_IDLE; 187 | esp_bt_gap_start_discovery(ESP_BT_INQ_MODE_GENERAL_INQUIRY, 10, 0); 188 | } 189 | 190 | void app_main() 191 | { 192 | /* Initialize NVS — it is used to store PHY calibration data */ 193 | esp_err_t ret = nvs_flash_init(); 194 | if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { 195 | ESP_ERROR_CHECK(nvs_flash_erase()); 196 | ret = nvs_flash_init(); 197 | } 198 | ESP_ERROR_CHECK( ret ); 199 | 200 | ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_BLE)); 201 | 202 | esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); 203 | if ((ret = esp_bt_controller_init(&bt_cfg)) != ESP_OK) { 204 | ESP_LOGE(GAP_TAG, "%s initialize controller failed: %s\n", __func__, esp_err_to_name(ret)); 205 | return; 206 | } 207 | 208 | if ((ret = esp_bt_controller_enable(ESP_BT_MODE_CLASSIC_BT)) != ESP_OK) { 209 | ESP_LOGE(GAP_TAG, "%s enable controller failed: %s\n", __func__, esp_err_to_name(ret)); 210 | return; 211 | } 212 | 213 | if ((ret = esp_bluedroid_init()) != ESP_OK) { 214 | ESP_LOGE(GAP_TAG, "%s initialize bluedroid failed: %s\n", __func__, esp_err_to_name(ret)); 215 | return; 216 | } 217 | 218 | if ((ret = esp_bluedroid_enable()) != ESP_OK) { 219 | ESP_LOGE(GAP_TAG, "%s enable bluedroid failed: %s\n", __func__, esp_err_to_name(ret)); 220 | return; 221 | } 222 | 223 | bt_app_gap_start_up(); 224 | } 225 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/src/mqtt/esp_qcloud_mqtt.c: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | #include 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | 27 | static const char *TAG = "esp_qcloud_mqtt"; 28 | 29 | #define MAX_MQTT_SUBSCRIPTIONS 6 30 | 31 | typedef struct { 32 | char *topic; 33 | esp_qcloud_mqtt_subscribe_cb_t cb; 34 | void *priv; 35 | } esp_qcloud_mqtt_subscription_t; 36 | 37 | typedef struct { 38 | esp_mqtt_client_handle_t mqtt_client; 39 | esp_qcloud_mqtt_config_t *config; 40 | esp_qcloud_mqtt_subscription_t *subscriptions[MAX_MQTT_SUBSCRIPTIONS]; 41 | } esp_qcloud_mqtt_data_t; 42 | esp_qcloud_mqtt_data_t *mqtt_data; 43 | 44 | const int MQTT_CONNECTED_EVENT = BIT1; 45 | static EventGroupHandle_t mqtt_event_group; 46 | 47 | static void esp_qcloud_mqtt_subscribe_callback(const char *topic, int topic_len, const char *data, int data_len) 48 | { 49 | esp_qcloud_mqtt_subscription_t **subscriptions = mqtt_data->subscriptions; 50 | int i; 51 | 52 | for (i = 0; i < MAX_MQTT_SUBSCRIPTIONS; i++) { 53 | if (subscriptions[i]) { 54 | if (strncmp(topic, subscriptions[i]->topic, topic_len) == 0) { 55 | subscriptions[i]->cb(subscriptions[i]->topic, (void *)data, data_len, subscriptions[i]->priv); 56 | } 57 | } 58 | } 59 | } 60 | 61 | esp_err_t esp_qcloud_mqtt_subscribe(const char *topic, esp_qcloud_mqtt_subscribe_cb_t cb, void *priv_data) 62 | { 63 | if (!mqtt_data || !topic || !cb) { 64 | return ESP_FAIL; 65 | } 66 | 67 | int i; 68 | 69 | for (i = 0; i < MAX_MQTT_SUBSCRIPTIONS; i++) { 70 | if (!mqtt_data->subscriptions[i]) { 71 | esp_qcloud_mqtt_subscription_t *subscription = calloc(1, sizeof(esp_qcloud_mqtt_subscription_t)); 72 | 73 | if (!subscription) { 74 | return ESP_FAIL; 75 | } 76 | 77 | subscription->topic = strdup(topic); 78 | 79 | if (!subscription->topic) { 80 | free(subscription); 81 | return ESP_FAIL; 82 | } 83 | 84 | int ret = esp_mqtt_client_subscribe(mqtt_data->mqtt_client, subscription->topic, 1); 85 | 86 | if (ret < 0) { 87 | free(subscription->topic); 88 | free(subscription); 89 | return ESP_FAIL; 90 | } 91 | 92 | subscription->priv = priv_data; 93 | subscription->cb = cb; 94 | mqtt_data->subscriptions[i] = subscription; 95 | ESP_LOGD(TAG, "Subscribed to topic: %s", topic); 96 | return ESP_OK; 97 | } 98 | } 99 | 100 | return ESP_FAIL; 101 | } 102 | 103 | esp_err_t esp_qcloud_mqtt_unsubscribe(const char *topic) 104 | { 105 | if (!mqtt_data || !topic) { 106 | return ESP_FAIL; 107 | } 108 | 109 | int ret = esp_mqtt_client_unsubscribe(mqtt_data->mqtt_client, topic); 110 | 111 | if (ret < 0) { 112 | ESP_LOGW(TAG, "Could not unsubscribe from topic: %s", topic); 113 | } 114 | 115 | esp_qcloud_mqtt_subscription_t **subscriptions = mqtt_data->subscriptions; 116 | int i; 117 | 118 | for (i = 0; i < MAX_MQTT_SUBSCRIPTIONS; i++) { 119 | if (subscriptions[i]) { 120 | if (strncmp(topic, subscriptions[i]->topic, strlen(topic)) == 0) { 121 | free(subscriptions[i]->topic); 122 | free(subscriptions[i]); 123 | subscriptions[i] = NULL; 124 | return ESP_OK; 125 | } 126 | } 127 | } 128 | 129 | return ESP_FAIL; 130 | } 131 | 132 | esp_err_t esp_qcloud_mqtt_publish(const char *topic, void *data, size_t data_len) 133 | { 134 | if (!mqtt_data || !topic || !data) { 135 | return ESP_FAIL; 136 | } 137 | 138 | ESP_LOGD(TAG, "Publishing to %s", topic); 139 | int ret = esp_mqtt_client_publish(mqtt_data->mqtt_client, topic, data, data_len, 1, 0); 140 | 141 | if (ret < 0) { 142 | ESP_LOGE(TAG, "MQTT Publish failed"); 143 | return ESP_FAIL; 144 | } 145 | 146 | return ESP_OK; 147 | } 148 | 149 | 150 | static esp_err_t mqtt_event_handler(esp_mqtt_event_handle_t event) 151 | { 152 | switch (event->event_id) { 153 | case MQTT_EVENT_CONNECTED: 154 | ESP_LOGI(TAG, "MQTT Connected"); 155 | 156 | /* Resubscribe to all topics after reconnection */ 157 | for (int i = 0; i < MAX_MQTT_SUBSCRIPTIONS; i++) { 158 | if (mqtt_data->subscriptions[i]) { 159 | esp_mqtt_client_subscribe(event->client, mqtt_data->subscriptions[i]->topic, 1); 160 | } 161 | } 162 | 163 | xEventGroupSetBits(mqtt_event_group, MQTT_CONNECTED_EVENT); 164 | extern void app_driver_set_wifi_state(char state); 165 | app_driver_set_wifi_state(1); 166 | break; 167 | 168 | case MQTT_EVENT_DISCONNECTED: 169 | ESP_LOGW(TAG, "MQTT Disconnected. Will try reconnecting in a while..."); 170 | extern void app_driver_set_wifi_state(char state); 171 | app_driver_set_wifi_state(0); 172 | break; 173 | 174 | case MQTT_EVENT_SUBSCRIBED: 175 | ESP_LOGD(TAG, "MQTT_EVENT_SUBSCRIBED, msg_id=%d", event->msg_id); 176 | break; 177 | 178 | case MQTT_EVENT_UNSUBSCRIBED: 179 | ESP_LOGD(TAG, "MQTT_EVENT_UNSUBSCRIBED, msg_id=%d", event->msg_id); 180 | break; 181 | 182 | case MQTT_EVENT_PUBLISHED: 183 | ESP_LOGD(TAG, "MQTT_EVENT_PUBLISHED, msg_id=%d", event->msg_id); 184 | break; 185 | 186 | case MQTT_EVENT_DATA: 187 | ESP_LOGD(TAG, "MQTT_EVENT_DATA"); 188 | ESP_LOGD(TAG, "TOPIC=%.*s\r\n", event->topic_len, event->topic); 189 | ESP_LOGD(TAG, "DATA=%.*s\r\n", event->data_len, event->data); 190 | esp_qcloud_mqtt_subscribe_callback(event->topic, event->topic_len, event->data, event->data_len); 191 | break; 192 | 193 | case MQTT_EVENT_ERROR: 194 | ESP_LOGE(TAG, "MQTT_EVENT_ERROR"); 195 | break; 196 | 197 | default: 198 | ESP_LOGD(TAG, "Other event id:%d", event->event_id); 199 | break; 200 | } 201 | 202 | return ESP_OK; 203 | } 204 | esp_err_t esp_qcloud_mqtt_connect(void) 205 | { 206 | if (!mqtt_data) { 207 | return ESP_FAIL; 208 | } 209 | 210 | ESP_LOGI(TAG, "Connecting to %s", mqtt_data->config->host); 211 | mqtt_event_group = xEventGroupCreate(); 212 | esp_err_t ret = esp_mqtt_client_start(mqtt_data->mqtt_client); 213 | 214 | if (ret != ESP_OK) { 215 | ESP_LOGE(TAG, "esp_mqtt_client_start() failed with err = %d", ret); 216 | return ret; 217 | } 218 | 219 | ESP_LOGI(TAG, "Waiting for MQTT connection. This may take time."); 220 | xEventGroupWaitBits(mqtt_event_group, MQTT_CONNECTED_EVENT, false, true, portMAX_DELAY); 221 | return ESP_OK; 222 | } 223 | 224 | static void esp_qcloud_mqtt_unsubscribe_all() 225 | { 226 | if (!mqtt_data) { 227 | return; 228 | } 229 | 230 | int i; 231 | 232 | for (i = 0; i < MAX_MQTT_SUBSCRIPTIONS; i++) { 233 | if (mqtt_data->subscriptions[i]) { 234 | esp_qcloud_mqtt_unsubscribe(mqtt_data->subscriptions[i]->topic); 235 | } 236 | } 237 | } 238 | 239 | esp_err_t esp_qcloud_mqtt_disconnect(void) 240 | { 241 | if (!mqtt_data) { 242 | return ESP_FAIL; 243 | } 244 | 245 | esp_qcloud_mqtt_unsubscribe_all(); 246 | esp_err_t err = esp_mqtt_client_stop(mqtt_data->mqtt_client); 247 | 248 | if (err != ESP_OK) { 249 | ESP_LOGE(TAG, "Failed to disconnect from MQTT"); 250 | } else { 251 | ESP_LOGI(TAG, "MQTT Disconnected."); 252 | } 253 | 254 | return err; 255 | } 256 | 257 | esp_err_t esp_qcloud_mqtt_init(esp_qcloud_mqtt_config_t *config) 258 | { 259 | if (mqtt_data) { 260 | ESP_LOGE(TAG, "MQTT already initialised"); 261 | return ESP_OK; 262 | } 263 | 264 | ESP_LOGI(TAG, "Initialising MQTT"); 265 | mqtt_data = calloc(1, sizeof(esp_qcloud_mqtt_data_t)); 266 | 267 | if (!mqtt_data) { 268 | return ESP_FAIL; 269 | } 270 | 271 | mqtt_data->config = malloc(sizeof(esp_qcloud_mqtt_config_t)); 272 | *mqtt_data->config = *config; 273 | const esp_mqtt_client_config_t mqtt_client_cfg = { 274 | .username = config->username, 275 | .password = config->password, 276 | .client_id = config->client_id, 277 | .uri = config->host, 278 | .cert_pem = config->server_cert, 279 | .client_cert_pem = config->client_cert, 280 | .client_key_pem = config->client_key, 281 | .keepalive = 15, 282 | .event_handle = mqtt_event_handler, 283 | }; 284 | mqtt_data->mqtt_client = esp_mqtt_client_init(&mqtt_client_cfg); 285 | return ESP_OK; 286 | } 287 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/examples/jm_xxj/main/app_driver.c: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: app_driver.c 3 | > Author: 4 | > Mail: 5 | > Created Time: Sun 04 Dec 2022 16:09:33 HKT 6 | ************************************************************************/ 7 | #include 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | #include "freertos/FreeRTOS.h" 14 | #include "freertos/queue.h" 15 | #include "freertos/task.h" 16 | #include "freertos/timers.h" 17 | 18 | #include "esp_qcloud_utils.h" 19 | #include "esp_qcloud_storage.h" 20 | 21 | #include "driver/ledc.h" 22 | #include "driver/gpio.h" 23 | 24 | #include "ic_tm1650.h" 25 | 26 | static const char *TAG = "app_driver"; 27 | 28 | 29 | 30 | #define GPIO_OUTPUT_LED_BLUE 18 31 | #define GPIO_OUTPUT_LED_RED 19 32 | #define GPIO_OUTPUT_LED_GREEN 21 33 | #define GPIO_OUTPUT_MOTO_CTL 4 34 | #define GPIO_OUTPUT_FAN_CTL 5 35 | #define GPIO_OUTPUT_VALVE1_CTL 16 36 | #define GPIO_OUTPUT_VALVE2_CTL 17 37 | #define GPIO_OUTPUT_PIN_SEL ((1ULL< HELL1 149 | static uint8_t level[8] = {0x06,0x05,0x04,0x03,0x02,0x01,0x00,0x00}; 150 | _hell1 = level[_hell1]; 151 | _hell2 = level[_hell2]; 152 | 153 | // if have changed report by blue 154 | extern void bt_server_cmd(uint8_t *datas, uint8_t len); 155 | if(_hell1 != hell1 || _hell2 != hell2){ 156 | hell1 = _hell1; 157 | hell2 = _hell2; 158 | 159 | uint8_t send[14]; 160 | memset(send,0,14); 161 | send[0] = 0x02; 162 | bt_server_cmd(send,14); 163 | } 164 | //ESP_LOGW(TAG,"hell sensor: %x %x", hell1, hell2); 165 | TM1650_print(0,TUBE_TABLE_0[hell1]); 166 | TM1650_print(1,TUBE_TABLE_0[hell2]); 167 | TM1650_print(2,TUBE_TABLE_0[btn]); 168 | /* 169 | static int num = 0; 170 | static unsigned char dig = 0; 171 | TM1650_print(dig,TUBE_TABLE_0[num]); 172 | ESP_LOGW(TAG,"->%d %d",dig,num); 173 | num++; 174 | if(num > 15){ 175 | num = 0; 176 | dig++; 177 | if(dig > 3) 178 | dig = 0; 179 | } 180 | */ 181 | } 182 | 183 | static void app_driver_task(void* arg){ 184 | while(true) { 185 | app_driver_wifi_state_run(); 186 | app_driver_fragrance_run(); 187 | app_driver_hell_run(); 188 | vTaskDelay(500 / portTICK_RATE_MS); 189 | } 190 | } 191 | 192 | void app_driver_set_wifi_state(char state){ 193 | wifi_state = state; 194 | ESP_LOGW(TAG,"set wifi state: %d", state); 195 | } 196 | 197 | void app_driver_set_fragrance_onoff(char device, bool on){ 198 | ESP_LOGW(TAG,"DEVICE[%c]:%d",device,on); 199 | 200 | if(device == 'A'){ 201 | fragrance_state[0] = on; 202 | }else if(device == 'B'){ 203 | fragrance_state[1] = on; 204 | } 205 | } 206 | 207 | void app_driver_set_fan_speed(int speed){ 208 | //ledc_set_freq(LEDC_HIGH_SPEED_MODE,LEDC_TIMER_0,(speed%10+1)); 209 | //0~100 210 | //pwm 0~2^13 (//0~100 211 | ledc_channel[0].duty = (speed<<13)/100; 212 | ledc_set_fade_with_time(ledc_channel[0].speed_mode, 213 | ledc_channel[0].channel, ledc_channel[0].duty, 0); 214 | ledc_fade_start(ledc_channel[0].speed_mode, 215 | ledc_channel[0].channel, LEDC_FADE_NO_WAIT); 216 | ESP_LOGW(TAG,"FAN SPEED:%d DUTY:%d",speed,ledc_channel[0].duty); 217 | } 218 | 219 | esp_err_t app_driver_init(void){ 220 | //zero-initialize the config structure. 221 | gpio_config_t io_conf = {}; 222 | //disable interrupt 223 | io_conf.intr_type = GPIO_INTR_DISABLE; 224 | //set as output mode 225 | io_conf.mode = GPIO_MODE_OUTPUT; 226 | //bit mask of the pins that you want to set,e.g.GPIO18/19 227 | io_conf.pin_bit_mask = GPIO_OUTPUT_PIN_SEL; 228 | //disable pull-down mode 229 | io_conf.pull_down_en = 0; 230 | //disable pull-up mode 231 | io_conf.pull_up_en = 0; 232 | //configure GPIO with the given settings 233 | gpio_config(&io_conf); 234 | 235 | //bit mask of the pins, use GPIO4/5 here 236 | io_conf.pin_bit_mask = GPIO_INPUT_PIN_SEL; 237 | //set as input mode 238 | io_conf.mode = GPIO_MODE_INPUT; 239 | //enable pull-up mode 240 | //io_conf.pull_up_en = 1; 241 | gpio_config(&io_conf); 242 | 243 | 244 | gpio_set_level(GPIO_OUTPUT_LED_BLUE, 0); 245 | gpio_set_level(GPIO_OUTPUT_LED_RED, 0); 246 | gpio_set_level(GPIO_OUTPUT_LED_GREEN, 0); 247 | gpio_set_level(GPIO_OUTPUT_MOTO_CTL, 0); 248 | gpio_set_level(GPIO_OUTPUT_VALVE1_CTL, 0); 249 | gpio_set_level(GPIO_OUTPUT_VALVE2_CTL, 0); 250 | 251 | //PWM 252 | // Set configuration of timer0 for high speed channels 253 | ledc_timer_config(&ledc_timer); 254 | // Set LED Controller with previously prepared configuration 255 | ledc_channel_config(&ledc_channel[0]); 256 | // Initialize fade service. 257 | ledc_fade_func_install(0); 258 | 259 | app_driver_set_fan_speed(100); 260 | 261 | 262 | //4-LCD 263 | TM1650_init(); 264 | 265 | xTaskCreate(app_driver_task, "app_driver_task", 2048, NULL, 10, NULL); 266 | 267 | return ESP_OK; 268 | } 269 | 270 | -------------------------------------------------------------------------------- /app/aliyun_demo/my_src/mqtt_example.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2018 Alibaba Group Holding Limited 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "iot_import.h" 11 | #include "iot_export.h" 12 | #include "app_entry.h" 13 | #include "esp_system.h" 14 | #include "esp_log.h" 15 | 16 | // #define PRODUCT_KEY NULL 17 | #define PRODUCT_KEY "a1wAofCFef3" 18 | #define PRODUCT_SECRET "6aU67eL2iHo7xv9x" 19 | #define DEVICE_NAME "test" 20 | #define DEVICE_SECRET "ktktdxJm34qtZ9pLWk6kzeQDKk09xPEv" 21 | 22 | /* These are pre-defined topics */ 23 | #define TOPIC_UPDATE "/"PRODUCT_KEY"/"DEVICE_NAME"/user/update" 24 | #define TOPIC_ERROR "/"PRODUCT_KEY"/"DEVICE_NAME"/user/update/error" 25 | #define TOPIC_GET "/"PRODUCT_KEY"/"DEVICE_NAME"/user/get" 26 | 27 | #define DEVICE_PROPERTY_POST "/sys/"PRODUCT_KEY"/"DEVICE_NAME"/thing/event/property/post" 28 | #define DEVICE_PROPERTY_POST_REPLY "/sys/"PRODUCT_KEY"/"DEVICE_NAME"/thing/event/property/post_reply" 29 | #define DEVICE_PROPERTY_SET "/sys/"PRODUCT_KEY"/"DEVICE_NAME"/thing/service/property/set" 30 | #define DEVICE_INFO_UPDATE "/sys/"PRODUCT_KEY"/"DEVICE_NAME"/thing/deviceinfo/update" 31 | 32 | #define MQTT_MSGLEN (1024) 33 | 34 | #define EXAMPLE_TRACE(fmt, ...) \ 35 | do { \ 36 | HAL_Printf("%s|%03d :: ", __func__, __LINE__); \ 37 | HAL_Printf(fmt, ##__VA_ARGS__); \ 38 | HAL_Printf("%s", "\r\n"); \ 39 | } while(0) 40 | 41 | static int user_argc; 42 | static char **user_argv; 43 | 44 | static const char *TAG = "MQTT"; 45 | 46 | void event_handle(void *pcontext, void *pclient, iotx_mqtt_event_msg_pt msg) 47 | { 48 | uintptr_t packet_id = (uintptr_t)msg->msg; 49 | iotx_mqtt_topic_info_pt topic_info = (iotx_mqtt_topic_info_pt)msg->msg; 50 | 51 | switch (msg->event_type) { 52 | case IOTX_MQTT_EVENT_UNDEF: 53 | EXAMPLE_TRACE("undefined event occur."); 54 | break; 55 | 56 | case IOTX_MQTT_EVENT_DISCONNECT: 57 | EXAMPLE_TRACE("MQTT disconnect."); 58 | break; 59 | 60 | case IOTX_MQTT_EVENT_RECONNECT: 61 | EXAMPLE_TRACE("MQTT reconnect."); 62 | break; 63 | 64 | case IOTX_MQTT_EVENT_SUBCRIBE_SUCCESS: 65 | EXAMPLE_TRACE("subscribe success, packet-id=%u", (unsigned int)packet_id); 66 | break; 67 | 68 | case IOTX_MQTT_EVENT_SUBCRIBE_TIMEOUT: 69 | EXAMPLE_TRACE("subscribe wait ack timeout, packet-id=%u", (unsigned int)packet_id); 70 | break; 71 | 72 | case IOTX_MQTT_EVENT_SUBCRIBE_NACK: 73 | EXAMPLE_TRACE("subscribe nack, packet-id=%u", (unsigned int)packet_id); 74 | break; 75 | 76 | case IOTX_MQTT_EVENT_UNSUBCRIBE_SUCCESS: 77 | EXAMPLE_TRACE("unsubscribe success, packet-id=%u", (unsigned int)packet_id); 78 | break; 79 | 80 | case IOTX_MQTT_EVENT_UNSUBCRIBE_TIMEOUT: 81 | EXAMPLE_TRACE("unsubscribe timeout, packet-id=%u", (unsigned int)packet_id); 82 | break; 83 | 84 | case IOTX_MQTT_EVENT_UNSUBCRIBE_NACK: 85 | EXAMPLE_TRACE("unsubscribe nack, packet-id=%u", (unsigned int)packet_id); 86 | break; 87 | 88 | case IOTX_MQTT_EVENT_PUBLISH_SUCCESS: 89 | EXAMPLE_TRACE("publish success, packet-id=%u", (unsigned int)packet_id); 90 | break; 91 | 92 | case IOTX_MQTT_EVENT_PUBLISH_TIMEOUT: 93 | EXAMPLE_TRACE("publish timeout, packet-id=%u", (unsigned int)packet_id); 94 | break; 95 | 96 | case IOTX_MQTT_EVENT_PUBLISH_NACK: 97 | EXAMPLE_TRACE("publish nack, packet-id=%u", (unsigned int)packet_id); 98 | break; 99 | 100 | case IOTX_MQTT_EVENT_PUBLISH_RECEIVED: 101 | EXAMPLE_TRACE("topic message arrived but without any related handle: topic=%.*s, topic_msg=%.*s", 102 | topic_info->topic_len, 103 | topic_info->ptopic, 104 | topic_info->payload_len, 105 | topic_info->payload); 106 | break; 107 | 108 | case IOTX_MQTT_EVENT_BUFFER_OVERFLOW: 109 | EXAMPLE_TRACE("buffer overflow, %s", msg->msg); 110 | break; 111 | 112 | default: 113 | EXAMPLE_TRACE("Should NOT arrive here."); 114 | break; 115 | } 116 | } 117 | 118 | static void _demo_message_arrive(void *pcontext, void *pclient, iotx_mqtt_event_msg_pt msg) 119 | { 120 | iotx_mqtt_topic_info_pt ptopic_info = (iotx_mqtt_topic_info_pt) msg->msg; 121 | switch (msg->event_type) { 122 | case IOTX_MQTT_EVENT_PUBLISH_RECEIVED: 123 | /* print topic name and topic message */ 124 | EXAMPLE_TRACE("----"); 125 | EXAMPLE_TRACE("PacketId: %d", ptopic_info->packet_id); 126 | EXAMPLE_TRACE("Topic: '%.*s' (Length: %d)", 127 | ptopic_info->topic_len, 128 | ptopic_info->ptopic, 129 | ptopic_info->topic_len); 130 | EXAMPLE_TRACE("Payload: '%.*s' (Length: %d)", 131 | ptopic_info->payload_len, 132 | ptopic_info->payload, 133 | ptopic_info->payload_len); 134 | EXAMPLE_TRACE("----"); 135 | break; 136 | default: 137 | EXAMPLE_TRACE("Should NOT arrive here."); 138 | break; 139 | } 140 | } 141 | 142 | int mqtt_client(void) 143 | { 144 | int rc, msg_len, cnt = 0; 145 | void *pclient; 146 | iotx_conn_info_pt pconn_info; 147 | iotx_mqtt_param_t mqtt_params; 148 | iotx_mqtt_topic_info_t topic_msg; 149 | char msg_pub[128]; 150 | 151 | /* Device AUTH */ 152 | if (0 != IOT_SetupConnInfo(PRODUCT_KEY, DEVICE_NAME, DEVICE_SECRET, (void **)&pconn_info)) { 153 | EXAMPLE_TRACE("AUTH request failed!"); 154 | return -1; 155 | } 156 | 157 | /* Initialize MQTT parameter */ 158 | memset(&mqtt_params, 0x0, sizeof(mqtt_params)); 159 | 160 | mqtt_params.port = pconn_info->port; 161 | mqtt_params.host = pconn_info->host_name; 162 | mqtt_params.client_id = pconn_info->client_id; 163 | mqtt_params.username = pconn_info->username; 164 | mqtt_params.password = pconn_info->password; 165 | mqtt_params.pub_key = pconn_info->pub_key; 166 | 167 | mqtt_params.request_timeout_ms = 2000; 168 | mqtt_params.clean_session = 0; 169 | mqtt_params.keepalive_interval_ms = 60000; 170 | mqtt_params.read_buf_size = MQTT_MSGLEN; 171 | mqtt_params.write_buf_size = MQTT_MSGLEN; 172 | 173 | mqtt_params.handle_event.h_fp = event_handle; 174 | mqtt_params.handle_event.pcontext = NULL; 175 | 176 | 177 | /* Construct a MQTT client with specify parameter */ 178 | pclient = IOT_MQTT_Construct(&mqtt_params); 179 | if (NULL == pclient) { 180 | EXAMPLE_TRACE("MQTT construct failed"); 181 | return -1; 182 | } 183 | 184 | ////////////////////////////////////////////////////////////////////////////////////////////// 185 | //send data to topic 186 | /* Initialize topic information */ 187 | memset(&topic_msg, 0x0, sizeof(iotx_mqtt_topic_info_t)); 188 | strcpy(msg_pub, "update: hello! start!"); 189 | 190 | topic_msg.qos = IOTX_MQTT_QOS1; 191 | topic_msg.retain = 0; 192 | topic_msg.dup = 0; 193 | topic_msg.payload = (void *)msg_pub; 194 | topic_msg.payload_len = strlen(msg_pub); 195 | 196 | rc = IOT_MQTT_Publish(pclient, TOPIC_UPDATE, &topic_msg); 197 | if (rc < 0) { 198 | IOT_MQTT_Destroy(&pclient); 199 | EXAMPLE_TRACE("error occur when publish"); 200 | return -1; 201 | } 202 | 203 | EXAMPLE_TRACE("\n publish message: \n topic: %s\n payload: \%s\n rc = %d", TOPIC_UPDATE, topic_msg.payload, rc); 204 | 205 | ////////////////////////////////////////////////////////////////////////////////////////////// 206 | //Subscribe a topic, then send a top 207 | /* Subscribe the specific topic */ 208 | rc = IOT_MQTT_Subscribe(pclient, DEVICE_PROPERTY_SET, IOTX_MQTT_QOS1, _demo_message_arrive, NULL); 209 | if (rc < 0) { 210 | IOT_MQTT_Destroy(&pclient); 211 | EXAMPLE_TRACE("IOT_MQTT_Subscribe() failed, rc = %d", rc); 212 | return -1; 213 | } 214 | rc = IOT_MQTT_Subscribe(pclient, DEVICE_INFO_UPDATE, IOTX_MQTT_QOS1, _demo_message_arrive, NULL); 215 | if (rc < 0) { 216 | IOT_MQTT_Destroy(&pclient); 217 | EXAMPLE_TRACE("IOT_MQTT_Subscribe() failed, rc = %d", rc); 218 | return -1; 219 | } 220 | rc = IOT_MQTT_Subscribe(pclient, TOPIC_GET, IOTX_MQTT_QOS1, _demo_message_arrive, NULL); 221 | if (rc < 0) { 222 | IOT_MQTT_Destroy(&pclient); 223 | EXAMPLE_TRACE("IOT_MQTT_Subscribe() failed, rc = %d", rc); 224 | return -1; 225 | } 226 | rc = IOT_MQTT_Subscribe(pclient, DEVICE_PROPERTY_POST_REPLY, IOTX_MQTT_QOS1, _demo_message_arrive, NULL); 227 | if (rc < 0) { 228 | IOT_MQTT_Destroy(&pclient); 229 | EXAMPLE_TRACE("IOT_MQTT_Subscribe() failed, rc = %d", rc); 230 | return -1; 231 | } 232 | 233 | IOT_MQTT_Yield(pclient, 200); 234 | 235 | HAL_SleepMs(2000); 236 | 237 | /* Initialize topic information */ 238 | memset(msg_pub, 0x0, 128); 239 | strcpy(msg_pub, "data: hello! start!"); 240 | memset(&topic_msg, 0x0, sizeof(iotx_mqtt_topic_info_t)); 241 | topic_msg.qos = IOTX_MQTT_QOS1; 242 | topic_msg.retain = 0; 243 | topic_msg.dup = 0; 244 | topic_msg.payload = (void *)msg_pub; 245 | topic_msg.payload_len = strlen(msg_pub); 246 | 247 | rc = IOT_MQTT_Publish(pclient, TOPIC_UPDATE, &topic_msg); 248 | EXAMPLE_TRACE("\n publish message: \n topic: %s\n payload: \%s\n rc = %d", TOPIC_UPDATE, topic_msg.payload, rc); 249 | 250 | IOT_MQTT_Yield(pclient, 200); 251 | 252 | ////////////////////////////////////////////////////////////////////////////////////////////// 253 | //then send a top 254 | do { 255 | /* Generate topic message */ 256 | cnt++; 257 | msg_len = snprintf(msg_pub, sizeof(msg_pub), "{\"method\":\"thing.event.property.post\",\"id\":\"7\",\"version\":\"1.0\",\"params\":{\"Status\":%d,\"Data\":\"Hello, World!-%d\"}}",cnt%2 == 0,cnt); 258 | 259 | if (msg_len < 0) { 260 | EXAMPLE_TRACE("Error occur! Exit program"); 261 | return -1; 262 | } 263 | 264 | topic_msg.payload = (void *)msg_pub; 265 | topic_msg.payload_len = msg_len; 266 | 267 | rc = IOT_MQTT_Publish(pclient, DEVICE_PROPERTY_POST, &topic_msg); 268 | if (rc < 0) { 269 | EXAMPLE_TRACE("error occur when publish"); 270 | } 271 | EXAMPLE_TRACE("packet-id=%u, publish topic msg=%s", (uint32_t)rc, msg_pub); 272 | 273 | /* handle the MQTT packet received from TCP or SSL connection */ 274 | IOT_MQTT_Yield(pclient, 1000); 275 | 276 | /* infinite loop if running with 'loop' argument */ 277 | if (user_argc >= 2 && !strcmp("loop", user_argv[1])) { 278 | // HAL_SleepMs(2000); 279 | // cnt = 0; 280 | } 281 | ESP_LOGI(TAG, "min:%u heap:%u", esp_get_minimum_free_heap_size(), esp_get_free_heap_size()); 282 | } while (cnt); 283 | 284 | IOT_MQTT_Yield(pclient, 200); 285 | 286 | IOT_MQTT_Unsubscribe(pclient, DEVICE_PROPERTY_SET); 287 | 288 | IOT_MQTT_Yield(pclient, 200); 289 | 290 | IOT_MQTT_Destroy(&pclient); 291 | 292 | return 0; 293 | } 294 | 295 | int linkkit_main(void *paras) 296 | { 297 | IOT_SetLogLevel(IOT_LOG_DEBUG); 298 | 299 | user_argc = 0; 300 | user_argv = NULL; 301 | 302 | if (paras != NULL) { 303 | app_main_paras_t *p = (app_main_paras_t *)paras; 304 | user_argc = p->argc; 305 | user_argv = p->argv; 306 | } 307 | 308 | HAL_SetProductKey(PRODUCT_KEY); 309 | HAL_SetDeviceName(DEVICE_NAME); 310 | HAL_SetDeviceSecret(DEVICE_SECRET); 311 | HAL_SetProductSecret(PRODUCT_SECRET); 312 | /* Choose Login Server */ 313 | int domain_type = IOTX_CLOUD_REGION_SHANGHAI; 314 | IOT_Ioctl(IOTX_IOCTL_SET_DOMAIN, (void *)&domain_type); 315 | 316 | /* Choose Login Method */ 317 | int dynamic_register = 0; 318 | IOT_Ioctl(IOTX_IOCTL_SET_DYNAMIC_REGISTER, (void *)&dynamic_register); 319 | 320 | mqtt_client(); 321 | IOT_DumpMemoryStats(IOT_LOG_DEBUG); 322 | IOT_SetLogLevel(IOT_LOG_NONE); 323 | 324 | EXAMPLE_TRACE("out of sample!"); 325 | 326 | return 0; 327 | } 328 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/src/iothub/esp_qcloud_device.c: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include 16 | 17 | #include 18 | 19 | #include "esp_qcloud_iothub.h" 20 | #include "esp_qcloud_utils.h" 21 | 22 | #ifdef CONFIG_QCLOUD_MASS_MANUFACTURE 23 | #include "nvs.h" 24 | #include "nvs_flash.h" 25 | #endif 26 | 27 | /* Handle to maintain internal information (will move to an internal file) */ 28 | typedef struct { 29 | char *product_id; 30 | char *version; 31 | esp_qcloud_auth_mode_t auth_mode; 32 | char *device_name; 33 | union { 34 | char *device_secret; 35 | struct { 36 | char *cert_crt; 37 | char *private_key; 38 | }; 39 | }; 40 | } esp_qcloud_profile_t; 41 | 42 | static esp_qcloud_profile_t *g_device_profile = NULL; 43 | static esp_qcloud_set_param_t g_esp_qcloud_set_param = NULL; 44 | static esp_qcloud_get_param_t g_esp_qcloud_get_param = NULL; 45 | 46 | static SLIST_HEAD(param_list_, esp_qcloud_param) g_property_list; 47 | static SLIST_HEAD(action_list_, esp_qcloud_action) g_action_list; 48 | 49 | #ifdef CONFIG_AUTH_MODE_CERT 50 | extern const uint8_t dev_cert_crt_start[] asm("_binary_dev_cert_crt_start"); 51 | extern const uint8_t dev_cert_crt_end[] asm("_binary_dev_cert_crt_end"); 52 | extern const uint8_t dev_private_key_start[] asm("_binary_dev_private_key_start"); 53 | extern const uint8_t dev_private_key_end[] asm("_binary_dev_private_key_end"); 54 | #endif 55 | 56 | static const char *TAG = "esp_qcloud_device"; 57 | 58 | esp_err_t esp_qcloud_device_add_fw_version(const char *version) 59 | { 60 | ESP_QCLOUD_PARAM_CHECK(version); 61 | 62 | g_device_profile->version = strdup(version); 63 | 64 | return ESP_OK; 65 | } 66 | 67 | esp_err_t esp_qcloud_device_secret(const char *device_secret) 68 | { 69 | ESP_QCLOUD_PARAM_CHECK(device_secret && strlen(device_secret) == DEVICE_SECRET_SIZE); 70 | 71 | return ESP_OK; 72 | } 73 | 74 | esp_err_t esp_qcloud_device_cert(const char *cert_crt, const char *private_key) 75 | { 76 | ESP_QCLOUD_PARAM_CHECK(cert_crt); 77 | ESP_QCLOUD_PARAM_CHECK(private_key); 78 | 79 | g_device_profile->cert_crt = strdup(cert_crt); 80 | g_device_profile->private_key = strdup(private_key); 81 | g_device_profile->auth_mode = QCLOUD_AUTH_MODE_CERT; 82 | 83 | return ESP_OK; 84 | } 85 | 86 | esp_err_t esp_qcloud_create_device() 87 | { 88 | g_device_profile = ESP_QCLOUD_CALLOC(1, sizeof(esp_qcloud_profile_t)); 89 | 90 | #ifdef CONFIG_QCLOUD_MASS_MANUFACTURE 91 | g_device_profile->auth_mode = QCLOUD_AUTH_MODE_KEY; 92 | /** 93 | * @brief Read device configuration information through flash 94 | * 1. Configure device information via single_mfg_config.csv 95 | * 2. Generate single_mfg_config.bin, use the following command: 96 | * python $IDF_PATH/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py generate single_mfg_config.csv single_mfg_config.bin 0x4000 97 | * 3. Burn single_mfg_config.bin to flash 98 | * python $IDF_PATH/components/esptool_py/esptool/esptool.py write_flash 0x15000 single_mfg_config.bin 99 | * @note Currently does not support the use of certificates for mass manufacture 100 | */ 101 | esp_err_t err = ESP_FAIL; 102 | nvs_handle handle = 0; 103 | size_t required_size = 0; 104 | ESP_ERROR_CHECK(nvs_flash_init_partition(CONFIG_QCLOUD_FACTRY_PARTITION_NAME)); 105 | err = nvs_open_from_partition(CONFIG_QCLOUD_FACTRY_PARTITION_NAME, 106 | CONFIG_QCLOUD_FACTRY_PARTITION_NAMESPACE, NVS_READONLY, &handle); 107 | ESP_QCLOUD_ERROR_GOTO(err != ESP_OK, ERR_EXIT, "<%s> Factory partition information is not burned", esp_err_to_name(err)); 108 | 109 | required_size = PRODUCT_ID_SIZE + 1; 110 | g_device_profile->product_id = ESP_QCLOUD_CALLOC(1, PRODUCT_ID_SIZE + 1); 111 | ESP_ERROR_CHECK(nvs_get_str(handle, "product_id", g_device_profile->product_id, &required_size)); 112 | 113 | required_size = DEVICE_NAME_MAX_SIZE + 1; 114 | g_device_profile->device_name = ESP_QCLOUD_CALLOC(1, DEVICE_NAME_MAX_SIZE + 1); 115 | ESP_ERROR_CHECK(nvs_get_str(handle, "device_name", g_device_profile->device_name, &required_size)); 116 | 117 | required_size = DEVICE_SECRET_SIZE + 1; 118 | g_device_profile->device_secret = ESP_QCLOUD_CALLOC(1, DEVICE_SECRET_SIZE + 1); 119 | ESP_ERROR_CHECK(nvs_get_str(handle, "device_secret", g_device_profile->device_secret, &required_size)); 120 | #else 121 | 122 | g_device_profile->product_id = CONFIG_QCLOUD_PRODUCT_ID; 123 | g_device_profile->device_name = CONFIG_QCLOUD_DEVICE_NAME; 124 | 125 | #ifdef CONFIG_AUTH_MODE_KEY 126 | g_device_profile->auth_mode = QCLOUD_AUTH_MODE_KEY; 127 | /** 128 | * @brief Read device configuration information through sdkconfig.h 129 | * 1. Configure device information via `idf.py menuconfig`, Menu path: (Top) -> Example Configuration 130 | * 2. Select key authentication 131 | * 3. Enter device secret key 132 | */ 133 | g_device_profile->device_secret = CONFIG_QCLOUD_DEVICE_SECRET; 134 | 135 | if (strlen(g_device_profile->device_secret) != DEVICE_SECRET_SIZE 136 | || strlen(g_device_profile->product_id) != PRODUCT_ID_SIZE) { 137 | ESP_LOGE(TAG, "Please check if the authentication information of the device is configured"); 138 | ESP_LOGE(TAG, "Obtain authentication configuration information from login qcloud iothut: "); 139 | ESP_LOGE(TAG, "https://console.cloud.tencent.com/iotexplorer"); 140 | ESP_LOGE(TAG, "product_id: %s", g_device_profile->product_id); 141 | ESP_LOGE(TAG, "device_name: %s", g_device_profile->device_name); 142 | ESP_LOGE(TAG, "device_secret: %s", g_device_profile->device_secret); 143 | goto ERR_EXIT; 144 | } 145 | #endif 146 | 147 | #ifdef CONFIG_AUTH_MODE_CERT 148 | g_device_profile->auth_mode = QCLOUD_AUTH_MODE_CERT; 149 | /** 150 | * @brief Read device configuration information through sdkconfig.h 151 | * 1. Configure device information via `idf.py menuconfig`, Menu path: (Top) -> Example Configuration 152 | * 2. Choose certificate authentication 153 | * 3. Replace the certificate file in the config directory 154 | */ 155 | 156 | g_device_profile->cert_crt = (char*)dev_cert_crt_start; 157 | g_device_profile->private_key = (char*)dev_private_key_start; 158 | 159 | if (strlen(g_device_profile->product_id) != PRODUCT_ID_SIZE 160 | || strlen(g_device_profile->cert_crt) == DEVICE_CERT_FILE_DEFAULT_SIZE) { 161 | ESP_LOGE(TAG, "Please check if the authentication information of the device is configured"); 162 | ESP_LOGE(TAG, "Obtain authentication configuration information from login qcloud iothut: "); 163 | ESP_LOGE(TAG, "https://console.cloud.tencent.com/iotexplorer"); 164 | ESP_LOGE(TAG, "product_id: %s", g_device_profile->product_id); 165 | ESP_LOGE(TAG, "device_name: %s", g_device_profile->device_name); 166 | ESP_LOGE(TAG, "cert_crt: \r\n%s", g_device_profile->cert_crt); 167 | ESP_LOGE(TAG, "private_key: \r\n%s", g_device_profile->private_key); 168 | goto ERR_EXIT; 169 | } 170 | #endif 171 | 172 | #endif 173 | 174 | return ESP_OK; 175 | 176 | ERR_EXIT: 177 | ESP_QCLOUD_FREE(g_device_profile); 178 | vTaskDelay(pdMS_TO_TICKS(3000)); 179 | return ESP_FAIL; 180 | } 181 | 182 | const char *esp_qcloud_get_device_name() 183 | { 184 | return g_device_profile->device_name; 185 | } 186 | 187 | const char *esp_qcloud_get_version() 188 | { 189 | return g_device_profile->version; 190 | } 191 | 192 | const char *esp_qcloud_get_product_id() 193 | { 194 | return g_device_profile->product_id; 195 | } 196 | 197 | esp_qcloud_auth_mode_t esp_qcloud_get_auth_mode() 198 | { 199 | return g_device_profile->auth_mode; 200 | } 201 | 202 | const char *esp_qcloud_get_device_secret() 203 | { 204 | return g_device_profile->device_secret; 205 | } 206 | 207 | const char *esp_qcloud_get_cert_crt() 208 | { 209 | return g_device_profile->cert_crt; 210 | } 211 | 212 | const char *esp_qcloud_get_private_key() 213 | { 214 | return g_device_profile->private_key; 215 | } 216 | 217 | esp_err_t esp_qcloud_device_add_property(const char *id, esp_qcloud_param_val_type_t type) 218 | { 219 | esp_qcloud_param_t *item = ESP_QCLOUD_CALLOC(1, sizeof(esp_qcloud_param_t)); 220 | 221 | item->id = strdup(id); 222 | item->value.type = type; 223 | 224 | esp_qcloud_param_t *last = SLIST_FIRST(&g_property_list); 225 | 226 | if (last == NULL) { 227 | SLIST_INSERT_HEAD(&g_property_list, item, next); 228 | } else { 229 | SLIST_INSERT_AFTER(last, item, next); 230 | } 231 | 232 | return ESP_OK; 233 | } 234 | 235 | esp_err_t esp_qcloud_device_add_action_cb(const char *action_id, const esp_qcloud_action_cb_t action_cb) 236 | { 237 | esp_qcloud_action_t *item = ESP_QCLOUD_CALLOC(1, sizeof(esp_qcloud_action_t)); 238 | 239 | item->id = strdup(action_id); 240 | item->action_cb = action_cb; 241 | 242 | esp_qcloud_action_t *last = SLIST_FIRST(&g_action_list); 243 | 244 | if (last == NULL) { 245 | SLIST_INSERT_HEAD(&g_action_list, item, next); 246 | } else { 247 | SLIST_INSERT_AFTER(last, item, next); 248 | } 249 | 250 | return ESP_OK; 251 | } 252 | 253 | esp_err_t esp_qcloud_device_add_property_cb(const esp_qcloud_get_param_t get_param_cb, 254 | const esp_qcloud_set_param_t set_param_cb) 255 | { 256 | g_esp_qcloud_get_param = get_param_cb; 257 | g_esp_qcloud_set_param = set_param_cb; 258 | 259 | return ESP_OK; 260 | } 261 | 262 | esp_err_t esp_qcloud_handle_set_param(const cJSON *request_params, cJSON *reply_data) 263 | { 264 | esp_err_t err = ESP_FAIL; 265 | 266 | for (cJSON *item = request_params->child; item; item = item->next) { 267 | esp_qcloud_param_val_t value = {0}; 268 | 269 | switch (item->type) { 270 | case cJSON_False: 271 | value.b = false; 272 | break; 273 | 274 | case cJSON_True: 275 | value.b = true; 276 | break; 277 | 278 | case cJSON_Number: 279 | value.i = item->valueint; 280 | value.f = item->valuedouble; 281 | break; 282 | 283 | case cJSON_String: 284 | value.s = item->valuestring; 285 | break; 286 | 287 | case cJSON_Object: 288 | value.obj = item->child; 289 | break; 290 | 291 | default: 292 | break; 293 | } 294 | 295 | err = g_esp_qcloud_set_param(item->string, &value); 296 | ESP_QCLOUD_ERROR_BREAK(err != ESP_OK, "<%s> esp_qcloud_set_param, id: %s", 297 | esp_err_to_name(err), item->string); 298 | } 299 | 300 | return err; 301 | } 302 | 303 | esp_err_t esp_qcloud_handle_get_param(const cJSON *request_data, cJSON *reply_data) 304 | { 305 | esp_err_t err = ESP_FAIL; 306 | 307 | esp_qcloud_param_t *param; 308 | SLIST_FOREACH(param, &g_property_list, next) { 309 | /* Check if command starts with buf */ 310 | err = g_esp_qcloud_get_param(param->id, ¶m->value); 311 | ESP_QCLOUD_ERROR_BREAK(err != ESP_OK, "esp_qcloud_get_param, id: %s", param->id); 312 | 313 | if (param->value.type == QCLOUD_VAL_TYPE_INTEGER) { 314 | cJSON_AddNumberToObject(reply_data, param->id, param->value.i); 315 | } else if (param->value.type == QCLOUD_VAL_TYPE_BOOLEAN) { 316 | cJSON_AddNumberToObject(reply_data, param->id, param->value.b); 317 | } else if (param->value.type == QCLOUD_VAL_TYPE_STRING) { 318 | cJSON_AddStringToObject(reply_data, param->id, param->value.s); 319 | } else if (param->value.type == QCLOUD_VAL_TYPE_FLOAT) { 320 | cJSON_AddNumberToObject(reply_data, param->id, param->value.f); 321 | } 322 | } 323 | 324 | return err; 325 | } 326 | 327 | esp_err_t esp_qcloud_operate_action(esp_qcloud_method_t *action_handle, const char *action_id, char *params) 328 | { 329 | esp_err_t err = ESP_ERR_NOT_FOUND; 330 | 331 | esp_qcloud_action_t *action; 332 | SLIST_FOREACH(action, &g_action_list, next) { 333 | if(!strcmp(action->id, action_id)){ 334 | return action->action_cb(action_handle, params); 335 | } 336 | } 337 | ESP_LOGE(TAG, "The callback function of <%s> was not found, Please check ", action_id); 338 | return err; 339 | } 340 | -------------------------------------------------------------------------------- /app/aliyun_dd_xxj/my_src/mqtt_example.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2018 Alibaba Group Holding Limited 3 | */ 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "iot_import.h" 11 | #include "iot_export.h" 12 | #include "app_entry.h" 13 | #include "esp_system.h" 14 | #include "esp_log.h" 15 | #include "cJSON.h" 16 | 17 | // #define PRODUCT_KEY NULL 18 | #define PRODUCT_KEY "a15Ws4gOoAP" 19 | #define PRODUCT_SECRET "90CusBMPSkclFUpn" 20 | #define DEVICE_NAME "develop1" 21 | #define DEVICE_SECRET "jcTRzLc8kY5MxkPDUViMyRZJBHFt7TyN" 22 | 23 | /* These are pre-defined topics */ 24 | #define TOPIC_UPDATE "/"PRODUCT_KEY"/"DEVICE_NAME"/user/update" 25 | #define TOPIC_ERROR "/"PRODUCT_KEY"/"DEVICE_NAME"/user/update/error" 26 | #define TOPIC_GET "/"PRODUCT_KEY"/"DEVICE_NAME"/user/get" 27 | 28 | #define DEVICE_PROPERTY_POST "/sys/"PRODUCT_KEY"/"DEVICE_NAME"/thing/event/property/post" 29 | #define DEVICE_PROPERTY_POST_REPLY "/sys/"PRODUCT_KEY"/"DEVICE_NAME"/thing/event/property/post_reply" 30 | #define DEVICE_PROPERTY_SET "/sys/"PRODUCT_KEY"/"DEVICE_NAME"/thing/service/property/set" 31 | #define DEVICE_INFO_UPDATE "/sys/"PRODUCT_KEY"/"DEVICE_NAME"/thing/deviceinfo/update" 32 | 33 | #define MQTT_MSGLEN (1024) 34 | 35 | #define EXAMPLE_TRACE(fmt, ...) \ 36 | do { \ 37 | HAL_Printf("%s|%03d :: ", __func__, __LINE__); \ 38 | HAL_Printf(fmt, ##__VA_ARGS__); \ 39 | HAL_Printf("%s", "\r\n"); \ 40 | } while(0) 41 | 42 | static int user_argc; 43 | static char **user_argv; 44 | 45 | static const char *TAG = "MQTT"; 46 | 47 | static char update_flag = 1; 48 | typedef struct{ 49 | bool PowerSwitch; 50 | bool OilShortage; 51 | char SprayLevel; 52 | char timer[41]; 53 | char time_syn[21]; 54 | }dps_s; 55 | 56 | dps_s dps = { 57 | .PowerSwitch = 0, 58 | .OilShortage = 0, 59 | .SprayLevel = 0, 60 | .timer = "0123456789012345678901234567890123456789", 61 | .time_syn = "1512038504", 62 | }; 63 | 64 | 65 | char get_value(const char *jsonRoot){ 66 | // jsonRoot 是您要剖析的数据 67 | //首先整体判断是否为一个json格式的数据 68 | cJSON *pJsonRoot = cJSON_Parse(jsonRoot); 69 | //如果是否json格式数据 70 | if (pJsonRoot !=NULL) { 71 | cJSON *pParams = cJSON_GetObjectItem(pJsonRoot, "params"); 72 | if(pParams != NULL){ 73 | cJSON *pValue = cJSON_GetObjectItem(pParams, "PowerSwitch"); 74 | if(pValue != NULL){ 75 | EXAMPLE_TRACE("dp: PowerSwitch:%d",pValue->valueint); 76 | dps.PowerSwitch = pValue->valueint; 77 | } 78 | pValue = cJSON_GetObjectItem(pParams, "OilShortage"); 79 | if(pValue != NULL){ 80 | EXAMPLE_TRACE("dp: OilShortage:%d",pValue->valueint); 81 | dps.OilShortage = pValue->valueint; 82 | } 83 | pValue = cJSON_GetObjectItem(pParams, "SprayLevel"); 84 | if(pValue != NULL){ 85 | EXAMPLE_TRACE("dp: SprayLevel:%d",pValue->valueint); 86 | dps.SprayLevel = pValue->valueint; 87 | } 88 | pValue = cJSON_GetObjectItem(pParams, "timer"); 89 | if(pValue != NULL){ 90 | EXAMPLE_TRACE("dp: timer:%s",pValue->valuestring); 91 | memset(dps.timer,0,sizeof(dps.timer)); 92 | memcpy(dps.timer,pValue->valuestring,strlen(pValue->valuestring)); 93 | } 94 | pValue = cJSON_GetObjectItem(pParams, "time_syn"); 95 | if(pValue != NULL){ 96 | EXAMPLE_TRACE("dp: time_syn:%s",pValue->valuestring); 97 | memset(dps.time_syn,0,sizeof(dps.time_syn)); 98 | memcpy(dps.time_syn,pValue->valuestring,strlen(pValue->valuestring)); 99 | } 100 | update_flag = 1; 101 | } 102 | } 103 | 104 | return 1; 105 | } 106 | 107 | 108 | void event_handle(void *pcontext, void *pclient, iotx_mqtt_event_msg_pt msg) 109 | { 110 | uintptr_t packet_id = (uintptr_t)msg->msg; 111 | iotx_mqtt_topic_info_pt topic_info = (iotx_mqtt_topic_info_pt)msg->msg; 112 | 113 | switch (msg->event_type) { 114 | case IOTX_MQTT_EVENT_UNDEF: 115 | EXAMPLE_TRACE("undefined event occur."); 116 | break; 117 | 118 | case IOTX_MQTT_EVENT_DISCONNECT: 119 | EXAMPLE_TRACE("MQTT disconnect."); 120 | break; 121 | 122 | case IOTX_MQTT_EVENT_RECONNECT: 123 | EXAMPLE_TRACE("MQTT reconnect."); 124 | break; 125 | 126 | case IOTX_MQTT_EVENT_SUBCRIBE_SUCCESS: 127 | EXAMPLE_TRACE("subscribe success, packet-id=%u", (unsigned int)packet_id); 128 | break; 129 | 130 | case IOTX_MQTT_EVENT_SUBCRIBE_TIMEOUT: 131 | EXAMPLE_TRACE("subscribe wait ack timeout, packet-id=%u", (unsigned int)packet_id); 132 | break; 133 | 134 | case IOTX_MQTT_EVENT_SUBCRIBE_NACK: 135 | EXAMPLE_TRACE("subscribe nack, packet-id=%u", (unsigned int)packet_id); 136 | break; 137 | 138 | case IOTX_MQTT_EVENT_UNSUBCRIBE_SUCCESS: 139 | EXAMPLE_TRACE("unsubscribe success, packet-id=%u", (unsigned int)packet_id); 140 | break; 141 | 142 | case IOTX_MQTT_EVENT_UNSUBCRIBE_TIMEOUT: 143 | EXAMPLE_TRACE("unsubscribe timeout, packet-id=%u", (unsigned int)packet_id); 144 | break; 145 | 146 | case IOTX_MQTT_EVENT_UNSUBCRIBE_NACK: 147 | EXAMPLE_TRACE("unsubscribe nack, packet-id=%u", (unsigned int)packet_id); 148 | break; 149 | 150 | case IOTX_MQTT_EVENT_PUBLISH_SUCCESS: 151 | EXAMPLE_TRACE("publish success, packet-id=%u", (unsigned int)packet_id); 152 | break; 153 | 154 | case IOTX_MQTT_EVENT_PUBLISH_TIMEOUT: 155 | EXAMPLE_TRACE("publish timeout, packet-id=%u", (unsigned int)packet_id); 156 | break; 157 | 158 | case IOTX_MQTT_EVENT_PUBLISH_NACK: 159 | EXAMPLE_TRACE("publish nack, packet-id=%u", (unsigned int)packet_id); 160 | break; 161 | 162 | case IOTX_MQTT_EVENT_PUBLISH_RECEIVED: 163 | EXAMPLE_TRACE("topic message arrived but without any related handle: topic=%.*s, topic_msg=%.*s", 164 | topic_info->topic_len, 165 | topic_info->ptopic, 166 | topic_info->payload_len, 167 | topic_info->payload); 168 | break; 169 | 170 | case IOTX_MQTT_EVENT_BUFFER_OVERFLOW: 171 | EXAMPLE_TRACE("buffer overflow, %s", msg->msg); 172 | break; 173 | 174 | default: 175 | EXAMPLE_TRACE("Should NOT arrive here."); 176 | break; 177 | } 178 | } 179 | 180 | static void _demo_message_arrive(void *pcontext, void *pclient, iotx_mqtt_event_msg_pt msg) 181 | { 182 | iotx_mqtt_topic_info_pt ptopic_info = (iotx_mqtt_topic_info_pt) msg->msg; 183 | switch (msg->event_type) { 184 | case IOTX_MQTT_EVENT_PUBLISH_RECEIVED: 185 | /* print topic name and topic message */ 186 | EXAMPLE_TRACE("----"); 187 | EXAMPLE_TRACE("PacketId: %d", ptopic_info->packet_id); 188 | EXAMPLE_TRACE("Topic: '%.*s' (Length: %d)", 189 | ptopic_info->topic_len, 190 | ptopic_info->ptopic, 191 | ptopic_info->topic_len); 192 | EXAMPLE_TRACE("Payload: '%.*s' (Length: %d)", 193 | ptopic_info->payload_len, 194 | ptopic_info->payload, 195 | ptopic_info->payload_len); 196 | get_value(ptopic_info->payload); 197 | EXAMPLE_TRACE("----"); 198 | break; 199 | default: 200 | EXAMPLE_TRACE("Should NOT arrive here."); 201 | break; 202 | } 203 | } 204 | 205 | int mqtt_client(void) 206 | { 207 | int rc, msg_len, cnt = 0; 208 | void *pclient; 209 | iotx_conn_info_pt pconn_info; 210 | iotx_mqtt_param_t mqtt_params; 211 | iotx_mqtt_topic_info_t topic_msg; 212 | char msg_pub[256]; 213 | 214 | /* Device AUTH */ 215 | if (0 != IOT_SetupConnInfo(PRODUCT_KEY, DEVICE_NAME, DEVICE_SECRET, (void **)&pconn_info)) { 216 | EXAMPLE_TRACE("AUTH request failed!"); 217 | return -1; 218 | } 219 | 220 | /* Initialize MQTT parameter */ 221 | memset(&mqtt_params, 0x0, sizeof(mqtt_params)); 222 | 223 | mqtt_params.port = pconn_info->port; 224 | mqtt_params.host = pconn_info->host_name; 225 | mqtt_params.client_id = pconn_info->client_id; 226 | mqtt_params.username = pconn_info->username; 227 | mqtt_params.password = pconn_info->password; 228 | mqtt_params.pub_key = pconn_info->pub_key; 229 | 230 | mqtt_params.request_timeout_ms = 2000; 231 | mqtt_params.clean_session = 0; 232 | mqtt_params.keepalive_interval_ms = 60000; 233 | mqtt_params.read_buf_size = MQTT_MSGLEN; 234 | mqtt_params.write_buf_size = MQTT_MSGLEN; 235 | 236 | mqtt_params.handle_event.h_fp = event_handle; 237 | mqtt_params.handle_event.pcontext = NULL; 238 | 239 | 240 | /* Construct a MQTT client with specify parameter */ 241 | pclient = IOT_MQTT_Construct(&mqtt_params); 242 | if (NULL == pclient) { 243 | EXAMPLE_TRACE("MQTT construct failed"); 244 | return -1; 245 | } 246 | 247 | ////////////////////////////////////////////////////////////////////////////////////////////// 248 | //send data to topic 249 | /* Initialize topic information */ 250 | memset(&topic_msg, 0x0, sizeof(iotx_mqtt_topic_info_t)); 251 | strcpy(msg_pub, "update: hello! start!"); 252 | 253 | topic_msg.qos = IOTX_MQTT_QOS1; 254 | topic_msg.retain = 0; 255 | topic_msg.dup = 0; 256 | topic_msg.payload = (void *)msg_pub; 257 | topic_msg.payload_len = strlen(msg_pub); 258 | 259 | rc = IOT_MQTT_Publish(pclient, TOPIC_UPDATE, &topic_msg); 260 | if (rc < 0) { 261 | IOT_MQTT_Destroy(&pclient); 262 | EXAMPLE_TRACE("error occur when publish"); 263 | return -1; 264 | } 265 | 266 | EXAMPLE_TRACE("\n publish message: \n topic: %s\n payload: \%s\n rc = %d", TOPIC_UPDATE, topic_msg.payload, rc); 267 | 268 | ////////////////////////////////////////////////////////////////////////////////////////////// 269 | //Subscribe a topic, then send a top 270 | /* Subscribe the specific topic */ 271 | rc = IOT_MQTT_Subscribe(pclient, DEVICE_PROPERTY_SET, IOTX_MQTT_QOS1, _demo_message_arrive, NULL); 272 | if (rc < 0) { 273 | IOT_MQTT_Destroy(&pclient); 274 | EXAMPLE_TRACE("IOT_MQTT_Subscribe() failed, rc = %d", rc); 275 | return -1; 276 | } 277 | rc = IOT_MQTT_Subscribe(pclient, DEVICE_INFO_UPDATE, IOTX_MQTT_QOS1, _demo_message_arrive, NULL); 278 | if (rc < 0) { 279 | IOT_MQTT_Destroy(&pclient); 280 | EXAMPLE_TRACE("IOT_MQTT_Subscribe() failed, rc = %d", rc); 281 | return -1; 282 | } 283 | rc = IOT_MQTT_Subscribe(pclient, TOPIC_GET, IOTX_MQTT_QOS1, _demo_message_arrive, NULL); 284 | if (rc < 0) { 285 | IOT_MQTT_Destroy(&pclient); 286 | EXAMPLE_TRACE("IOT_MQTT_Subscribe() failed, rc = %d", rc); 287 | return -1; 288 | } 289 | rc = IOT_MQTT_Subscribe(pclient, DEVICE_PROPERTY_POST_REPLY, IOTX_MQTT_QOS1, _demo_message_arrive, NULL); 290 | if (rc < 0) { 291 | IOT_MQTT_Destroy(&pclient); 292 | EXAMPLE_TRACE("IOT_MQTT_Subscribe() failed, rc = %d", rc); 293 | return -1; 294 | } 295 | 296 | IOT_MQTT_Yield(pclient, 200); 297 | 298 | HAL_SleepMs(2000); 299 | 300 | /* Initialize topic information */ 301 | memset(msg_pub, 0x0, 256); 302 | strcpy(msg_pub, "data: hello! start!"); 303 | memset(&topic_msg, 0x0, sizeof(iotx_mqtt_topic_info_t)); 304 | topic_msg.qos = IOTX_MQTT_QOS1; 305 | topic_msg.retain = 0; 306 | topic_msg.dup = 0; 307 | topic_msg.payload = (void *)msg_pub; 308 | topic_msg.payload_len = strlen(msg_pub); 309 | 310 | rc = IOT_MQTT_Publish(pclient, TOPIC_UPDATE, &topic_msg); 311 | EXAMPLE_TRACE("\n publish message: \n topic: %s\n payload: \%s\n rc = %d", TOPIC_UPDATE, topic_msg.payload, rc); 312 | 313 | IOT_MQTT_Yield(pclient, 200); 314 | 315 | ////////////////////////////////////////////////////////////////////////////////////////////// 316 | //then send a top 317 | 318 | do { 319 | /* Generate topic message */ 320 | cnt++; 321 | if(update_flag){ 322 | update_flag = 0; 323 | msg_len = snprintf(msg_pub, sizeof(msg_pub), 324 | "{\"method\":\"thing.event.property.post\",\"id\":\"7\",\"version\":\"1.0\",\"params\":{\"PowerSwitch\":%d,\"OilShortage\":%d,\"SprayLevel\":%d,\"timer\":\"%s\",\"time_syn\":\"%s\"}}", 325 | dps.PowerSwitch, dps.OilShortage, dps.SprayLevel, dps.timer, dps.time_syn); 326 | 327 | if (msg_len < 0) { 328 | EXAMPLE_TRACE("Error occur! Exit program"); 329 | return -1; 330 | } 331 | 332 | topic_msg.payload = (void *)msg_pub; 333 | topic_msg.payload_len = msg_len; 334 | 335 | rc = IOT_MQTT_Publish(pclient, DEVICE_PROPERTY_POST, &topic_msg); 336 | if (rc < 0) { 337 | EXAMPLE_TRACE("error occur when publish"); 338 | } 339 | EXAMPLE_TRACE("packet-id=%u, publish topic msg=%s", (uint32_t)rc, msg_pub); 340 | } 341 | 342 | /* handle the MQTT packet received from TCP or SSL connection */ 343 | IOT_MQTT_Yield(pclient, 1000); 344 | 345 | /* infinite loop if running with 'loop' argument */ 346 | if (user_argc >= 2 && !strcmp("loop", user_argv[1])) { 347 | //HAL_SleepMs(2000); 348 | //cnt = 0; 349 | } 350 | ESP_LOGI(TAG, "min:%u heap:%u", esp_get_minimum_free_heap_size(), esp_get_free_heap_size()); 351 | } while (cnt); 352 | 353 | IOT_MQTT_Yield(pclient, 200); 354 | 355 | IOT_MQTT_Unsubscribe(pclient, DEVICE_PROPERTY_SET); 356 | 357 | IOT_MQTT_Yield(pclient, 200); 358 | 359 | IOT_MQTT_Destroy(&pclient); 360 | 361 | return 0; 362 | } 363 | 364 | int linkkit_main(void *paras) 365 | { 366 | IOT_SetLogLevel(IOT_LOG_DEBUG); 367 | 368 | user_argc = 0; 369 | user_argv = NULL; 370 | 371 | if (paras != NULL) { 372 | app_main_paras_t *p = (app_main_paras_t *)paras; 373 | user_argc = p->argc; 374 | user_argv = p->argv; 375 | } 376 | 377 | HAL_SetProductKey(PRODUCT_KEY); 378 | HAL_SetDeviceName(DEVICE_NAME); 379 | HAL_SetDeviceSecret(DEVICE_SECRET); 380 | HAL_SetProductSecret(PRODUCT_SECRET); 381 | /* Choose Login Server */ 382 | int domain_type = IOTX_CLOUD_REGION_SHANGHAI; 383 | IOT_Ioctl(IOTX_IOCTL_SET_DOMAIN, (void *)&domain_type); 384 | 385 | /* Choose Login Method */ 386 | int dynamic_register = 0; 387 | IOT_Ioctl(IOTX_IOCTL_SET_DYNAMIC_REGISTER, (void *)&dynamic_register); 388 | 389 | mqtt_client(); 390 | IOT_DumpMemoryStats(IOT_LOG_DEBUG); 391 | IOT_SetLogLevel(IOT_LOG_NONE); 392 | 393 | EXAMPLE_TRACE("out of sample!"); 394 | 395 | return 0; 396 | } 397 | -------------------------------------------------------------------------------- /app/tencent_jm_xxj/my_src/include/esp_qcloud_iothub.h: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Espressif Systems (Shanghai) PTE LTD 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #pragma once 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | #include "esp_qcloud_mem.h" 24 | #include "esp_qcloud_utils.h" 25 | 26 | #include "cJSON.h" 27 | 28 | #ifdef __cplusplus 29 | extern "C" 30 | { 31 | #endif 32 | 33 | /** 34 | * @brief QCloud Length of configuration information. 35 | */ 36 | #define CLIENT_ID_MAX_SIZE (80) /**< MAX size of client ID */ 37 | #define PRODUCT_ID_SIZE (10) /**< MAX size of product ID */ 38 | #define PRODUCT_SECRET_MAX_SIZE (32) /**< MAX size of product secret */ 39 | #define DEVICE_NAME_MAX_SIZE (48) /**< MAX size of device name */ 40 | #define DEVICE_SECRET_SIZE (24) /**< MAX size of device secret */ 41 | #define DEVICE_CERT_FILE_DEFAULT_SIZE (92) /**< MAX size of device cert file name */ 42 | 43 | #define AUTH_TOKEN_MAX_SIZE (32) /**< MAX size of auth token */ 44 | 45 | /** 46 | * @brief ESP QCloud Event Base. 47 | */ 48 | ESP_EVENT_DECLARE_BASE(QCLOUD_EVENT); 49 | 50 | /** 51 | * @brief ESP QCloud Events. 52 | */ 53 | typedef enum { 54 | QCLOUD_EVENT_IOTHUB_INIT_DONE = 1, /**< QCloud core Initialisation Done */ 55 | QCLOUD_EVENT_IOTHUB_BOND_DEVICE, /**< QCloud bind device */ 56 | QCLOUD_EVENT_IOTHUB_UNBOND_DEVICE, /**< QCloud unbind device */ 57 | QCLOUD_EVENT_IOTHUB_BIND_EXCEPTION, /**< QCloud bind exception */ 58 | QCLOUD_EVENT_IOTHUB_RECEIVE_STATUS, /**< QCloud receive status message */ 59 | QCLOUD_EVENT_LOG_FLASH_FULL, /**< QCloud log storage full */ 60 | } esp_qcloud_iothub_event_t; 61 | 62 | /** 63 | * @brief ESP QCloud Auth mode. 64 | */ 65 | typedef enum { 66 | QCLOUD_AUTH_MODE_INVALID, /**< Invalid mode */ 67 | QCLOUD_AUTH_MODE_KEY, /**< Key authentication */ 68 | QCLOUD_AUTH_MODE_CERT, /**< Certificate authentication */ 69 | QCLOUD_AUTH_MODE_DYNREG, /**< Dynamic authentication */ 70 | } esp_qcloud_auth_mode_t; 71 | 72 | typedef enum { 73 | QCLOUD_REPORT_EVENT_TYPE_INVALID = 0, /**< Invalid */ 74 | QCLOUD_REPORT_EVENT_TYPE_INFO, /**< Info */ 75 | QCLOUD_REPORT_EVENT_TYPE_ALERT, /**< Alert */ 76 | QCLOUD_REPORT_EVENT_TYPE_FAULT, /**< Fault */ 77 | } esp_qcloud_event_type_t; 78 | 79 | /** 80 | * @brief ESP QCloud Parameter Value type. 81 | */ 82 | typedef enum { 83 | QCLOUD_VAL_TYPE_INVALID = 0, /**< Invalid */ 84 | QCLOUD_VAL_TYPE_BOOLEAN, /**< Boolean */ 85 | QCLOUD_VAL_TYPE_INTEGER, /**< Integer. Mapped to a 32 bit signed integer */ 86 | QCLOUD_VAL_TYPE_FLOAT, /**< Floating point number */ 87 | QCLOUD_VAL_TYPE_STRING, /**< NULL terminated string */ 88 | QCLOUD_VAL_TYPE_STRUCT, /**< cJson */ 89 | QCLOUD_VAL_TYPE_ENUM, /**< Transmission as a integer */ 90 | QCLOUD_VAL_TYPE_TIME, /**< Transmission as a integer */ 91 | } esp_qcloud_param_val_type_t; 92 | 93 | /** 94 | * @brief ESP QCloud Value. 95 | */ 96 | typedef struct { 97 | esp_qcloud_param_val_type_t type; 98 | float f; /**< Float */ 99 | union { 100 | bool b; /**< Boolean */ 101 | int i; /**< Integer */ 102 | char *s; /**< NULL terminated string */ 103 | cJSON *obj;//Struct 104 | }; 105 | } esp_qcloud_param_val_t; 106 | 107 | /** 108 | * @brief Types of methods for reporting to the cloud 109 | * 110 | */ 111 | typedef enum { 112 | QCLOUD_METHOD_TYPE_INVALID = 0, /**< Invalid */ 113 | QCLOUD_METHOD_TYPE_EVENT, 114 | QCLOUD_METHOD_TYPE_ACTION_REPLY, 115 | QCLOUD_METHOD_TYPE_APP_BIND_TOKEN, 116 | QCLOUD_METHOD_TYPE_REPORT, 117 | QCLOUD_METHOD_TYPE_REPORT_INFO, 118 | QCLOUD_METHOD_TYPE_MAX_INVALID, 119 | } esp_qcloud_method_type_t; 120 | 121 | typedef struct esp_qcloud_param { 122 | const char *id; 123 | esp_qcloud_param_val_t value; 124 | SLIST_ENTRY(esp_qcloud_param) next; //!< next command in the list 125 | } esp_qcloud_param_t; 126 | 127 | typedef struct esp_qcloud_method_extra{ 128 | double timestamp; /**< Exist only in event_post and report*/ 129 | char *type; /**< Exist only in event_post*/ 130 | char *version; /**< Exist only in event_post*/ 131 | char *id; /**< Exist only in event_post*/ 132 | char *token; /**< Exist only in action_reply and control reply*/ 133 | uint32_t code; /**< Exist only in action_reply and control reply*/ 134 | }esp_qcloud_method_extra_val_t; 135 | 136 | typedef struct esp_qcloud_method { 137 | esp_qcloud_method_type_t method_type; 138 | esp_qcloud_method_extra_val_t *extra_val; 139 | SLIST_HEAD(method_param_list_, esp_qcloud_param) method_param_list; 140 | } esp_qcloud_method_t; 141 | 142 | /** 143 | * @brief Interface method. 144 | * 145 | */ 146 | typedef esp_err_t (*esp_qcloud_action_cb_t)(esp_qcloud_method_t *action_handle, char *params); 147 | 148 | typedef struct esp_qcloud_action { 149 | const char *id; 150 | esp_qcloud_action_cb_t action_cb; 151 | SLIST_ENTRY(esp_qcloud_action) next; //!< next command in the list 152 | } esp_qcloud_action_t; 153 | 154 | /** 155 | * @brief Interface method get_param. 156 | * 157 | */ 158 | typedef esp_err_t (*esp_qcloud_get_param_t)(const char *id, esp_qcloud_param_val_t *val); 159 | 160 | /** 161 | * @brief Interface method set_param. 162 | * 163 | */ 164 | typedef esp_err_t (*esp_qcloud_set_param_t)(const char *id, const esp_qcloud_param_val_t *val); 165 | 166 | /** 167 | * @brief Add device property callback function, set and get. 168 | * 169 | * @param[in] get_param_cb Get param interface. 170 | * @param[in] set_param_cb Set param interface. 171 | * @return 172 | * - ESP_OK: succeed 173 | * - others: fail 174 | */ 175 | esp_err_t esp_qcloud_device_add_property_cb(const esp_qcloud_get_param_t get_param_cb, 176 | const esp_qcloud_set_param_t set_param_cb); 177 | 178 | 179 | /** 180 | * @brief Add device action callback function. 181 | * 182 | * @param[in] action_id Parameter id. 183 | * @param[in] action_cb Callback 184 | * @return esp_err_t 185 | */ 186 | esp_err_t esp_qcloud_device_add_action_cb(const char *action_id, const esp_qcloud_action_cb_t action_cb); 187 | 188 | /** 189 | * @brief Create device. 190 | * 191 | * @note Need product id, device name, device key. 192 | * @return 193 | * - ESP_OK: succeed 194 | * - others: fail 195 | */ 196 | esp_err_t esp_qcloud_create_device(void); 197 | 198 | /** 199 | * @brief Add firmware version information. 200 | * 201 | * @param[in] version Current firmware version. 202 | * @return 203 | * - ESP_OK: succeed 204 | * - others: fail 205 | */ 206 | esp_err_t esp_qcloud_device_add_fw_version(const char *version); 207 | 208 | /** 209 | * @brief Get firmware version information. 210 | * 211 | * @return Pointer to firmware version. 212 | */ 213 | const char *esp_qcloud_get_version(void); 214 | 215 | /** 216 | * @brief Get device name. 217 | * 218 | * @return Pointer to device name. 219 | */ 220 | const char *esp_qcloud_get_device_name(void); 221 | 222 | /** 223 | * @brief Get product id. 224 | * 225 | * @return Pointer to product id. 226 | */ 227 | const char *esp_qcloud_get_product_id(void); 228 | 229 | /** 230 | * @brief Get authentication mode. 231 | * 232 | * @return Current authentication model. 233 | */ 234 | esp_qcloud_auth_mode_t esp_qcloud_get_auth_mode(void); 235 | 236 | /** 237 | * @brief Get device secret. 238 | * 239 | * @return Pointer to device secret. 240 | */ 241 | const char *esp_qcloud_get_device_secret(void); 242 | 243 | /** 244 | * @brief Get Certification. 245 | * 246 | * @return Pointer to certification. 247 | */ 248 | const char *esp_qcloud_get_cert_crt(void); 249 | 250 | /** 251 | * @brief Get private key. 252 | * 253 | * @return Pointer to private key. 254 | */ 255 | const char *esp_qcloud_get_private_key(void); 256 | 257 | /** 258 | * @brief Add properties to your device 259 | * 260 | * @note You need to register these properties on Qcloud, Ensure property identifier is correct. 261 | * 262 | * @param[in] id property identifier. 263 | * @param[in] type property type. 264 | * @return 265 | * - ESP_OK: succeed 266 | * - others: fail 267 | */ 268 | esp_err_t esp_qcloud_device_add_property(const char *id, esp_qcloud_param_val_type_t type); 269 | 270 | /** 271 | * @brief Set local properties. 272 | * 273 | * @note When a control message is received, the function will be called. 274 | * This is an internal function, You can not modify it. 275 | * You need to pass your function through esp_qcloud_device_add_property_cb. 276 | * 277 | * @param[in] request_params 278 | * @param[in] reply_data 279 | * @return 280 | * - ESP_OK: succeed 281 | * - others: fail 282 | */ 283 | esp_err_t esp_qcloud_handle_set_param(const cJSON *request_params, cJSON *reply_data); 284 | 285 | /** 286 | * @brief Get local properties. 287 | * 288 | * @note When a control message is received, the function will be called. 289 | * This is an internal function, You can not modify it. 290 | * You need to pass your function through esp_qcloud_device_add_property_cb. 291 | * 292 | * @param[in] request_data 293 | * @param[in] reply_data 294 | * @return 295 | * - ESP_OK: succeed 296 | * - others: fail 297 | */ 298 | esp_err_t esp_qcloud_handle_get_param(const cJSON *request_data, cJSON *reply_data); 299 | 300 | /** 301 | * @brief Initialize Qcloud and establish MQTT service. 302 | * 303 | * @return 304 | * - ESP_OK: succeed 305 | * - others: fail 306 | */ 307 | esp_err_t esp_qcloud_iothub_init(void); 308 | 309 | /** 310 | * @brief Run Qcloud service and register related parameters. 311 | * 312 | * @return 313 | * - ESP_OK: succeed 314 | * - others: fail 315 | */ 316 | esp_err_t esp_qcloud_iothub_start(void); 317 | 318 | /** 319 | * @brief Stop Qcloud service and release related resources. 320 | * 321 | * @return 322 | * - ESP_OK: succeed 323 | * - others: fail 324 | */ 325 | esp_err_t esp_qcloud_iothub_stop(void); 326 | 327 | /** 328 | * @brief Use token to bind with Qcloud. 329 | * 330 | * @note If the blocking option is selected, the function will wait for the binding result 331 | * returned by the cloud platform. You can also listen to the event to get the result. 332 | * 333 | * @param[in] token Token comes from WeChat applet. 334 | * @param[in] block Blocking option 335 | * @return 336 | * - ESP_OK: succeed 337 | * - others: fail 338 | */ 339 | esp_err_t esp_qcloud_iothub_bind(const char *token, bool block); 340 | 341 | /** 342 | * @brief Get the latest status of the QCloud 343 | * 344 | * @param[in] type Message type 345 | * @param[in] auto_update When the status is obtained, whether to automatically call the set function. 346 | * @return 347 | * - ESP_OK: succeed 348 | * - others: fail 349 | */ 350 | esp_err_t esp_qcloud_iothub_get_status(esp_qcloud_method_type_t type, bool auto_update); 351 | 352 | /** 353 | * @brief Report device information. 354 | * 355 | * @return 356 | * - ESP_OK: succeed 357 | * - others: fail 358 | */ 359 | esp_err_t esp_qcloud_iothub_report_device_info(void); 360 | 361 | /** 362 | * @brief Report all property. 363 | * 364 | * @return 365 | * - ESP_OK: succeed 366 | * - others: fail 367 | */ 368 | esp_err_t esp_qcloud_iothub_report_all_property(void); 369 | 370 | /** 371 | * @brief Get Qcloud service status. 372 | * 373 | * @return true Connect 374 | * @return false Disconnect 375 | */ 376 | bool esp_qcloud_iothub_is_connected(void); 377 | 378 | /** 379 | * @brief Enable OTA 380 | * 381 | * @note Calling this API enables OTA as per the ESP QCloud specification. 382 | * Please check the various ESP QCloud configuration options to 383 | * use the different variants of OTA. Refer the documentation for 384 | * additional details. 385 | * 386 | * @return 387 | * - ESP_OK: succeed 388 | * - others: fail 389 | */ 390 | esp_err_t esp_qcloud_iothub_ota_enable(void); 391 | 392 | /** 393 | * @brief Add int type data to the handle method. 394 | * 395 | * @param[in] method Method handle. 396 | * @param[in] id Parameter id. 397 | * @param[in] value Parameter value. 398 | * @return 399 | * - ESP_OK: succeed 400 | * - others: fail 401 | */ 402 | esp_err_t esp_qcloud_iothub_param_add_int(esp_qcloud_method_t *method, char *id, int value); 403 | 404 | /** 405 | * @brief Add float type data to the handle method. 406 | * 407 | * @param[in] method Method handle. 408 | * @param[in] id Parameter id. 409 | * @param[in] value Parameter value. 410 | * @return 411 | * - ESP_OK: succeed 412 | * - others: fail 413 | */ 414 | esp_err_t esp_qcloud_iothub_param_add_float(esp_qcloud_method_t *method, char *id, float value); 415 | 416 | /** 417 | * @brief Add char type data to the handle method. 418 | * 419 | * @param[in] method Method handle. 420 | * @param[in] id Parameter id. 421 | * @param[in] value Parameter value. 422 | * @return 423 | * - ESP_OK: succeed 424 | * - others: fail 425 | */ 426 | esp_err_t esp_qcloud_iothub_param_add_string(esp_qcloud_method_t *method, char *id, char *value); 427 | 428 | /** 429 | * @brief Add bool type data to the handle method. 430 | * 431 | * @param[in] method Method handle. 432 | * @param[in] id Parameter id. 433 | * @param[in] value Parameter value. 434 | * @return 435 | * - ESP_OK: succeed 436 | * - others: fail 437 | */ 438 | esp_err_t esp_qcloud_iothub_param_add_bool(esp_qcloud_method_t *method, char *id, bool value); 439 | 440 | /** 441 | * @brief Create a report handle. 442 | * 443 | * @return Pointer to the report handle. 444 | */ 445 | esp_qcloud_method_t *esp_qcloud_iothub_create_report(void); 446 | 447 | /** 448 | * @brief Create a event handle. 449 | * 450 | * @param[in] eventId Parameter id. 451 | * @param[in] type Event type 452 | * @return Pointer to the event handle. 453 | */ 454 | esp_qcloud_method_t *esp_qcloud_iothub_create_event(const char *eventId, esp_qcloud_event_type_t type); 455 | 456 | /** 457 | * @brief Create a action handle. 458 | * 459 | * @return Pointer to the report handle. 460 | */ 461 | esp_qcloud_method_t *esp_qcloud_iothub_create_action(void); 462 | 463 | /** 464 | * @brief Destroy the handle by report. 465 | * 466 | * @param[in] report Method handle. 467 | * @return 468 | * - ESP_OK: succeed 469 | * - others: fail 470 | */ 471 | esp_err_t esp_qcloud_iothub_destroy_report(esp_qcloud_method_t *report); 472 | 473 | /** 474 | * @brief Destroy the handle by event. 475 | * 476 | * @param[in] event Method handle. 477 | * @return 478 | * - ESP_OK: succeed 479 | * - others: fail 480 | */ 481 | esp_err_t esp_qcloud_iothub_destroy_event(esp_qcloud_method_t *event); 482 | 483 | /** 484 | * @brief Destroy the handle by action. 485 | * 486 | * @param[in] event Method handle. 487 | * @return 488 | * - ESP_OK: succeed 489 | * - others: fail 490 | */ 491 | esp_err_t esp_qcloud_iothub_destroy_action(esp_qcloud_method_t *action); 492 | 493 | /** 494 | * @brief Post handle data to QCloud. 495 | * 496 | * @param[in] method Method handle. 497 | * @return 498 | * - ESP_OK: succeed 499 | * - others: fail 500 | */ 501 | esp_err_t esp_qcloud_iothub_post_method(esp_qcloud_method_t *method); 502 | 503 | /** 504 | * @brief The device executes actions from the cloud. 505 | * 506 | * @param[in] action_handle Method handle. 507 | * @param[in] action_id Parameter id. 508 | * @param[in] params Downstream parameters 509 | * @return 510 | * - ESP_OK: succeed 511 | * - others: fail 512 | */ 513 | esp_err_t esp_qcloud_operate_action(esp_qcloud_method_t *action_handle, const char *action_id, char *params); 514 | 515 | #ifdef __cplusplus 516 | } 517 | #endif 518 | -------------------------------------------------------------------------------- /app/bt_discovery/sdkconfig: -------------------------------------------------------------------------------- 1 | # 2 | # Automatically generated file; DO NOT EDIT. 3 | # Espressif IoT Development Framework Configuration 4 | # 5 | CONFIG_IDF_TARGET="esp32" 6 | 7 | # 8 | # SDK tool configuration 9 | # 10 | CONFIG_TOOLPREFIX="xtensa-esp32-elf-" 11 | CONFIG_PYTHON="python" 12 | CONFIG_MAKE_WARN_UNDEFINED_VARIABLES=y 13 | 14 | # 15 | # Application manager 16 | # 17 | CONFIG_APP_COMPILE_TIME_DATE=y 18 | CONFIG_APP_EXCLUDE_PROJECT_VER_VAR= 19 | CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR= 20 | 21 | # 22 | # Bootloader config 23 | # 24 | CONFIG_LOG_BOOTLOADER_LEVEL_NONE= 25 | CONFIG_LOG_BOOTLOADER_LEVEL_ERROR= 26 | CONFIG_LOG_BOOTLOADER_LEVEL_WARN= 27 | CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y 28 | CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG= 29 | CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE= 30 | CONFIG_LOG_BOOTLOADER_LEVEL=3 31 | CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_8V= 32 | CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V=y 33 | CONFIG_BOOTLOADER_FACTORY_RESET= 34 | CONFIG_BOOTLOADER_APP_TEST= 35 | CONFIG_BOOTLOADER_WDT_ENABLE=y 36 | CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE= 37 | CONFIG_BOOTLOADER_WDT_TIME_MS=9000 38 | CONFIG_APP_ROLLBACK_ENABLE= 39 | 40 | # 41 | # Security features 42 | # 43 | CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT= 44 | CONFIG_SECURE_BOOT_ENABLED= 45 | CONFIG_FLASH_ENCRYPTION_ENABLED= 46 | 47 | # 48 | # Serial flasher config 49 | # 50 | CONFIG_ESPTOOLPY_PORT="/dev/ttyUSB0" 51 | CONFIG_ESPTOOLPY_BAUD_115200B=y 52 | CONFIG_ESPTOOLPY_BAUD_230400B= 53 | CONFIG_ESPTOOLPY_BAUD_921600B= 54 | CONFIG_ESPTOOLPY_BAUD_2MB= 55 | CONFIG_ESPTOOLPY_BAUD_OTHER= 56 | CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 57 | CONFIG_ESPTOOLPY_BAUD=115200 58 | CONFIG_ESPTOOLPY_COMPRESSED=y 59 | CONFIG_FLASHMODE_QIO= 60 | CONFIG_FLASHMODE_QOUT= 61 | CONFIG_FLASHMODE_DIO=y 62 | CONFIG_FLASHMODE_DOUT= 63 | CONFIG_ESPTOOLPY_FLASHMODE="dio" 64 | CONFIG_ESPTOOLPY_FLASHFREQ_80M= 65 | CONFIG_ESPTOOLPY_FLASHFREQ_40M=y 66 | CONFIG_ESPTOOLPY_FLASHFREQ_26M= 67 | CONFIG_ESPTOOLPY_FLASHFREQ_20M= 68 | CONFIG_ESPTOOLPY_FLASHFREQ="40m" 69 | CONFIG_ESPTOOLPY_FLASHSIZE_1MB= 70 | CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y 71 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB= 72 | CONFIG_ESPTOOLPY_FLASHSIZE_8MB= 73 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB= 74 | CONFIG_ESPTOOLPY_FLASHSIZE="2MB" 75 | CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y 76 | CONFIG_ESPTOOLPY_BEFORE_RESET=y 77 | CONFIG_ESPTOOLPY_BEFORE_NORESET= 78 | CONFIG_ESPTOOLPY_BEFORE="default_reset" 79 | CONFIG_ESPTOOLPY_AFTER_RESET=y 80 | CONFIG_ESPTOOLPY_AFTER_NORESET= 81 | CONFIG_ESPTOOLPY_AFTER="hard_reset" 82 | CONFIG_MONITOR_BAUD_9600B= 83 | CONFIG_MONITOR_BAUD_57600B= 84 | CONFIG_MONITOR_BAUD_115200B=y 85 | CONFIG_MONITOR_BAUD_230400B= 86 | CONFIG_MONITOR_BAUD_921600B= 87 | CONFIG_MONITOR_BAUD_2MB= 88 | CONFIG_MONITOR_BAUD_OTHER= 89 | CONFIG_MONITOR_BAUD_OTHER_VAL=115200 90 | CONFIG_MONITOR_BAUD=115200 91 | 92 | # 93 | # Partition Table 94 | # 95 | CONFIG_PARTITION_TABLE_SINGLE_APP=y 96 | CONFIG_PARTITION_TABLE_TWO_OTA= 97 | CONFIG_PARTITION_TABLE_CUSTOM= 98 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 99 | CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv" 100 | CONFIG_PARTITION_TABLE_OFFSET=0x8000 101 | CONFIG_PARTITION_TABLE_MD5=y 102 | 103 | # 104 | # Compiler options 105 | # 106 | CONFIG_OPTIMIZATION_LEVEL_DEBUG=y 107 | CONFIG_OPTIMIZATION_LEVEL_RELEASE= 108 | CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y 109 | CONFIG_OPTIMIZATION_ASSERTIONS_SILENT= 110 | CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED= 111 | CONFIG_CXX_EXCEPTIONS= 112 | CONFIG_STACK_CHECK_NONE=y 113 | CONFIG_STACK_CHECK_NORM= 114 | CONFIG_STACK_CHECK_STRONG= 115 | CONFIG_STACK_CHECK_ALL= 116 | CONFIG_STACK_CHECK= 117 | CONFIG_WARN_WRITE_STRINGS= 118 | CONFIG_DISABLE_GCC8_WARNINGS= 119 | 120 | # 121 | # Component config 122 | # 123 | 124 | # 125 | # Application Level Tracing 126 | # 127 | CONFIG_ESP32_APPTRACE_DEST_TRAX= 128 | CONFIG_ESP32_APPTRACE_DEST_NONE=y 129 | CONFIG_ESP32_APPTRACE_ENABLE= 130 | CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y 131 | CONFIG_AWS_IOT_SDK= 132 | 133 | # 134 | # Bluetooth 135 | # 136 | CONFIG_BT_ENABLED=y 137 | 138 | # 139 | # Bluetooth controller 140 | # 141 | CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY= 142 | CONFIG_BTDM_CONTROLLER_MODE_BR_EDR_ONLY=y 143 | CONFIG_BTDM_CONTROLLER_MODE_BTDM= 144 | CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN=2 145 | CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN=0 146 | CONFIG_BTDM_CONTROLLER_BLE_MAX_CONN_EFF=0 147 | CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_ACL_CONN_EFF=2 148 | CONFIG_BTDM_CONTROLLER_BR_EDR_MAX_SYNC_CONN_EFF=0 149 | CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE_0=y 150 | CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE_1= 151 | CONFIG_BTDM_CONTROLLER_PINNED_TO_CORE=0 152 | CONFIG_BTDM_CONTROLLER_HCI_MODE_VHCI=y 153 | CONFIG_BTDM_CONTROLLER_HCI_MODE_UART_H4= 154 | 155 | # 156 | # MODEM SLEEP Options 157 | # 158 | CONFIG_BTDM_CONTROLLER_MODEM_SLEEP=y 159 | CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG=y 160 | CONFIG_BTDM_MODEM_SLEEP_MODE_EVED= 161 | CONFIG_BTDM_LPCLK_SEL_MAIN_XTAL=y 162 | CONFIG_BLUEDROID_ENABLED=y 163 | CONFIG_BLUEDROID_PINNED_TO_CORE_0=y 164 | CONFIG_BLUEDROID_PINNED_TO_CORE_1= 165 | CONFIG_BLUEDROID_PINNED_TO_CORE=0 166 | CONFIG_BTC_TASK_STACK_SIZE=3072 167 | CONFIG_BLUEDROID_MEM_DEBUG= 168 | CONFIG_CLASSIC_BT_ENABLED=y 169 | CONFIG_A2DP_ENABLE= 170 | CONFIG_BT_SPP_ENABLED= 171 | CONFIG_HFP_ENABLE= 172 | CONFIG_BT_SSP_ENABLED=y 173 | CONFIG_BT_STACK_NO_LOG= 174 | 175 | # 176 | # BT DEBUG LOG LEVEL 177 | # 178 | CONFIG_HCI_TRACE_LEVEL_NONE= 179 | CONFIG_HCI_TRACE_LEVEL_ERROR= 180 | CONFIG_HCI_TRACE_LEVEL_WARNING=y 181 | CONFIG_HCI_TRACE_LEVEL_API= 182 | CONFIG_HCI_TRACE_LEVEL_EVENT= 183 | CONFIG_HCI_TRACE_LEVEL_DEBUG= 184 | CONFIG_HCI_TRACE_LEVEL_VERBOSE= 185 | CONFIG_HCI_INITIAL_TRACE_LEVEL=2 186 | CONFIG_BTM_TRACE_LEVEL_NONE= 187 | CONFIG_BTM_TRACE_LEVEL_ERROR= 188 | CONFIG_BTM_TRACE_LEVEL_WARNING=y 189 | CONFIG_BTM_TRACE_LEVEL_API= 190 | CONFIG_BTM_TRACE_LEVEL_EVENT= 191 | CONFIG_BTM_TRACE_LEVEL_DEBUG= 192 | CONFIG_BTM_TRACE_LEVEL_VERBOSE= 193 | CONFIG_BTM_INITIAL_TRACE_LEVEL=2 194 | CONFIG_L2CAP_TRACE_LEVEL_NONE= 195 | CONFIG_L2CAP_TRACE_LEVEL_ERROR= 196 | CONFIG_L2CAP_TRACE_LEVEL_WARNING=y 197 | CONFIG_L2CAP_TRACE_LEVEL_API= 198 | CONFIG_L2CAP_TRACE_LEVEL_EVENT= 199 | CONFIG_L2CAP_TRACE_LEVEL_DEBUG= 200 | CONFIG_L2CAP_TRACE_LEVEL_VERBOSE= 201 | CONFIG_L2CAP_INITIAL_TRACE_LEVEL=2 202 | CONFIG_RFCOMM_TRACE_LEVEL_NONE= 203 | CONFIG_RFCOMM_TRACE_LEVEL_ERROR= 204 | CONFIG_RFCOMM_TRACE_LEVEL_WARNING=y 205 | CONFIG_RFCOMM_TRACE_LEVEL_API= 206 | CONFIG_RFCOMM_TRACE_LEVEL_EVENT= 207 | CONFIG_RFCOMM_TRACE_LEVEL_DEBUG= 208 | CONFIG_RFCOMM_TRACE_LEVEL_VERBOSE= 209 | CONFIG_RFCOMM_INITIAL_TRACE_LEVEL=2 210 | CONFIG_SDP_TRACE_LEVEL_NONE= 211 | CONFIG_SDP_TRACE_LEVEL_ERROR= 212 | CONFIG_SDP_TRACE_LEVEL_WARNING=y 213 | CONFIG_SDP_TRACE_LEVEL_API= 214 | CONFIG_SDP_TRACE_LEVEL_EVENT= 215 | CONFIG_SDP_TRACE_LEVEL_DEBUG= 216 | CONFIG_SDP_TRACE_LEVEL_VERBOSE= 217 | CONFIG_SDP_INITIAL_TRACE_LEVEL=2 218 | CONFIG_GAP_TRACE_LEVEL_NONE= 219 | CONFIG_GAP_TRACE_LEVEL_ERROR= 220 | CONFIG_GAP_TRACE_LEVEL_WARNING=y 221 | CONFIG_GAP_TRACE_LEVEL_API= 222 | CONFIG_GAP_TRACE_LEVEL_EVENT= 223 | CONFIG_GAP_TRACE_LEVEL_DEBUG= 224 | CONFIG_GAP_TRACE_LEVEL_VERBOSE= 225 | CONFIG_GAP_INITIAL_TRACE_LEVEL=2 226 | CONFIG_BNEP_TRACE_LEVEL_NONE= 227 | CONFIG_BNEP_TRACE_LEVEL_ERROR= 228 | CONFIG_BNEP_TRACE_LEVEL_WARNING=y 229 | CONFIG_BNEP_TRACE_LEVEL_API= 230 | CONFIG_BNEP_TRACE_LEVEL_EVENT= 231 | CONFIG_BNEP_TRACE_LEVEL_DEBUG= 232 | CONFIG_BNEP_TRACE_LEVEL_VERBOSE= 233 | CONFIG_BNEP_INITIAL_TRACE_LEVEL=2 234 | CONFIG_PAN_TRACE_LEVEL_NONE= 235 | CONFIG_PAN_TRACE_LEVEL_ERROR= 236 | CONFIG_PAN_TRACE_LEVEL_WARNING=y 237 | CONFIG_PAN_TRACE_LEVEL_API= 238 | CONFIG_PAN_TRACE_LEVEL_EVENT= 239 | CONFIG_PAN_TRACE_LEVEL_DEBUG= 240 | CONFIG_PAN_TRACE_LEVEL_VERBOSE= 241 | CONFIG_PAN_INITIAL_TRACE_LEVEL=2 242 | CONFIG_A2D_TRACE_LEVEL_NONE= 243 | CONFIG_A2D_TRACE_LEVEL_ERROR= 244 | CONFIG_A2D_TRACE_LEVEL_WARNING=y 245 | CONFIG_A2D_TRACE_LEVEL_API= 246 | CONFIG_A2D_TRACE_LEVEL_EVENT= 247 | CONFIG_A2D_TRACE_LEVEL_DEBUG= 248 | CONFIG_A2D_TRACE_LEVEL_VERBOSE= 249 | CONFIG_A2D_INITIAL_TRACE_LEVEL=2 250 | CONFIG_AVDT_TRACE_LEVEL_NONE= 251 | CONFIG_AVDT_TRACE_LEVEL_ERROR= 252 | CONFIG_AVDT_TRACE_LEVEL_WARNING=y 253 | CONFIG_AVDT_TRACE_LEVEL_API= 254 | CONFIG_AVDT_TRACE_LEVEL_EVENT= 255 | CONFIG_AVDT_TRACE_LEVEL_DEBUG= 256 | CONFIG_AVDT_TRACE_LEVEL_VERBOSE= 257 | CONFIG_AVDT_INITIAL_TRACE_LEVEL=2 258 | CONFIG_AVCT_TRACE_LEVEL_NONE= 259 | CONFIG_AVCT_TRACE_LEVEL_ERROR= 260 | CONFIG_AVCT_TRACE_LEVEL_WARNING=y 261 | CONFIG_AVCT_TRACE_LEVEL_API= 262 | CONFIG_AVCT_TRACE_LEVEL_EVENT= 263 | CONFIG_AVCT_TRACE_LEVEL_DEBUG= 264 | CONFIG_AVCT_TRACE_LEVEL_VERBOSE= 265 | CONFIG_AVCT_INITIAL_TRACE_LEVEL=2 266 | CONFIG_AVRC_TRACE_LEVEL_NONE= 267 | CONFIG_AVRC_TRACE_LEVEL_ERROR= 268 | CONFIG_AVRC_TRACE_LEVEL_WARNING=y 269 | CONFIG_AVRC_TRACE_LEVEL_API= 270 | CONFIG_AVRC_TRACE_LEVEL_EVENT= 271 | CONFIG_AVRC_TRACE_LEVEL_DEBUG= 272 | CONFIG_AVRC_TRACE_LEVEL_VERBOSE= 273 | CONFIG_AVRC_INITIAL_TRACE_LEVEL=2 274 | CONFIG_MCA_TRACE_LEVEL_NONE= 275 | CONFIG_MCA_TRACE_LEVEL_ERROR= 276 | CONFIG_MCA_TRACE_LEVEL_WARNING=y 277 | CONFIG_MCA_TRACE_LEVEL_API= 278 | CONFIG_MCA_TRACE_LEVEL_EVENT= 279 | CONFIG_MCA_TRACE_LEVEL_DEBUG= 280 | CONFIG_MCA_TRACE_LEVEL_VERBOSE= 281 | CONFIG_MCA_INITIAL_TRACE_LEVEL=2 282 | CONFIG_HID_TRACE_LEVEL_NONE= 283 | CONFIG_HID_TRACE_LEVEL_ERROR= 284 | CONFIG_HID_TRACE_LEVEL_WARNING=y 285 | CONFIG_HID_TRACE_LEVEL_API= 286 | CONFIG_HID_TRACE_LEVEL_EVENT= 287 | CONFIG_HID_TRACE_LEVEL_DEBUG= 288 | CONFIG_HID_TRACE_LEVEL_VERBOSE= 289 | CONFIG_HID_INITIAL_TRACE_LEVEL=2 290 | CONFIG_APPL_TRACE_LEVEL_NONE= 291 | CONFIG_APPL_TRACE_LEVEL_ERROR= 292 | CONFIG_APPL_TRACE_LEVEL_WARNING=y 293 | CONFIG_APPL_TRACE_LEVEL_API= 294 | CONFIG_APPL_TRACE_LEVEL_EVENT= 295 | CONFIG_APPL_TRACE_LEVEL_DEBUG= 296 | CONFIG_APPL_TRACE_LEVEL_VERBOSE= 297 | CONFIG_APPL_INITIAL_TRACE_LEVEL=2 298 | CONFIG_GATT_TRACE_LEVEL_NONE= 299 | CONFIG_GATT_TRACE_LEVEL_ERROR= 300 | CONFIG_GATT_TRACE_LEVEL_WARNING=y 301 | CONFIG_GATT_TRACE_LEVEL_API= 302 | CONFIG_GATT_TRACE_LEVEL_EVENT= 303 | CONFIG_GATT_TRACE_LEVEL_DEBUG= 304 | CONFIG_GATT_TRACE_LEVEL_VERBOSE= 305 | CONFIG_GATT_INITIAL_TRACE_LEVEL=2 306 | CONFIG_SMP_TRACE_LEVEL_NONE= 307 | CONFIG_SMP_TRACE_LEVEL_ERROR= 308 | CONFIG_SMP_TRACE_LEVEL_WARNING=y 309 | CONFIG_SMP_TRACE_LEVEL_API= 310 | CONFIG_SMP_TRACE_LEVEL_EVENT= 311 | CONFIG_SMP_TRACE_LEVEL_DEBUG= 312 | CONFIG_SMP_TRACE_LEVEL_VERBOSE= 313 | CONFIG_SMP_INITIAL_TRACE_LEVEL=2 314 | CONFIG_BTIF_TRACE_LEVEL_NONE= 315 | CONFIG_BTIF_TRACE_LEVEL_ERROR= 316 | CONFIG_BTIF_TRACE_LEVEL_WARNING=y 317 | CONFIG_BTIF_TRACE_LEVEL_API= 318 | CONFIG_BTIF_TRACE_LEVEL_EVENT= 319 | CONFIG_BTIF_TRACE_LEVEL_DEBUG= 320 | CONFIG_BTIF_TRACE_LEVEL_VERBOSE= 321 | CONFIG_BTIF_INITIAL_TRACE_LEVEL=2 322 | CONFIG_BTC_TRACE_LEVEL_NONE= 323 | CONFIG_BTC_TRACE_LEVEL_ERROR= 324 | CONFIG_BTC_TRACE_LEVEL_WARNING=y 325 | CONFIG_BTC_TRACE_LEVEL_API= 326 | CONFIG_BTC_TRACE_LEVEL_EVENT= 327 | CONFIG_BTC_TRACE_LEVEL_DEBUG= 328 | CONFIG_BTC_TRACE_LEVEL_VERBOSE= 329 | CONFIG_BTC_INITIAL_TRACE_LEVEL=2 330 | CONFIG_OSI_TRACE_LEVEL_NONE= 331 | CONFIG_OSI_TRACE_LEVEL_ERROR= 332 | CONFIG_OSI_TRACE_LEVEL_WARNING=y 333 | CONFIG_OSI_TRACE_LEVEL_API= 334 | CONFIG_OSI_TRACE_LEVEL_EVENT= 335 | CONFIG_OSI_TRACE_LEVEL_DEBUG= 336 | CONFIG_OSI_TRACE_LEVEL_VERBOSE= 337 | CONFIG_OSI_INITIAL_TRACE_LEVEL=2 338 | CONFIG_BLUFI_TRACE_LEVEL_NONE= 339 | CONFIG_BLUFI_TRACE_LEVEL_ERROR= 340 | CONFIG_BLUFI_TRACE_LEVEL_WARNING=y 341 | CONFIG_BLUFI_TRACE_LEVEL_API= 342 | CONFIG_BLUFI_TRACE_LEVEL_EVENT= 343 | CONFIG_BLUFI_TRACE_LEVEL_DEBUG= 344 | CONFIG_BLUFI_TRACE_LEVEL_VERBOSE= 345 | CONFIG_BLUFI_INITIAL_TRACE_LEVEL=2 346 | CONFIG_BT_ACL_CONNECTIONS=4 347 | CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST= 348 | CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY= 349 | CONFIG_BLE_HOST_QUEUE_CONGESTION_CHECK= 350 | CONFIG_SMP_ENABLE=y 351 | CONFIG_BT_RESERVE_DRAM=0xdb5c 352 | 353 | # 354 | # Driver configurations 355 | # 356 | 357 | # 358 | # ADC configuration 359 | # 360 | CONFIG_ADC_FORCE_XPD_FSM= 361 | CONFIG_ADC2_DISABLE_DAC=y 362 | 363 | # 364 | # SPI configuration 365 | # 366 | CONFIG_SPI_MASTER_IN_IRAM= 367 | CONFIG_SPI_MASTER_ISR_IN_IRAM=y 368 | CONFIG_SPI_SLAVE_IN_IRAM= 369 | CONFIG_SPI_SLAVE_ISR_IN_IRAM=y 370 | 371 | # 372 | # ESP32-specific 373 | # 374 | CONFIG_IDF_TARGET_ESP32=y 375 | CONFIG_ESP32_DEFAULT_CPU_FREQ_80= 376 | CONFIG_ESP32_DEFAULT_CPU_FREQ_160=y 377 | CONFIG_ESP32_DEFAULT_CPU_FREQ_240= 378 | CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=160 379 | CONFIG_SPIRAM_SUPPORT= 380 | CONFIG_MEMMAP_TRACEMEM= 381 | CONFIG_MEMMAP_TRACEMEM_TWOBANKS= 382 | CONFIG_ESP32_TRAX= 383 | CONFIG_TRACEMEM_RESERVE_DRAM=0x0 384 | 385 | # 386 | # Core dump 387 | # 388 | CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH= 389 | CONFIG_ESP32_ENABLE_COREDUMP_TO_UART= 390 | CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y 391 | CONFIG_ESP32_ENABLE_COREDUMP= 392 | CONFIG_TWO_UNIVERSAL_MAC_ADDRESS= 393 | CONFIG_FOUR_UNIVERSAL_MAC_ADDRESS=y 394 | CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS=4 395 | CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 396 | CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304 397 | CONFIG_MAIN_TASK_STACK_SIZE=3584 398 | CONFIG_IPC_TASK_STACK_SIZE=1024 399 | CONFIG_TIMER_TASK_STACK_SIZE=3584 400 | CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y 401 | CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF= 402 | CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR= 403 | CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF= 404 | CONFIG_NEWLIB_STDIN_LINE_ENDING_LF= 405 | CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y 406 | CONFIG_NEWLIB_NANO_FORMAT= 407 | CONFIG_CONSOLE_UART_DEFAULT=y 408 | CONFIG_CONSOLE_UART_CUSTOM= 409 | CONFIG_CONSOLE_UART_NONE= 410 | CONFIG_CONSOLE_UART_NUM=0 411 | CONFIG_CONSOLE_UART_BAUDRATE=115200 412 | CONFIG_ULP_COPROC_ENABLED= 413 | CONFIG_ULP_COPROC_RESERVE_MEM=0 414 | CONFIG_ESP32_PANIC_PRINT_HALT= 415 | CONFIG_ESP32_PANIC_PRINT_REBOOT=y 416 | CONFIG_ESP32_PANIC_SILENT_REBOOT= 417 | CONFIG_ESP32_PANIC_GDBSTUB= 418 | CONFIG_ESP32_DEBUG_OCDAWARE=y 419 | CONFIG_ESP32_DEBUG_STUBS_ENABLE=y 420 | CONFIG_INT_WDT=y 421 | CONFIG_INT_WDT_TIMEOUT_MS=300 422 | CONFIG_INT_WDT_CHECK_CPU1=y 423 | CONFIG_TASK_WDT=y 424 | CONFIG_TASK_WDT_PANIC= 425 | CONFIG_TASK_WDT_TIMEOUT_S=5 426 | CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y 427 | CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=y 428 | CONFIG_BROWNOUT_DET=y 429 | CONFIG_BROWNOUT_DET_LVL_SEL_0=y 430 | CONFIG_BROWNOUT_DET_LVL_SEL_1= 431 | CONFIG_BROWNOUT_DET_LVL_SEL_2= 432 | CONFIG_BROWNOUT_DET_LVL_SEL_3= 433 | CONFIG_BROWNOUT_DET_LVL_SEL_4= 434 | CONFIG_BROWNOUT_DET_LVL_SEL_5= 435 | CONFIG_BROWNOUT_DET_LVL_SEL_6= 436 | CONFIG_BROWNOUT_DET_LVL_SEL_7= 437 | CONFIG_BROWNOUT_DET_LVL=0 438 | CONFIG_REDUCE_PHY_TX_POWER=y 439 | CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y 440 | CONFIG_ESP32_TIME_SYSCALL_USE_RTC= 441 | CONFIG_ESP32_TIME_SYSCALL_USE_FRC1= 442 | CONFIG_ESP32_TIME_SYSCALL_USE_NONE= 443 | CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC=y 444 | CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL= 445 | CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_OSC= 446 | CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_8MD256= 447 | CONFIG_ESP32_RTC_CLK_CAL_CYCLES=1024 448 | CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=2000 449 | CONFIG_ESP32_XTAL_FREQ_40=y 450 | CONFIG_ESP32_XTAL_FREQ_26= 451 | CONFIG_ESP32_XTAL_FREQ_AUTO= 452 | CONFIG_ESP32_XTAL_FREQ=40 453 | CONFIG_DISABLE_BASIC_ROM_CONSOLE= 454 | CONFIG_ESP_TIMER_PROFILING= 455 | CONFIG_COMPATIBLE_PRE_V2_1_BOOTLOADERS= 456 | CONFIG_ESP_ERR_TO_NAME_LOOKUP=y 457 | 458 | # 459 | # Wi-Fi 460 | # 461 | CONFIG_SW_COEXIST_ENABLE=y 462 | CONFIG_SW_COEXIST_PREFERENCE_WIFI= 463 | CONFIG_SW_COEXIST_PREFERENCE_BT= 464 | CONFIG_SW_COEXIST_PREFERENCE_BALANCE=y 465 | CONFIG_SW_COEXIST_PREFERENCE_VALUE=2 466 | CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 467 | CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 468 | CONFIG_ESP32_WIFI_STATIC_TX_BUFFER= 469 | CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y 470 | CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 471 | CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 472 | CONFIG_ESP32_WIFI_CSI_ENABLED= 473 | CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y 474 | CONFIG_ESP32_WIFI_TX_BA_WIN=6 475 | CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y 476 | CONFIG_ESP32_WIFI_RX_BA_WIN=6 477 | CONFIG_ESP32_WIFI_NVS_ENABLED=y 478 | CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y 479 | CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1= 480 | CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 481 | CONFIG_ESP32_WIFI_DEBUG_LOG_ENABLE= 482 | 483 | # 484 | # PHY 485 | # 486 | CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y 487 | CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION= 488 | CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 489 | CONFIG_ESP32_PHY_MAX_TX_POWER=20 490 | 491 | # 492 | # Power Management 493 | # 494 | CONFIG_PM_ENABLE= 495 | 496 | # 497 | # ADC-Calibration 498 | # 499 | CONFIG_ADC_CAL_EFUSE_TP_ENABLE=y 500 | CONFIG_ADC_CAL_EFUSE_VREF_ENABLE=y 501 | CONFIG_ADC_CAL_LUT_ENABLE=y 502 | 503 | # 504 | # Event Loop Library 505 | # 506 | CONFIG_EVENT_LOOP_PROFILING= 507 | 508 | # 509 | # ESP HTTP client 510 | # 511 | CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y 512 | 513 | # 514 | # HTTP Server 515 | # 516 | CONFIG_HTTPD_MAX_REQ_HDR_LEN=512 517 | CONFIG_HTTPD_MAX_URI_LEN=512 518 | 519 | # 520 | # Ethernet 521 | # 522 | CONFIG_DMA_RX_BUF_NUM=10 523 | CONFIG_DMA_TX_BUF_NUM=10 524 | CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE=y 525 | CONFIG_EMAC_CHECK_LINK_PERIOD_MS=2000 526 | CONFIG_EMAC_TASK_PRIORITY=20 527 | CONFIG_EMAC_TASK_STACK_SIZE=3072 528 | 529 | # 530 | # FAT Filesystem support 531 | # 532 | CONFIG_FATFS_CODEPAGE_DYNAMIC= 533 | CONFIG_FATFS_CODEPAGE_437=y 534 | CONFIG_FATFS_CODEPAGE_720= 535 | CONFIG_FATFS_CODEPAGE_737= 536 | CONFIG_FATFS_CODEPAGE_771= 537 | CONFIG_FATFS_CODEPAGE_775= 538 | CONFIG_FATFS_CODEPAGE_850= 539 | CONFIG_FATFS_CODEPAGE_852= 540 | CONFIG_FATFS_CODEPAGE_855= 541 | CONFIG_FATFS_CODEPAGE_857= 542 | CONFIG_FATFS_CODEPAGE_860= 543 | CONFIG_FATFS_CODEPAGE_861= 544 | CONFIG_FATFS_CODEPAGE_862= 545 | CONFIG_FATFS_CODEPAGE_863= 546 | CONFIG_FATFS_CODEPAGE_864= 547 | CONFIG_FATFS_CODEPAGE_865= 548 | CONFIG_FATFS_CODEPAGE_866= 549 | CONFIG_FATFS_CODEPAGE_869= 550 | CONFIG_FATFS_CODEPAGE_932= 551 | CONFIG_FATFS_CODEPAGE_936= 552 | CONFIG_FATFS_CODEPAGE_949= 553 | CONFIG_FATFS_CODEPAGE_950= 554 | CONFIG_FATFS_CODEPAGE=437 555 | CONFIG_FATFS_LFN_NONE=y 556 | CONFIG_FATFS_LFN_HEAP= 557 | CONFIG_FATFS_LFN_STACK= 558 | CONFIG_FATFS_FS_LOCK=0 559 | CONFIG_FATFS_TIMEOUT_MS=10000 560 | CONFIG_FATFS_PER_FILE_CACHE=y 561 | 562 | # 563 | # Modbus configuration 564 | # 565 | CONFIG_MB_QUEUE_LENGTH=20 566 | CONFIG_MB_SERIAL_TASK_STACK_SIZE=2048 567 | CONFIG_MB_SERIAL_BUF_SIZE=256 568 | CONFIG_MB_SERIAL_TASK_PRIO=10 569 | CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT= 570 | CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT=20 571 | CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 572 | CONFIG_MB_CONTROLLER_STACK_SIZE=4096 573 | CONFIG_MB_EVENT_QUEUE_TIMEOUT=20 574 | CONFIG_MB_TIMER_PORT_ENABLED=y 575 | CONFIG_MB_TIMER_GROUP=0 576 | CONFIG_MB_TIMER_INDEX=0 577 | 578 | # 579 | # FreeRTOS 580 | # 581 | CONFIG_FREERTOS_UNICORE= 582 | CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF 583 | CONFIG_FREERTOS_CORETIMER_0=y 584 | CONFIG_FREERTOS_CORETIMER_1= 585 | CONFIG_FREERTOS_HZ=100 586 | CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y 587 | CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE= 588 | CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL= 589 | CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y 590 | CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK= 591 | CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y 592 | CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1 593 | CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y 594 | CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE= 595 | CONFIG_FREERTOS_ASSERT_DISABLE= 596 | CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536 597 | CONFIG_FREERTOS_ISR_STACKSIZE=1536 598 | CONFIG_FREERTOS_LEGACY_HOOKS= 599 | CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 600 | CONFIG_SUPPORT_STATIC_ALLOCATION= 601 | CONFIG_TIMER_TASK_PRIORITY=1 602 | CONFIG_TIMER_TASK_STACK_DEPTH=2048 603 | CONFIG_TIMER_QUEUE_LENGTH=10 604 | CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0 605 | CONFIG_FREERTOS_USE_TRACE_FACILITY= 606 | CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS= 607 | CONFIG_FREERTOS_DEBUG_INTERNALS= 608 | CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y 609 | 610 | # 611 | # Heap memory debugging 612 | # 613 | CONFIG_HEAP_POISONING_DISABLED=y 614 | CONFIG_HEAP_POISONING_LIGHT= 615 | CONFIG_HEAP_POISONING_COMPREHENSIVE= 616 | CONFIG_HEAP_TRACING= 617 | 618 | # 619 | # libsodium 620 | # 621 | CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y 622 | 623 | # 624 | # Log output 625 | # 626 | CONFIG_LOG_DEFAULT_LEVEL_NONE= 627 | CONFIG_LOG_DEFAULT_LEVEL_ERROR= 628 | CONFIG_LOG_DEFAULT_LEVEL_WARN= 629 | CONFIG_LOG_DEFAULT_LEVEL_INFO=y 630 | CONFIG_LOG_DEFAULT_LEVEL_DEBUG= 631 | CONFIG_LOG_DEFAULT_LEVEL_VERBOSE= 632 | CONFIG_LOG_DEFAULT_LEVEL=3 633 | CONFIG_LOG_COLORS=y 634 | 635 | # 636 | # LWIP 637 | # 638 | CONFIG_L2_TO_L3_COPY= 639 | CONFIG_LWIP_IRAM_OPTIMIZATION= 640 | CONFIG_LWIP_MAX_SOCKETS=10 641 | CONFIG_USE_ONLY_LWIP_SELECT= 642 | CONFIG_LWIP_SO_REUSE=y 643 | CONFIG_LWIP_SO_REUSE_RXTOALL=y 644 | CONFIG_LWIP_SO_RCVBUF= 645 | CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=1 646 | CONFIG_LWIP_IP_FRAG= 647 | CONFIG_LWIP_IP_REASSEMBLY= 648 | CONFIG_LWIP_STATS= 649 | CONFIG_LWIP_ETHARP_TRUST_IP_MAC= 650 | CONFIG_ESP_GRATUITOUS_ARP=y 651 | CONFIG_GARP_TMR_INTERVAL=60 652 | CONFIG_TCPIP_RECVMBOX_SIZE=32 653 | CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y 654 | CONFIG_LWIP_DHCP_RESTORE_LAST_IP= 655 | 656 | # 657 | # DHCP server 658 | # 659 | CONFIG_LWIP_DHCPS_LEASE_UNIT=60 660 | CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 661 | CONFIG_LWIP_AUTOIP= 662 | CONFIG_LWIP_NETIF_LOOPBACK=y 663 | CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 664 | 665 | # 666 | # TCP 667 | # 668 | CONFIG_LWIP_MAX_ACTIVE_TCP=16 669 | CONFIG_LWIP_MAX_LISTENING_TCP=16 670 | CONFIG_TCP_MAXRTX=12 671 | CONFIG_TCP_SYNMAXRTX=6 672 | CONFIG_TCP_MSS=1436 673 | CONFIG_TCP_MSL=60000 674 | CONFIG_TCP_SND_BUF_DEFAULT=5744 675 | CONFIG_TCP_WND_DEFAULT=5744 676 | CONFIG_TCP_RECVMBOX_SIZE=6 677 | CONFIG_TCP_QUEUE_OOSEQ=y 678 | CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES= 679 | CONFIG_TCP_OVERSIZE_MSS=y 680 | CONFIG_TCP_OVERSIZE_QUARTER_MSS= 681 | CONFIG_TCP_OVERSIZE_DISABLE= 682 | 683 | # 684 | # UDP 685 | # 686 | CONFIG_LWIP_MAX_UDP_PCBS=16 687 | CONFIG_UDP_RECVMBOX_SIZE=6 688 | CONFIG_TCPIP_TASK_STACK_SIZE=3072 689 | CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y 690 | CONFIG_TCPIP_TASK_AFFINITY_CPU0= 691 | CONFIG_TCPIP_TASK_AFFINITY_CPU1= 692 | CONFIG_TCPIP_TASK_AFFINITY=0x7FFFFFFF 693 | CONFIG_PPP_SUPPORT= 694 | 695 | # 696 | # ICMP 697 | # 698 | CONFIG_LWIP_MULTICAST_PING= 699 | CONFIG_LWIP_BROADCAST_PING= 700 | 701 | # 702 | # LWIP RAW API 703 | # 704 | CONFIG_LWIP_MAX_RAW_PCBS=16 705 | 706 | # 707 | # mbedTLS 708 | # 709 | CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y 710 | CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC= 711 | CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC= 712 | CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=16384 713 | CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN= 714 | CONFIG_MBEDTLS_DEBUG= 715 | CONFIG_MBEDTLS_HARDWARE_AES=y 716 | CONFIG_MBEDTLS_HARDWARE_MPI= 717 | CONFIG_MBEDTLS_HARDWARE_SHA= 718 | CONFIG_MBEDTLS_HAVE_TIME=y 719 | CONFIG_MBEDTLS_HAVE_TIME_DATE= 720 | CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y 721 | CONFIG_MBEDTLS_TLS_SERVER_ONLY= 722 | CONFIG_MBEDTLS_TLS_CLIENT_ONLY= 723 | CONFIG_MBEDTLS_TLS_DISABLED= 724 | CONFIG_MBEDTLS_TLS_SERVER=y 725 | CONFIG_MBEDTLS_TLS_CLIENT=y 726 | CONFIG_MBEDTLS_TLS_ENABLED=y 727 | 728 | # 729 | # TLS Key Exchange Methods 730 | # 731 | CONFIG_MBEDTLS_PSK_MODES= 732 | CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y 733 | CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA=y 734 | CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y 735 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y 736 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y 737 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y 738 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y 739 | CONFIG_MBEDTLS_SSL_RENEGOTIATION=y 740 | CONFIG_MBEDTLS_SSL_PROTO_SSL3= 741 | CONFIG_MBEDTLS_SSL_PROTO_TLS1=y 742 | CONFIG_MBEDTLS_SSL_PROTO_TLS1_1=y 743 | CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y 744 | CONFIG_MBEDTLS_SSL_PROTO_DTLS= 745 | CONFIG_MBEDTLS_SSL_ALPN=y 746 | CONFIG_MBEDTLS_SSL_SESSION_TICKETS=y 747 | 748 | # 749 | # Symmetric Ciphers 750 | # 751 | CONFIG_MBEDTLS_AES_C=y 752 | CONFIG_MBEDTLS_CAMELLIA_C= 753 | CONFIG_MBEDTLS_DES_C= 754 | CONFIG_MBEDTLS_RC4_DISABLED=y 755 | CONFIG_MBEDTLS_RC4_ENABLED_NO_DEFAULT= 756 | CONFIG_MBEDTLS_RC4_ENABLED= 757 | CONFIG_MBEDTLS_BLOWFISH_C= 758 | CONFIG_MBEDTLS_XTEA_C= 759 | CONFIG_MBEDTLS_CCM_C=y 760 | CONFIG_MBEDTLS_GCM_C=y 761 | CONFIG_MBEDTLS_RIPEMD160_C= 762 | 763 | # 764 | # Certificates 765 | # 766 | CONFIG_MBEDTLS_PEM_PARSE_C=y 767 | CONFIG_MBEDTLS_PEM_WRITE_C=y 768 | CONFIG_MBEDTLS_X509_CRL_PARSE_C=y 769 | CONFIG_MBEDTLS_X509_CSR_PARSE_C=y 770 | CONFIG_MBEDTLS_ECP_C=y 771 | CONFIG_MBEDTLS_ECDH_C=y 772 | CONFIG_MBEDTLS_ECDSA_C=y 773 | CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y 774 | CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y 775 | CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y 776 | CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y 777 | CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y 778 | CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y 779 | CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y 780 | CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y 781 | CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y 782 | CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y 783 | CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y 784 | CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y 785 | CONFIG_MBEDTLS_ECP_NIST_OPTIM=y 786 | 787 | # 788 | # mDNS 789 | # 790 | CONFIG_MDNS_MAX_SERVICES=10 791 | 792 | # 793 | # ESP-MQTT Configurations 794 | # 795 | CONFIG_MQTT_PROTOCOL_311=y 796 | CONFIG_MQTT_TRANSPORT_SSL=y 797 | CONFIG_MQTT_TRANSPORT_WEBSOCKET=y 798 | CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y 799 | CONFIG_MQTT_USE_CUSTOM_CONFIG= 800 | CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED= 801 | CONFIG_MQTT_CUSTOM_OUTBOX= 802 | 803 | # 804 | # NVS 805 | # 806 | 807 | # 808 | # OpenSSL 809 | # 810 | CONFIG_OPENSSL_DEBUG= 811 | CONFIG_OPENSSL_ASSERT_DO_NOTHING=y 812 | CONFIG_OPENSSL_ASSERT_EXIT= 813 | 814 | # 815 | # PThreads 816 | # 817 | CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 818 | CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 819 | CONFIG_PTHREAD_STACK_MIN=768 820 | CONFIG_ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY=y 821 | CONFIG_ESP32_DEFAULT_PTHREAD_CORE_0= 822 | CONFIG_ESP32_DEFAULT_PTHREAD_CORE_1= 823 | CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT=-1 824 | CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread" 825 | 826 | # 827 | # SPI Flash driver 828 | # 829 | CONFIG_SPI_FLASH_VERIFY_WRITE= 830 | CONFIG_SPI_FLASH_ENABLE_COUNTERS= 831 | CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y 832 | CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y 833 | CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS= 834 | CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED= 835 | 836 | # 837 | # SPIFFS Configuration 838 | # 839 | CONFIG_SPIFFS_MAX_PARTITIONS=3 840 | 841 | # 842 | # SPIFFS Cache Configuration 843 | # 844 | CONFIG_SPIFFS_CACHE=y 845 | CONFIG_SPIFFS_CACHE_WR=y 846 | CONFIG_SPIFFS_CACHE_STATS= 847 | CONFIG_SPIFFS_PAGE_CHECK=y 848 | CONFIG_SPIFFS_GC_MAX_RUNS=10 849 | CONFIG_SPIFFS_GC_STATS= 850 | CONFIG_SPIFFS_PAGE_SIZE=256 851 | CONFIG_SPIFFS_OBJ_NAME_LEN=32 852 | CONFIG_SPIFFS_USE_MAGIC=y 853 | CONFIG_SPIFFS_USE_MAGIC_LENGTH=y 854 | CONFIG_SPIFFS_META_LENGTH=4 855 | CONFIG_SPIFFS_USE_MTIME=y 856 | 857 | # 858 | # Debug Configuration 859 | # 860 | CONFIG_SPIFFS_DBG= 861 | CONFIG_SPIFFS_API_DBG= 862 | CONFIG_SPIFFS_GC_DBG= 863 | CONFIG_SPIFFS_CACHE_DBG= 864 | CONFIG_SPIFFS_CHECK_DBG= 865 | CONFIG_SPIFFS_TEST_VISUALISATION= 866 | 867 | # 868 | # TCP/IP Adapter 869 | # 870 | CONFIG_IP_LOST_TIMER_INTERVAL=120 871 | CONFIG_TCPIP_LWIP=y 872 | 873 | # 874 | # Unity unit testing library 875 | # 876 | CONFIG_UNITY_ENABLE_FLOAT=y 877 | CONFIG_UNITY_ENABLE_DOUBLE=y 878 | CONFIG_UNITY_ENABLE_COLOR= 879 | CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y 880 | CONFIG_UNITY_ENABLE_FIXTURE= 881 | 882 | # 883 | # Virtual file system 884 | # 885 | CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y 886 | CONFIG_SUPPORT_TERMIOS=y 887 | 888 | # 889 | # Wear Levelling 890 | # 891 | CONFIG_WL_SECTOR_SIZE_512= 892 | CONFIG_WL_SECTOR_SIZE_4096=y 893 | CONFIG_WL_SECTOR_SIZE=4096 894 | --------------------------------------------------------------------------------