硬着头皮啃小e源码,能啃多少算多少吧,正好赶上微信服务器升级,测试要暂缓了
迷窟Q的广告时间,http://mikuq.com/
更多内容可关注“二叔科技.创客空间(167153362)”
源代码下载地址
http://www.kaifakuai.com/kfkdev/Download2.html
在包M302I-ESP8266-ROMsource固件源码.zip里
我们要从et_iot_source\et_app\user里的user_main.c看起
入口函数user_init
/****************************************************************************** * FunctionName : user_init * Description : entry of user application, init user function here * Parameters : none * Returns : none *******************************************************************************/ void user_init(void) { key_gpio_t key; struct station_config config; struct ip_info info; et_uchar result=0; os_printf("now SDK version:%s\n", system_get_sdk_version()); if(get_fac_norm_mode(&result) != SPI_FLASH_RESULT_OK) { os_printf("get_fac_norm_mode error, NORMAL mode\n"); } if(result == FAC_MODE) { os_printf("run in factory mode\n"); uart_init_new_uart1(BIT_RATE_115200); UART_SetPrintPort(UART1); uart_init_new(BIT_RATE_9600, result); return; } os_printf("run in normal mode\n"); // show logo user_show_logo(); if (RETURN_OK != user_get_work_mode(&work_mode)) { os_printf("get work mode fail !!!\n"); return; } if (RETURN_OK != user_init_work_mode(work_mode, result)) { os_printf("init work mode fail !!!\n"); return; } // wifi led control xTaskCreate(user_wifi_led_control, "wifi_led_control", 256, NULL, 2, NULL); //wifi event handle wifi_set_event_handler_cb(et_wifi_event_cb); memset(&key, 0, sizeof(key_gpio_t)); key.key_gpio_pin = AIRKISS_KEY_IO_PIN; key.key_num = AIRKISS_KEY_IO_NUM; airkiss_key_init(&key); wifi_set_opmode(STATION_MODE); wifi_reconnect_start_flag = 0; xTaskCreate(airkiss_key_poll_task, "smartconfig_task", 256, NULL, 2, NULL); memset(&config, 0, sizeof(struct station_config)); if(wifi_station_get_config_default(&config) == true) { os_printf("ssid=%s\n", config.ssid); wifi_station_set_config_current(&config); //for static ip set /*wifi_station_dhcpc_stop(); IP4_ADDR(&info.ip, 192, 168, 1, 43); IP4_ADDR(&info.gw, 192, 168, 1, 1); IP4_ADDR(&info.netmask, 255, 255, 255, 0); wifi_set_ip_info(STATION_IF, &info);*/ } os_timer_disarm(&test_timer); os_timer_setfn(&test_timer, (os_timer_func_t *)user_esp_platform_check_ip, NULL); os_timer_arm(&test_timer, 1000, 0); }
插上USB线,串口速率比较特殊74880不知道为什么,是否可以修改,估计不容易吧
运行日志
OS SDK ver: 1.2.0(b900bd2) compiled @ Aug 28 2015 17:18:41 phy ver: 356, pp ver: 9.0 now SDK version:1.2.0(b900bd2) run in normal mode get adc value=716 is success !!! get work mode=BAROMETRIC is success !!! ssid=home mode : sta(4b:fe:34:de:0d:18) add if0 wifi led thread will be start scandone state: 0 -> 2 (b0) state: 2 -> 3 (0) state: 3 -> 5 (10) add 0 aid 8 cnt ERRRRRR:256,135,135!!!!ERRRRRR:256,113,113!!!! connected with mikuq, channel 6 et connect to ssid mikuq, channel 6 dhcp client start... ip:192.168.1.117,mask:255.255.255.0,gw:192.168.1.1 got ip !!! ET U-SDK var2.1.0.2 now addr is 192.168.1.117 now write rc is 70 Received : 115.28.226.129:1883 Now im server addr is 115.28.226.129 port is 1883 now write rc is 70 now read delay is 299 now server time is 15903983 now server time is 16903972 now server time is 17903976 now read recv rc is 1 now read recv rc is 1 now read recv rc is 2 ET event happend event_no:1 data:0 You are connect:0x1 now write rc is 32 Now send get state success Get 2266 state 0 now write rc is 20 Now send get state success Sub 1843 state 0 now write rc is 27 Now send get state success Sub all buddies status 0 now write rc is 18 now read recv rc is 1 now read recv rc is 1 now read recv rc is 30 now message arrived 2266 Status:status message: id16383, qos0--> payload len:17 payload:0&29470@4|2.1.0.2 now read recv rc is 1 now read recv rc is 1 now read recv rc is 2 now read recv rc is 1 now read recv rc is 1 now read recv rc is 2 now read recv rc is 1 now read recv rc is 1 now read recv rc is 2 now read delay is 294 now server time is 18903978 now server time is 19903969 now server time is 20903969 now read recv rc is 1 now read recv rc is 1 now read recv rc is 3 Sub topic 0 file IP 115.28.226.129 Send task already create now start client task now server time is 21903976 now client time is 22013967 now server time is 22903967 now client time is 23013967 now server time is 23903967 now client time is 24013967 now server time is 24903974 now client time is 25013969 now server time is 25904033 now client time is 26013967 now server time is 26903967 now client time is 27013967 now server time is 27903967 now client time is 28013967 now server time is 28903967 now client time is 29013967 now server time is 29903967 now client time is 30013967 now server time is 30903967 now start init friend now client time is 31014949 now write rc is 24 Now get buddies list success Get online buddies sucess now write rc is 27 Now send get state success Sub all buddies state sucess now client time 2 is 31041933 now read recv rc is 1 now read recv rc is 1 now read recv rc is 20 now message arrived Get online buddies list:buddy_state_list message: id16400, qos0--> payload len:0 now client time 2 is 31083757 now read recv rc is 1 now read recv rc is 1 now read recv rc is 2 now client time 2 is 31297222 now read recv rc is 1 now read recv rc is 1 now read recv rc is 2 now server time is 31903972 now client time is 32293969 now server time is 32903969 now client time is 33293967 now server time is 33903969 now client time is 34293978 now server time is 34904040 now client time is 35293964 now server time is 35903972 now client time is 36293964 now server time is 36904013 now client time is 37293964 now server time is 37903972 now client time is 38293964 now server time is 38903969 now client time is 39293967 now server time is 39903969 now client time is 40294007 now server time is 40903972 now client time is 41293964 now server time is 41903969
airkiss的任务,大意就是每0.5秒检查一下配置按键吧
void ICACHE_FLASH_ATTR airkiss_key_poll_task(void *pvParameters) { et_uint32 value, i; while(1) { value = gpio_get_value(AIRKISS_KEY_IO_NUM); if(!air_kiss_start_flag && !value) { delay_s(1); value = gpio_get_value(AIRKISS_KEY_IO_NUM); if(!air_kiss_start_flag && !value) { os_printf("begin to airkiss\n"); air_kiss_start_flag = 1; os_timer_disarm(&test_timer); to_stop_app = 1; //in airkiss mode, stop et_user_main thread if(g_cloud_handle != NULL) { et_stop_srv(g_cloud_handle); et_logout_cloud(g_cloud_handle); et_destroy_context(g_cloud_handle); g_cloud_handle = NULL; } delay_s(1); wifi_reconnect_start_flag = 0; smartconfig_start(smartconfig_done); //airkiss start user_set_wifi_led_delay(500); if(work_mode != WORK_MODE_BAROMETRIC || work_mode != WORK_MODE_AUDIO) { OLED_clear(); OLED_show_chn(0, 0, 15); //show 小e: OLED_show_str(18, 0, "e:", 2); OLED_show_chn(0, 2, 8); //show 网络配置中... OLED_show_chn(18, 2, 9); OLED_show_chn(36, 2, 10); OLED_show_chn(54, 2, 11); OLED_show_chn(72, 2, 12); OLED_show_str(90, 2, "...", 2); } os_timer_setfn(&test_timer, (os_timer_func_t *)user_esp_platform_check_ip, NULL); os_timer_arm(&test_timer, 1000, 0); } } delay_ms(500); } os_printf("end airkiss\n"); vTaskDelete(NULL); }
void user_wifi_led_control(void *param) { printf("wifi led thread will be start\n"); gpio_set_output(WIFI_STATUS_IO_PIN, WIFI_STATUS_IO_NUM); GPIO_OUTPUT_SET(WIFI_STATUS_IO_NUM, LOGIC_HL); while (wifi_led_thread) { if (WIFI_LED_DELAY_Y != wifi_led_mode) { delay_ms(100); continue; } GPIO_OUTPUT_SET(WIFI_STATUS_IO_NUM, LOGIC_LL); delay_ms(wifi_led_delay); GPIO_OUTPUT_SET(WIFI_STATUS_IO_NUM, LOGIC_HL); delay_ms(wifi_led_delay); } printf("wifi led thread will be stop\n"); vTaskDelete(NULL); }
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
与电子爱好者谈读图二被打赏50分 | |
【FRDM-MCXN947评测】Core1适配运行FreeRtos被打赏50分 | |
【FRDM-MCXN947评测】双核调试被打赏50分 | |
【CPKCORRA8D1B评测】---移植CoreMark被打赏50分 | |
【CPKCORRA8D1B评测】---打开硬件定时器被打赏50分 | |
【FRDM-MCXA156评测】4、CAN loopback模式测试被打赏50分 | |
【CPKcorRA8D1评测】--搭建初始环境被打赏50分 | |
【FRDM-MCXA156评测】3、使用FlexIO模拟UART被打赏50分 | |
【FRDM-MCXA156评测】2、rt-thread MCXA156 BSP制作被打赏50分 | |
【FRDM-MCXN947评测】核间通信MUTEX被打赏50分 |