Ejemplo n.º 1
0
void ICACHE_FLASH_ATTR
sp_LightPairRequestPermission()
{
#if 1
    char data_body[200];
    os_bzero(data_body,sizeof(data_body));
    uint8 mac_sta[6] = {0};
    wifi_get_macaddr(STATION_IF, mac_sta);
    os_sprintf(data_body,"{\"device_mac\":\"%02X%02X%02X%02X%02X%02X\",\"button_mac\":\"%02X%02X%02X%02X%02X%02X\",\"path\":\"%s\"}",MAC2STR(mac_sta),MAC2STR(buttonPairingInfo.button_mac),PAIR_FOUND_REQUEST);
	
	if (!mesh_json_add_elem(data_body, sizeof(data_body), pair_sip, ESP_MESH_JSON_IP_ELEM_LEN)) {
    	return;
    }
    if (!mesh_json_add_elem(data_body, sizeof(data_body), pair_sport, ESP_MESH_JSON_PORT_ELEM_LEN)) {
	    return;
    }
    char* dev_mac = (char*)mesh_GetMdevMac();
    if (!mesh_json_add_elem(data_body, sizeof(data_body), dev_mac, ESP_MESH_JSON_DEV_MAC_ELEM_LEN)) {
	    return;
    }
    #if ESP_MESH_SUPPORT
	response_send_str((struct espconn*)user_GetUserPConn(),true,data_body,os_strlen(data_body),NULL,0,0,0);
	#else
	response_send_str((struct espconn*)user_GetWebPConn(),true,data_body,os_strlen(data_body),NULL,0,0,0);
	#endif
#endif
}
Ejemplo n.º 2
0
void ICACHE_FLASH_ATTR
sp_LightPairReportResult(bool res)
{
#if 1
	os_printf("sp_LightPairReportResult %d \r\n",res);
    char data_body[300];
    os_bzero(data_body,sizeof(data_body));
    uint8 mac_sta[6] = {0};
    wifi_get_macaddr(STATION_IF, mac_sta);
    os_sprintf(data_body,"{\"device_mac\":\"%02X%02X%02X%02X%02X%02X\",\"button_mac\":\"%02X%02X%02X%02X%02X%02X\",\"result\":%d,\"path\":\"%s\"}",MAC2STR(mac_sta),MAC2STR(buttonPairingInfo.button_mac),res,PAIR_RESULT);
	//{"device_mac":"...","result":1,"path":"/device/button/pair/result"}
	if (!mesh_json_add_elem(data_body, sizeof(data_body), pair_sip, ESP_MESH_JSON_IP_ELEM_LEN)) {
    	return;
    }
    if (!mesh_json_add_elem(data_body, sizeof(data_body), pair_sport, ESP_MESH_JSON_PORT_ELEM_LEN)) {
	    return;
    }
    char* dev_mac = (char*)mesh_GetMdevMac();
    if (!mesh_json_add_elem(data_body, sizeof(data_body), dev_mac, ESP_MESH_JSON_DEV_MAC_ELEM_LEN)) {
	    return;
    }
    #if ESP_MESH_SUPPORT
	response_send_str((struct espconn*)user_GetUserPConn(),true,data_body,os_strlen(data_body),NULL,0,0,0);
	#else
	response_send_str((struct espconn*)user_GetWebPConn(),true,data_body,os_strlen(data_body),NULL,0,0,0);
	#endif
#endif
}
Ejemplo n.º 3
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();
		
    }
}
Ejemplo n.º 4
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");
    }
}