1. 程式人生 > >AliOS-Things--linkkitapp (6)列印日誌

AliOS-Things--linkkitapp (6)列印日誌

設定日誌水平:

 EXAMPLE_TRACE("linkkit start");

    /*
     * linkkit start
     * max_buffered_msg = 16, set the handle msg max numbers.
     *     if it is enough memory, this number can be set bigger.
     * if get_tsl_from_cloud = 0, it will use the default tsl [TSL_STRING]; if
     * get_tsl_from_cloud =1, it will get tsl from cloud.
     */
if (-1 == linkkit_start(16, get_tsl_from_cloud, linkkit_loglevel_emerg, &linkkit_ops, linkkit_cloud_domain_shanghai, &sample_ctx)) { EXAMPLE_TRACE("linkkit start fail"); return -1; }

日誌種種

#define EXAMPLE_TRACE(fmt, ...)                        \
    do {                                               \
        HAL_Printf("%s|%03d :: ", __func__, __LINE__); \
        HAL_Printf(fmt, ##__VA_ARGS__);                \
        HAL_Printf("%s", "\r\n");                      \
    } while (0)

使用:

int linkkit_example()
{
	...
	EXAMPLE_TRACE("linkkit start");
	...
}

日誌列印:

linkkit_example|938 :: linkkit start

    函式名      |  不知道是啥的編號  ::  列印的內容

日誌–問題溯源

裝置打印出這條日誌訊息之後,就卡死了,也不進行WiFi重連的操作了。

bcn_timout,ap_probe_send_start
ap_probe_send_over, rest wifi status to disassoc
state: 5 -> 0 (1)
rm 0
pm close 7 0 0/58782808
[WiFi] event 2
Wifi disconnected (reason: 200)

 現在,由[WiFi] event 2來找問題:

  • WiFi事件2:應該是要找WiFi驅動的問題
    在路徑為:platform\mcu\esp8266\hal\wifi_port.c的檔案中看到了:printf("[WiFi] event %u\n", event->event_id);
void ICACHE_FLASH_ATTR wifi_event_handler_cb(System_Event_t *event)
{
    static bool station_was_connected = false;
    if (event == NULL) {
        return;
    }

    printf("[WiFi] event %u\n", event->event_id);

    switch (event->event_id) {
        case EVENT_STAMODE_DISCONNECTED:
            wifi_station_is_connected = false;
            Event_StaMode_Disconnected_t *ev = (Event_StaMode_Disconnected_t *)&event->event_info;
            if(on_station_disconnect){
                on_station_disconnect(ev->reason);
            }
            break;
        case EVENT_STAMODE_CONNECTED:
            if(wifi_station_static_ip){
                wifi_station_is_connected = true;
                if(!station_was_connected){
                    station_was_connected = true;
                    if(on_station_first_connect){
                        on_station_first_connect();
                    }
                }
                if(on_station_connect){
                    on_station_connect();
                }
            }
            break;
        case EVENT_STAMODE_DHCP_TIMEOUT:
            if(wifi_station_is_connected){
                wifi_station_is_connected = false;
                if(on_station_disconnect){
                    on_station_disconnect(REASON_UNSPECIFIED);
                }
            }
            break;
        case EVENT_STAMODE_GOT_IP:
            wifi_station_is_connected = true;
            if(!station_was_connected){
                station_was_connected = true;
                if(on_station_first_connect){
                    on_station_first_connect();
                }
            }
            notify_got_ip(event);
            if(on_station_connect){
                on_station_connect();
            }
            break;

        case EVENT_SOFTAPMODE_STACONNECTED:
            if(on_client_connect){
                on_client_connect();
            }
            break;
        case EVENT_SOFTAPMODE_STADISCONNECTED:
            if(on_client_disconnect){
                on_client_disconnect();
            }
            break;
        default:
            break;
    }
}

在路徑為:platform\mcu\esp8266\bsp\ESP8266_RTOS_SDK\include\espressif\esp_wifi.h中找到了“事件2”是什麼意思:ESP8266 station disconnected to AP

typedef enum {
    EVENT_STAMODE_SCAN_DONE = 0,        /**< ESP8266 station finish scanning AP */
    EVENT_STAMODE_CONNECTED,            /**< ESP8266 station connected to AP */
    EVENT_STAMODE_DISCONNECTED,         /**< ESP8266 station disconnected to AP */
    EVENT_STAMODE_AUTHMODE_CHANGE,      /**< the auth mode of AP connected by ESP8266 station changed */
    EVENT_STAMODE_GOT_IP,               /**< ESP8266 station got IP from connected AP */
    EVENT_STAMODE_DHCP_TIMEOUT,         /**< ESP8266 station dhcp client got IP timeout */
    EVENT_SOFTAPMODE_STACONNECTED,      /**< a station connected to ESP8266 soft-AP */
    EVENT_SOFTAPMODE_STADISCONNECTED,   /**< a station disconnected to ESP8266 soft-AP */
    EVENT_SOFTAPMODE_PROBEREQRECVED,    /**< Receive probe request packet in soft-AP interface */
    EVENT_MAX
} SYSTEM_EVENT;

鴈mpty
Wifi init success!!
mode : sta(cc:50:e3:04:d4:16)
add if0
trace should have cli to control!!!
[000010]<V> aos framework init.
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 2
pm open phy_2,type:2 0 0
cnt 

connected with 1318, channel 1
dhcp client start...
[WiFi] event 1
ip:192.168.0.102,mask:255.255.255.0,gw:192.168.0.1
[WiFi] event 4
Same seed found -1274967296
[003030]<V> wifi_service_event config.ssid 1318
--- PWM v2.0
linkkit_example|938 :: linkkit start
[003040]<V> IOTX_CONN_CLOUD
[err] Add Connectivity Success, Type: 1
Wifi connected.
[004700]<V> IOTX_CONN_CLOUD_SUC
<DEBUG> [awss_report_token_to_cloud#280] : report token:{"id":"0", "version":"1.0", "method":"thing.awss.enrollee.match", "params":{"token":"1A7E3832F23B16720E0353FD82BD6C77"}}

<DEBUG> [awss_report_token_to_cloud#285] : report token res:0

[err] Add Connectivity Success, Type: 2
[err] Start ALCS Cloud Init
[err] ALCS Prefix Get, Topic: /sys/a1a6auLEDNx/LTS20181008001/thing/lan/prefix/get, Payload: {"id":"0","version":"1.0","params":"{}","method":"thing.lan.prefix.get"}
[wrn] JSON Parse Failed: deviceName
linkkit_example|962 :: linkkit enter loop
thing_create|364 :: new [email protected] created.

on_connect|152 :: cloud is connected

<DEBUG> [awss_report_token_reply#82] : awss_report_token_reply

[006220]<V> IOTX_AWSS_BIND_NOTIFY
<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"1","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":43510,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"2","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":43400,"type":0}}

[err] No Matched Item
<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"3","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":43190,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"4","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":42880,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"5","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":42460,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"6","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":41930,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"7","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":41310,"type":0}}

<DEBUG> [linkkit_ntp_time_reply#41] : ntp reply len:91, payload:{"deviceSendTime":"1234","serverSendTime":"1539225966526","serverRecvTime":"1539225966526"}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"8","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":40550,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"9","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":39730,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"10","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":38800,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"11","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":37770,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"12","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":36660,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"13","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":35450,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"14","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":34140,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"15","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":32730,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"16","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":31220,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"17","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":29610,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"18","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":27900,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"19","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":26090,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"20","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":24180,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"21","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":22170,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"22","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":20060,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"23","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":17850,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"24","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":15540,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"25","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":13130,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"26","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":10620,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"27","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":8010,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"28","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":5300,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"29","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":2490,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"30","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":0,"type":0}}

<DEBUG> [awss_notify_dev_info#209] : topic:/sys/device/info/notify, {"id":"31","version":"1.0","method":"device.info.notify","params":{"awssVer":{"smartconfig":"2.0","zconfig":"2.0","router":"2.0","ap":"2.0"},"productKey":"a1a6auLEDNx","deviceName":"LTS20181008001","mac":"CC:50:E3:04:D4:16","ip":"192.168.0.102","cipherType":4,"token":"1A7E3832F23B16720E0353FD82BD6C77","remainTime":0,"type":0}}

<DEBUG> [awss_notify_response#117] : awss_notify_response, type:1,result:0