https://v.youku.com/v_show/id_XN ... .listitem_page1.5~A
1.源码编译方式
1. cd app/
2. ./gen_misc.sh
2.Gagent库版本
04020024
3.烧录固件
esp_init_data_default.bin 0x3fc000
blank.bin 0x3fe000
boot_v1.6.bin 0x00000
user1.4096.new.6.bin 0x01000
选项:CrystalFreq=26M SPI_SPEED=40MHz SPI_MODE=QIO FLASH_SIZE=32Mbit-C1, 其他默认,串口115200
进入uart烧录模式后,点击start下载即可!
4.OTA测试
OTA固件版本号位置:gizwits_product.h
#define SDK_VERSION "25" //OTA固件版本号,必须为两位数, 默认为当前Gagent库版本号
MAC:
查看云端产品管理->运行状态->在线设备详情->设备MAC
注意:
1.编译固件时的Makefile与烧录工具的设置:
"FLASH SIZE" : 32Mbit-C1
"SPI MODE" : QIO
2.推送的“OTA固件版本号”必须大于正工作的软件版本。
3.固件类型:WiFi 推送方式:v4.1
单片机源程序如下:
- #include "ets_sys.h"
- #include "osapi.h"
- #include "user_interface.h"
- #include "gagent_soc.h"
- #include "user_devicefind.h"
- #include "user_webserver.h"
- #include "gizwits_product.h"
- #include "driver/hal_key.h"
- #if ESP_PLATFORM
- #include "user_esp_platform.h"
- #endif
- #include "driver/hal_temp_hum.h"
- #ifdef SERVER_SSL_ENABLE
- #include "ssl/cert.h"
- #include "ssl/private_key.h"
- #else
- #ifdef CLIENT_SSL_ENABLE
- unsigned char *default_certificate;
- unsigned int default_certificate_len = 0;
- unsigned char *default_private_key;
- unsigned int default_private_key_len = 0;
- #endif
- #endif
- /**@} */
- /**@name Key related definitions
- * @{
- */
- #define GPIO_KEY_NUM 4 ///< Defines the total number of key members
- #define KEY_0_IO_MUX PERIPHS_IO_MUX_GPIO0_U ///< ESP8266 GPIO function
- #define KEY_0_IO_NUM 0 ///< ESP8266 GPIO number
- #define KEY_0_IO_FUNC FUNC_GPIO0 ///< ESP8266 GPIO name
- #define KEY_1_IO_MUX PERIPHS_IO_MUX_GPIO2_U ///< ESP8266 GPIO function
- #define KEY_1_IO_NUM 2 ///< ESP8266 GPIO number
- #define KEY_1_IO_FUNC FUNC_GPIO2 ///< ESP8266 GPIO name
- #define KEY_2_IO_MUX PERIPHS_IO_MUX_U0RXD_U ///< ESP8266 GPIO function
- #define KEY_2_IO_NUM 3 ///< ESP8266 GPIO number
- #define KEY_2_IO_FUNC FUNC_GPIO3 ///< ESP8266 GPIO name
- #define KEY_3_IO_MUX PERIPHS_IO_MUX_U0TXD_U ///< ESP8266 GPIO function
- #define KEY_3_IO_NUM 1 ///< ESP8266 GPIO number
- #define KEY_3_IO_FUNC FUNC_GPIO1 ///< ESP8266 GPIO name
- LOCAL key_typedef_t * singleKey[GPIO_KEY_NUM]; ///< Defines a single key member array pointer
- LOCAL keys_typedef_t keys; ///< Defines the overall key module structure pointer
- /**@} */
- /**
- * Key1 key short press processing
- * @param none
- * @return none
- */
- LOCAL void ICACHE_FLASH_ATTR key1ShortPress(void)
- {
- if(statu[0]=!statu[0])
- GIZWITS_LOG("#### KEY1 short press ,LED_1 ON/OFF \n");
-
- }
- /**
- * Key1 key presses a long press
- * @param none
- * @return none
- */
- LOCAL void ICACHE_FLASH_ATTR key1LongPress(void)
- {
- GIZWITS_LOG("#### key1 long press, SOFTAP MODE\n");
-
- gizwitsSetMode(WIFI_SOFTAP_MODE);
- }
- /**
- * Key2 key to short press processing
- * @param none
- * @return none
- */
- LOCAL void ICACHE_FLASH_ATTR key2ShortPress(void)
- {
- if(statu[1]=!statu[1])
- GIZWITS_LOG("#### key2 short press, LED_2 ON/OFF \n");
- }
- /**
- * Key2 button long press
- * @param none
- * @return none
- */
- LOCAL void ICACHE_FLASH_ATTR key2LongPress(void)
- {
- GIZWITS_LOG("#### key2 long press, AIRLINK MODE\n");
-
- gizwitsSetMode(WIFI_AIRLINK_MODE);
- }
- /**
- * Key3 key to short press processing
- * @param none
- * @return none
- */
- LOCAL void ICACHE_FLASH_ATTR key3ShortPress(void)
- {
- if(statu[2]=!statu[2])
- GIZWITS_LOG("#### key3 short press, LED_3 ON/OFF \n");
- }
- /**
- * Key3 button long press
- * @param none
- * @return none
- */
- LOCAL void ICACHE_FLASH_ATTR key3LongPress(void)
- {
- GIZWITS_LOG("#### key3 long press, ALL_LED ON \n");
- }
- /**
- * Key4 key to short press processing
- * @param none
- * @return none
- */
- LOCAL void ICACHE_FLASH_ATTR key4ShortPress(void)
- {
- if(statu[3]=!statu[3])
- GIZWITS_LOG("#### key4 short press, LED_4 ON/OFF \n");
- }
- /**
- * Key4 button long press
- * @param none
- * @return none
- */
- LOCAL void ICACHE_FLASH_ATTR key4LongPress(void)
- {
- GIZWITS_LOG("#### key4 long press, ALL_LED OFF \n");
- }
- /**
- * Key to initialize
- * @param none
- * @return none
- */
- LOCAL void ICACHE_FLASH_ATTR keyInit(void)
- {
- singleKey[0] = keyInitOne(KEY_0_IO_NUM, KEY_0_IO_MUX, KEY_0_IO_FUNC,
- key1LongPress, key1ShortPress);
- singleKey[1] = keyInitOne(KEY_1_IO_NUM, KEY_1_IO_MUX, KEY_1_IO_FUNC,
- key2LongPress, key2ShortPress);
- singleKey[2] = keyInitOne(KEY_2_IO_NUM, KEY_2_IO_MUX, KEY_2_IO_FUNC,
- key3LongPress, key3ShortPress);
- singleKey[3] = keyInitOne(KEY_3_IO_NUM, KEY_3_IO_MUX, KEY_3_IO_FUNC,
- key4LongPress, key4ShortPress);
- keys.singleKey = singleKey;
- keyParaInit(&keys);
- PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U,FUNC_GPIO14);// 配置lED_1引脚输出
- GPIO_DIS_OUTPUT(GPIO_ID_PIN(14));
- PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U,FUNC_GPIO12);// 配置LED_2引脚输出
- GPIO_DIS_OUTPUT(GPIO_ID_PIN(12));
- PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U,FUNC_GPIO13);// 配置lED_1引脚输出
- GPIO_DIS_OUTPUT(GPIO_ID_PIN(13));
- PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U,FUNC_GPIO15);// 配置lED_1引脚输出
- GPIO_DIS_OUTPUT(GPIO_ID_PIN(15));
- GPIO_OUTPUT_SET(GPIO_ID_PIN(14), 0);//输出高电平 LED_1 OFF
- GPIO_OUTPUT_SET(GPIO_ID_PIN(12), 0);//输出高电平 LED_2 OFF
- GPIO_OUTPUT_SET(GPIO_ID_PIN(13), 0);//输出高电平 LED_3 OFF
- GPIO_OUTPUT_SET(GPIO_ID_PIN(15), 0);//输出高电平 LED_4 OFF
- }
- /**
- * @brief user_rf_cal_sector_set
- * Use the 636 sector (2544k ~ 2548k) in flash to store the RF_CAL parameter
- * @param none
- * @return none
- */
- uint32_t ICACHE_FLASH_ATTR user_rf_cal_sector_set()
- {
- return 636;
- }
- /**
- * @brief program entry function
- * In the function to complete the user-related initialization
- * @param none
- * @return none
- */
- void ICACHE_FLASH_ATTR user_init(void)
- {
- uint32_t system_free_size = 0;
- wifi_station_set_auto_connect(1);
- wifi_set_sleep_type(NONE_SLEEP_T);//set none sleep mode
- espconn_tcp_set_max_con(10);
- uart_init_3(9600,115200);
- UART_SetPrintPort(1);
- GIZWITS_LOG( "---------------SDK version:%s--------------\n", system_get_sdk_version());
- GIZWITS_LOG( "system_get_free_heap_size=%d\n",system_get_free_heap_size());
- struct rst_info *rtc_info = system_get_rst_info();
- GIZWITS_LOG( "reset reason: %x\n", rtc_info->reason);
- if (rtc_info->reason == REASON_WDT_RST ||
- rtc_info->reason == REASON_EXCEPTION_RST ||
- rtc_info->reason == REASON_SOFT_WDT_RST)
- {
- if (rtc_info->reason == REASON_EXCEPTION_RST)
- {
- GIZWITS_LOG("Fatal exception (%d):\n", rtc_info->exccause);
- }
- GIZWITS_LOG( "epc1=0x%08x, epc2=0x%08x, epc3=0x%08x, excvaddr=0x%08x, depc=0x%08x\n",
- rtc_info->epc1, rtc_info->epc2, rtc_info->epc3, rtc_info->excvaddr, rtc_info->depc);
- }
- if (system_upgrade_userbin_check() == UPGRADE_FW_BIN1)
- {
- GIZWITS_LOG( "---UPGRADE_FW_BIN1---\n");
- }
- else if (system_upgrade_userbin_check() == UPGRADE_FW_BIN2)
- {
- GIZWITS_LOG( "---UPGRADE_FW_BIN2---\n");
- }
- keyInit();
- gizwitsInit();
- dh11Init();
- GIZWITS_LOG("--- system_free_size = %d ---\n", system_get_free_heap_size());
- }
复制代码
所有资料51hei提供下载:
ESP8266 NodeMcu机智云SOC方案控制4路继电器.7z
(2.54 MB, 下载次数: 67)
|