Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lizhibo committed Oct 25, 2018
1 parent 0fc1816 commit 77414bc
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"aliosStudio.sdkPath": "/Users/miaogs/.aos/AliOS-Things"
}
20 changes: 20 additions & 0 deletions examples/qlinkapp/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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

Expand Down
15 changes: 8 additions & 7 deletions src/cloud_qlink/cloud_qlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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) {
Expand All @@ -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;

Expand Down
1 change: 1 addition & 0 deletions src/cloud_qlink/cloud_qlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/helper/emhost/emh_arg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 77414bc

Please sign in to comment.