diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..bb55415 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "aliosStudio.sdkPath": "/Users/miaogs/.aos/AliOS-Things" +} \ No newline at end of file diff --git a/examples/qlinkapp/main.c b/examples/qlinkapp/main.c index d5c99b8..7c79355 100644 --- a/examples/qlinkapp/main.c +++ b/examples/qlinkapp/main.c @@ -7,6 +7,12 @@ const emh_qlink_config_t config = { .device_type = "30531", .format = EMH_ARG_QLINK_FORMAT_JSON, }, + // .product_info = { + // .product_token = "38Szyd6i1240elbV", + // .andlink_token = "wWppJIdROfQkcsMW", + // .device_type = "30413", + // .format = EMH_ARG_QLINK_FORMAT_JSON, + // }, .version_info = { .firmware_version = "1.4.3", .software_version = "1.0.1", @@ -92,9 +98,23 @@ static void handle_user_cmd(char* pwbuf, int blen, int argc, char** argv) } } +static void handle_reboot_cmd(char* pwbuf, int blen, int argc, char** argv) +{ + + if (argc != 1) + { + app_log("input param error!!!"); + return; + } + + emh_module_reset(); + +} + struct cli_command qlinkcmds[] = { { "raw", "raw [start|stop]", handle_raw_cmd }, { "user", "start|stop", handle_user_cmd }, + { "reboot", "reboot", handle_reboot_cmd }, }; #endif diff --git a/src/cloud_qlink/cloud_qlink.c b/src/cloud_qlink/cloud_qlink.c index ec3e8c3..58f50cb 100644 --- a/src/cloud_qlink/cloud_qlink.c +++ b/src/cloud_qlink/cloud_qlink.c @@ -34,8 +34,8 @@ typedef enum { eState_M1_initialize = 1, /**< State machine: Reset and initialize module */ - eState_M2_normal_ap = 2, /**< State machine: Waiting for WiFi config */ - eState_M2_normal_cloud = 3,/** connect to WiFi successfully, waiting for cloud connection */ + eState_M2_provision = 2, /**< State machine: Waiting for WiFi config */ + eState_M2_provision_ap = 3,/** connect to WiFi successfully, waiting for cloud connection */ eState_M3_normal = 4, /**< State machine: Connected to cloud, application running */ eState_M4_disconnected = 5, /**< State machine: Disconnect to cloud, all data transmission should stop */ eState_M5_fault = 6, /**< State machine: Drop in an unexpected error */ @@ -121,7 +121,7 @@ static mx_status _handle_state_initialize(void) err = emh_qlink_config(qlink_config, true); require_noerr(err, exit); - qlink_context.device_state = eState_M2_normal_ap; + qlink_context.device_state = eState_M2_provision; exit: return err; @@ -138,11 +138,11 @@ mx_status qlink_runloop(void) break; } - case eState_M2_normal_ap: {//waitint for connect to ap + case eState_M2_provision: {//waitint for connect to ap break; } - case eState_M2_normal_cloud:{ //connect to ap successfully, buf fail to connect to cloud + case eState_M2_provision_ap:{ //connect to ap successfully, buf fail to connect to cloud qlink_context.device_state = eState_M4_disconnected; emh_qlink_service_start(); break; @@ -169,9 +169,10 @@ mx_status qlink_runloop(void) void emh_ev_wlan(emh_arg_wlan_ev_t event) { - qlink_log("Wlan event: %s", emh_arg_for_type(EMH_ARG_WLAN_EV, event)); + qlink_debug_log("Wlan event: %s", emh_arg_for_type(EMH_ARG_WLAN_EV, event)); if (event == EMH_ARG_WLAN_EV_STA_CONNECTED) { qlink_event_handler(QLINK_EVENT_WLAN_CONNECTED); + qlink_context.device_state = eState_M2_provision_ap; } else if (event == EMH_ARG_WLAN_EV_STA_DISCONNECTED) { qlink_event_handler(QLINK_EVENT_WLAN_DISCONNECTED); } else if (event == EMH_ARG_WLAN_EV_UAP_ESTABLISHED) { @@ -181,7 +182,7 @@ void emh_ev_wlan(emh_arg_wlan_ev_t event) void emh_ev_qlink_connection(emh_arg_qlink_conn_t conn) { - qlink_log("AliCloud event: %s", emh_arg_for_type(EMH_ARG_QLINK_CONN, conn)); + qlink_debug_log("AliCloud event: %s", emh_arg_for_type(EMH_ARG_QLINK_CONN, conn)); qlink_context.cloud_state = conn; diff --git a/src/cloud_qlink/cloud_qlink.h b/src/cloud_qlink/cloud_qlink.h index 15ecf95..44113ca 100644 --- a/src/cloud_qlink/cloud_qlink.h +++ b/src/cloud_qlink/cloud_qlink.h @@ -40,6 +40,7 @@ ******************************************************************************/ #define qlink_log(M, ...) MX_LOG(CONFIG_CLOUD_DEBUG, "QLINK", M, ##__VA_ARGS__) +#define qlink_debug_log(M, ...) //MX_LOG(CONFIG_CLOUD_DEBUG, "QLINK_DEBUG", M, ##__VA_ARGS__) /****************************************************************************** * Constants diff --git a/src/helper/emhost/emh_arg.c b/src/helper/emhost/emh_arg.c index 120e6c7..6ae88bb 100644 --- a/src/helper/emhost/emh_arg.c +++ b/src/helper/emhost/emh_arg.c @@ -166,8 +166,8 @@ const char* EMH_ARG_QLINK_STATUS[] = const char* EMH_ARG_QLINK_CONN[] = { - [EMH_ARG_QLINK_CONN_CLOUD_CONNECTED] = "CLOUD_CONNECT", - [EMH_ARG_QLINK_CONN_CLOUD_DISCONNECTED] = "CLOUD_DISCONNECT", + [EMH_ARG_QLINK_CONN_CLOUD_CONNECTED] = "CONNECT", + [EMH_ARG_QLINK_CONN_CLOUD_DISCONNECTED] = "DISCONNECT", [EMH_ARG_QLINK_CONN_LOCAL_CONNECTED] = "LOCAL_CONNECT", [EMH_ARG_QLINK_CONN_LOCAL_DISCONNECTED] = "LOCAL_DISCONNECT", [EMH_ARG_QLINK_CONN_MAX] = "\0",