コード例 #1
0
void ICACHE_FLASH_ATTR
	debug_UploadExceptionInfo(void* arg)
{
    struct espconn *pespconn = (struct espconn *)arg;
	
	os_printf("reset reason: %x\n", rtc_info_dbg.reason);
	uint8 debug_upload_buf[DEBUG_UPLOAD_BUF_LEN];
	uint8* pInfo = debug_upload_buf;
	os_memset(debug_upload_buf,0,DEBUG_UPLOAD_BUF_LEN);

	uint8 devkey[41];
	os_memset(devkey,0,sizeof(devkey));
	user_esp_platform_get_devkey(devkey);
	
	if (rtc_info_dbg.reason == REASON_WDT_RST ||
		rtc_info_dbg.reason == REASON_EXCEPTION_RST ||
		rtc_info_dbg.reason == REASON_SOFT_WDT_RST) {


		os_sprintf(pInfo,UPLOAD_DEBUG_LOG,rtc_info_dbg.reason,rtc_info_dbg.exccause,rtc_info_dbg.epc1,
			                                      rtc_info_dbg.epc2,rtc_info_dbg.epc3,rtc_info_dbg.excvaddr,
			                                      rtc_info_dbg.depc,FlashDebugBufParam.DebugVersion ,devkey);
	}else{
		return;
	}

	//os_printf("pInfo, len: %d : \r\n%s\r\n",os_strlen(pInfo),pInfo);
	#if ESP_MESH_SUPPORT
	mesh_json_add_elem(pInfo, sizeof(pInfo), (char*)mesh_GetMdevMac(), ESP_MESH_JSON_DEV_MAC_ELEM_LEN);
	#endif
    if(0 == espconn_esp_sent(pespconn, pInfo, os_strlen(pInfo))){
	    debug_DropExceptionInfo();
		
    }
}
コード例 #2
0
//upload debug info to esp-server
void ICACHE_FLASH_ATTR
    debug_UploadExceptionInfo(void* arg)
{
    struct espconn *pespconn = (struct espconn *)arg;
    
    ESP_DBG("reset reason: %x\n", rtc_info_dbg.reason);
    uint8 debug_upload_buf[DEBUG_UPLOAD_BUF_LEN];
    uint8* pInfo = debug_upload_buf;
    os_memset(debug_upload_buf,0,DEBUG_UPLOAD_BUF_LEN);

    uint8 devkey[41];
    os_memset(devkey,0,sizeof(devkey));
    user_esp_platform_get_devkey(devkey);
    
    if (rtc_info_dbg.reason == REASON_WDT_RST ||
        rtc_info_dbg.reason == REASON_EXCEPTION_RST ||
        rtc_info_dbg.reason == REASON_SOFT_WDT_RST) {
        os_sprintf(pInfo,UPLOAD_DEBUG_LOG,rtc_info_dbg.reason,rtc_info_dbg.exccause,rtc_info_dbg.epc1,
                                                  rtc_info_dbg.epc2,rtc_info_dbg.epc3,rtc_info_dbg.excvaddr,
                                                  rtc_info_dbg.depc,FlashDebugBufParam.DebugVersion ,devkey);
    }else{
        return;
    }

    #if ESP_MESH_SUPPORT
    mesh_json_add_elem(pInfo, sizeof(pInfo), (char*)mesh_GetMdevMac(), ESP_MESH_JSON_DEV_MAC_ELEM_LEN);
    #endif

	uint8 *dst = NULL,*src = NULL;
	#if ESP_MESH_SUPPORT
    	uint8 dst_t[6],src_t[6];
		if(pespconn && pespconn->proto.tcp){
            os_memcpy(dst_t,pespconn->proto.tcp->remote_ip,4);
			os_memcpy(dst_t+4,&pespconn->proto.tcp->remote_port,2);
		}
    	wifi_get_macaddr(STATION_IF,src_t);	
		dst = dst_t;
		src = src_t;
	#endif
	
	ESP_DBG("debug Info: %s \r\n",pInfo);
    if(0 == user_JsonDataSend(pespconn, pInfo, os_strlen(pInfo),0,src,dst)){
        debug_DropExceptionInfo();
		ESP_DBG("upload success...\r\n");
    }else{
		ESP_DBG("upload fail...\r\n");
    }
}