Exemple #1
0
/* FogCloud message receive callback: handle cloud messages here
 */
OSStatus user_fogcloud_msg_handler(mico_Context_t* mico_context, 
                            const char* topic, const unsigned int topicLen,
                            unsigned char *inBuf, unsigned int inBufLen)
{
  user_log_trace();
  OSStatus err = kUnknownErr;
  mico_fogcloud_msg_t fogcloud_msg;
  int retCode = MSG_PROP_UNPROCESSED;
  
  if((NULL == mico_context) || (NULL == topic) || (0 == topicLen) ) {
    user_log("ERROR: mico_cloudmsg_dispatch params error, err=%d", err);
    return kParamErr;
  }
  
  fogcloud_msg.topic = topic;
  fogcloud_msg.topic_len = topicLen;
  fogcloud_msg.data = inBuf;
  fogcloud_msg.data_len = inBufLen;
  
  err = mico_fogcloud_msg_dispatch(mico_context, service_table, &fogcloud_msg, &retCode);    
  if(kNoErr != err){
    user_log("ERROR: mico_cloudmsg_dispatch error, err=%d", err);
  }
  else
  {
    if(MSG_PROP_WROTE == retCode){
      g_user_context.status.user_config_need_update = true;  // user params need update in flash
    }
  }
  
  return err;
}
/* user main function, called by AppFramework.
 */
OSStatus user_main( app_context_t * const app_context )
{
  user_log_trace();
  OSStatus err = kUnknownErr;
  
  user_log("User main thread start...");
  
  // start prop get/set thread
  err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "prop_recv", property_recv, 
                                STACK_SIZE_PROP_RECV_THREAD, (void*)app_context);
  require_noerr_action( err, exit, user_log("ERROR: Unable to start the prop_recv thread.") );
  
  err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "prop_update", property_update, 
                                STACK_SIZE_PROP_UPDATE_THREAD, (void*)app_context);
  require_noerr_action( err, exit, user_log("ERROR: Unable to start the prop_update thread.") );

  /* main loop for user display */
  while(1){
    // system work state show on OLED
    system_state_display(app_context);
    mico_thread_sleep(1);
  }
  
exit:
  user_log("ERROR: user_main exit with err=%d", err);
  return err;
}
Exemple #3
0
// Key1 callback: do RGB_LED test
void user_key1_clicked_callback(void)
{
  user_log_trace();
  
  user_log("user_key1_clicked_callback");
  rgb_led_test_flag = false;
  
  return;
}
Exemple #4
0
void user_key2_long_pressed_callback(void)
{
  user_log_trace();
  
  user_log("user_key2_long_pressed_callback");
  dc_motor_set(1);   // dc motor test
  
  return;
}
Exemple #5
0
// Key2 callback: do DC Motor test
void user_key2_clicked_callback(void)
{
  user_log_trace();
  
  user_log("user_key2_clicked_callback");
  dc_motor_set(0);  // dc motor test
  
  return;
}
Exemple #6
0
void user_key1_long_pressed_callback(void)
{
  user_log_trace();
  
  user_log("user_key1_long_pressed_callback");
  rgb_led_test_flag = true;
  
  return;
}
Exemple #7
0
/* user main function, called by AppFramework.
 */
OSStatus user_main( app_context_t * const app_context )
{
  user_log_trace();
  OSStatus err = kUnknownErr;
  
  user_log("User main task start...");
  
  
  
  err = user_uartInit();
  require_noerr_action( err, exit, user_log("ERROR: user_uartInit err = %d.", err) );
 
  
  
  user_log("start photo...");
  unsigned char* image="hello world";
  user_uartSend( image,strlen(image));
  char aa[200];
  
  memset(aa, '\0', 200);
  
  mico_thread_sleep(5);
  
  int len=user_uartRecv((unsigned char *)aa, 200);
  user_log("uart_data_recv: [%d][%.*s]", len,  len,(unsigned char*)aa);
  user_log("end...");
  
  
 
#if (MICO_CLOUD_TYPE != CLOUD_DISABLED)
  /* start fogcloud msg handle task */
  err = start_fog_msg_handler(app_context);
  require_noerr_action( err, exit, user_log("ERROR: start_fog_msg_handler err = %d.", err) );

  /* start properties notify task(upload data) */
  err = mico_start_properties_notify(app_context, service_table, 
                                     MICO_PROPERTIES_NOTIFY_INTERVAL_MS, 
                                     STACK_SIZE_NOTIFY_THREAD);
  require_noerr_action( err, exit, user_log("ERROR: mico_start_properties_notify err = %d.", err) );
#endif
  
  /* main loop for user display */
  while(1){
    // check every 1 seconds
    mico_thread_sleep(1);
    
    // system work state show on OLED
    system_state_display(app_context, &g_user_context);
  }
  
exit:
  user_log("ERROR: user_main exit with err=%d", err);
  return err;
}
Exemple #8
0
OSStatus start_fog_msg_handler(mico_Context_t *mico_context)
{
  user_log_trace();
  OSStatus err = kNoErr;
  require_action(mico_context, exit, err = kParamErr);
  
  err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "user_msg_handler", 
                                user_cloud_msg_handle_thread, STACK_SIZE_USER_MSG_HANDLER_THREAD, 
                                mico_context );
exit:
  return err;
}
/* user main function, called by AppFramework after system init done && wifi
 * station on in user_main thread.
 */
OSStatus user_main( app_context_t * const app_context )
{
  user_log_trace();
  OSStatus err = kUnknownErr;
  require(app_context, exit);
  
  hsb2rgb_led_init();  // rgb led init
  
  while(1){
    mico_thread_sleep(1);
    
    // system work state show on OLED
    system_state_display(app_context);
  }

exit:
  user_log("ERROR: user_main exit with err=%d", err);
  return err;
}
Exemple #10
0
/* user main function, called by AppFramework after FogCloud connected.
 */
OSStatus user_main( mico_Context_t * const mico_context )
{
  user_log_trace();
  OSStatus err = kUnknownErr;
  
  /* init user modules (pins && sensor init)*/
  err = user_modules_init();
  require_noerr_action( err, exit, user_log("ERROR: user_modules_init err=%d.", err) );
  
  /* recovery user settings from flash && set initail state of user modules */
  //err = user_settings_recovery(mico_context, &g_user_context);
  //require_noerr_action( err, exit, user_log("ERROR: user_settings_recovery err=%d.", err) );
  
#if (MICO_CLOUD_TYPE != CLOUD_DISABLED)
  /* start properties notify task */
  err = mico_start_properties_notify(mico_context, service_table, 
                                     MICO_PROPERTIES_NOTIFY_INTERVAL_MS, 
                                     STACK_SIZE_NOTIFY_THREAD);
  require_noerr_action( err, exit, user_log("ERROR: mico_start_properties_notify err = %d.", err) );
#endif
  
  while(1){
    /* user thread running state */
    user_display(&g_user_context);
    user_test(&g_user_context);
    
    /* check every 1 seconds */
    mico_thread_msleep(1000);
    
    /* save user settings into flash */
    //err = user_settings_update(mico_context, &g_user_context);
    //require_noerr_action( err, exit, user_log("ERROR: user_settings_update err=%d.", err) );
  }
  
exit:
  user_log("ERROR: user_main exit with err=%d", err);
  return err;
}
Exemple #11
0
/* user main function, called by AppFramework.
 */
OSStatus user_main( mico_Context_t * const mico_context )
{
  user_log_trace();
  OSStatus err = kUnknownErr;
  
  user_log("User main task start...");
  
  err = user_uartInit();
  require_noerr_action( err, exit, user_log("ERROR: user_uartInit err = %d.", err) );
  
  user_log("user_uartInit ok");
 
#if (MICO_CLOUD_TYPE != CLOUD_DISABLED)
  /* start fogcloud msg handle task */
  err = start_fog_msg_handler(mico_context);
  require_noerr_action( err, exit, user_log("ERROR: start_fog_msg_handler err = %d.", err) );

  /* start properties notify task(upload data) */
  err = mico_start_properties_notify(mico_context, service_table, 
                                     MICO_PROPERTIES_NOTIFY_INTERVAL_MS, 
                                     STACK_SIZE_NOTIFY_THREAD);
  require_noerr_action( err, exit, user_log("ERROR: mico_start_properties_notify err = %d.", err) );
#endif
  
  
  /* main loop for user display */
  while(1){
    // check every 1 seconds
    mico_thread_sleep(1);
    
    // system work state show on OLED
    system_state_display(mico_context, &g_user_context);
  }
  
exit:
  user_log("ERROR: user_main exit with err=%d", err);
  return err;
}
/* user main function, called by AppFramework after system init done && wifi
 * station on in user_main thread.
 */
OSStatus user_main( app_context_t * const app_context )
{
    user_log_trace();
    OSStatus err = kUnknownErr;
    json_object *send_json_object = NULL;
    const char *upload_data = NULL;

    uint8_t ret = 0;
    uint8_t dht11_temperature = 0;
    uint8_t dht11_humidity = 0;

    // update 2~4 lines on OLED
    char oled_show_line[OLED_DISPLAY_MAX_CHAR_PER_ROW+1] = {'\0'};

    require(app_context, exit);

    // init humiture sensor DHT11
    ret = DHT11_Init();
    if(0 != ret)   // init error
    {
        err = kNoResourcesErr;
        user_log("DHT11 init failed!");
        goto exit;
    }
    else
    {
        err = kNoErr;
    }

    while(1)
    {
        mico_thread_sleep(2);  // data acquisition && upload every 2 seconds

        // check fogcloud connect status
        if(!app_context->appStatus.fogcloudStatus.isCloudConnected)
        {
            continue;
        }

        // fogcloud connected, do data acquisition
        ret = DHT11_Read_Data(&dht11_temperature, &dht11_humidity);
        if(0 != ret)
        {
            err = kReadErr;
        }
        else
        {
            err = kNoErr;

            // temperature/humidity display on OLED, each line 16 chars max
            OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_2, "Demo Read H/T   ");  // clean line2

            memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1);
            snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "T: %2dC         ", dht11_temperature);
            OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_3, (uint8_t*)oled_show_line);

            memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1);
            snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "H: %2d%%        ", dht11_humidity);
            OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_4, (uint8_t*)oled_show_line);

            // create json object && upload to cloud
            send_json_object = json_object_new_object();
            if(NULL == send_json_object)
            {
                user_log("create json object error!");
                err = kNoMemoryErr;
            }
            else
            {
                // create json object && data string to upload
                json_object_object_add(send_json_object, "dht11_temperature", json_object_new_int(dht11_temperature));
                json_object_object_add(send_json_object, "dht11_humidity", json_object_new_int(dht11_humidity));
                upload_data = json_object_to_json_string(send_json_object);
                if(NULL == upload_data)
                {
                    user_log("create upload data string error!");
                    err = kNoMemoryErr;
                }
                else
                {
                    // upload data string to fogcloud, the seconde param(NULL) means send to defalut topic: '<device_id>/out'
                    MiCOFogCloudMsgSend(app_context, NULL, (unsigned char*)upload_data, strlen(upload_data));
                    user_log("upload data success!\r\ntopic=%s/out\tdht11_temperature=%d, dht11_humidity=%d",
                             app_context->appConfig->fogcloudConfig.deviceId,
                             dht11_temperature, dht11_humidity);
                    err = kNoErr;
                }

                // free json object memory
                json_object_put(send_json_object);
                send_json_object = NULL;
            }
        }
    }

exit:
    user_log("ERROR: user_main exit with err=%d", err);
    return err;
}
static void health_thread(void* arg)
{
    app_context_t *app_context = (app_context_t *)arg;
    user_log_trace();
    EKey ot;

#if 0
    u8 cup_status_temp, cup_status;

    cup_status = cup_status_temp = KEY_getValue();
#endif
  
    /* thread loop */
    while(1){
#if 1
        ot = GetOuterTriggerStatus();
        if(OUTERTRIGGER_PICKUP == ot) {
            SetDrinkPutStatus(true);

            if(IsDrinkPutStatusChanged()) {
                SendJsonBool(app_context, "HEALTH-1/DrinkPutStatus", GetDrinkPutStatus());
                if(!NoDisturbing() && IsPickupSetting()) {
                    u8 type;
                    u16 track_id;
                    
                    FindPickupTrack(&type, &track_id);
                    AaSysLogPrint(LOGLEVEL_DBG, "track type %d index %d will be played", type, track_id);
                    // stop last track before play new song
                    SendQuitReq();
                    SendPlayReq(type, track_id);
                }
            }
        }
        else if(OUTERTRIGGER_PUTDOWN == ot) {
            SetDrinkPutStatus(false);

            if(IsDrinkPutStatusChanged()) {
                SendJsonBool(app_context, "HEALTH-1/DrinkPutStatus", GetDrinkPutStatus());
                if(!NoDisturbing() && IsPutDownSetting()) {
                    startPutDownTimerGroup();
                }
            }
        }

        mico_thread_msleep(100);
#elif
        if(mico_rtos_get_semaphore(&semaphore_getup, CHECK_CUPSTATUS_TIMEOUT)) {
            // key fliter
            cup_status_temp = KEY_getValue();
            if(cup_status != cup_status_temp) {
                cup_status = cup_status_temp;
                
                SetDrinkStamp(true);
                
                if(!NoDisturbing() && IsPickupSetting()) {
                    PlayingSong(FindPickupTrack());
                }
            }
        }

        if(mico_rtos_get_semaphore(&semaphore_putdown, CHECK_CUPSTATUS_TIMEOUT)) {
            // key fliter
            cup_status_temp = KEY_getValue();
            if(cup_status != cup_status_temp) {
                cup_status = cup_status_temp;
                
                SetPutDownStamp(true);

                if(!NoDisturbing() && IsPutDownSetting()) {
                    startPutDownTimerGroup();
                }
            }
        }
#endif
    }
}
Exemple #14
0
/* Handle user message from cloud
 * Receive msg from cloud && do hardware operation
 */
void downstream_thread(void* arg)
{
    user_log_trace();
    OSStatus err = kUnknownErr;
    mico_Context_t *app_context = (mico_Context_t *)arg;
    fogcloud_msg_t *recv_msg = NULL;
    json_object *recv_json_object = NULL;
    
    require(app_context, exit);
    
    while(1) {
        mico_thread_sleep(1);
        if(!MicoFogCloudIsConnect(app_context)) {
            user_log("appStatus.fogcloudStatus.isCloudConnected = false");
            //mico_thread_sleep(1);
            continue;
        }
        
        // recv_msg->data = <topic><data>
        err = MicoFogCloudMsgRecv(app_context, &recv_msg, 1000);
        user_log("err = %d", err);
        if(kNoErr == err){
            user_log("Msg recv: topic[%d]=[%.*s]\tdata[%d]=[%.*s]", 
                    recv_msg->topic_len, recv_msg->topic_len, recv_msg->data, 
                    recv_msg->data_len, recv_msg->data_len, recv_msg->data + recv_msg->topic_len);
            
            recv_json_object = json_tokener_parse((const char*)recv_msg->data + recv_msg->topic_len);
            if(NULL != recv_json_object) {
                user_log("recv_json_object != NULL");
                
                // parse json object
                char *key; struct json_object *val; struct lh_entry *entry;

                for(entry = json_object_get_object(recv_json_object)->head; \
                        (entry ? (key = (char*)entry->k, val = (struct json_object*)entry->v, entry) : 0); \
                        entry = entry->next) {
                    if(!strcmp(key, "energy")){
                        SetEnergyValue(json_object_get_int(val));
                    }
                    else if(!strcmp(key, "interval")) {
                        SetIntervalValue(json_object_get_int(val));
                    }
                    else if(!strcmp(key, "lights")) {
                        SetLightsValue(json_object_get_int(val));
                    }
                    else if(!strcmp(key, "remind")) {
                        SetRemindValue(json_object_get_int(val));
                    }
                    else if(!strcmp(key, "volume")) {
                        SetVolumeValue(json_object_get_int(val));
                    }
                    else if(!strcmp(key, "subscribe")) {
                        subscribe = json_object_get_boolean(val);
                        user_log("subscribe = %d", (int)subscribe);
                    }
                    else if(!strcmp(key, "track")) {
                        //track = json_object_get_string(val);
                    }
                    else if(!strcmp(key, "url_path")) {
                        //url_path = json_object_get_string(val);
                    }
                }
            }
            
            // free memory of json object
            json_object_put(recv_json_object);
            recv_json_object = NULL;
        }
        
        // NOTE: must free msg memory after been used.
        if(NULL != recv_msg){
            free(recv_msg);
            recv_msg = NULL;
        }
    }
    
exit:
    if(kNoErr != err){
        user_log("ERROR: downstream_thread_handle thread exit with err=%d", err);
    }
    
    mico_rtos_delete_thread(NULL);  // delete current thread
}
Exemple #15
0
/* Message upload thread
 * Get DHT11 temperature/humidity data && upload to cloud
 */
void user_upstream_thread(void* arg)
{
  user_log_trace();
  OSStatus err = kUnknownErr;
  mico_Context_t *mico_context = (mico_Context_t *)arg;
  json_object *send_json_object = NULL;
  const char *upload_data = NULL;
  uint8_t ret = 0;
    
  require(mico_context, exit);
  
  
  /* init humiture sensor DHT11 */
  /*
  do{
    ret = DHT11_Init();
    if(0 != ret){  // init error
      user_log("DHT11 init failed!");
      err = kNoResourcesErr;
      mico_thread_sleep(1);  // sleep 1s then retry
    }
    else{
      err = kNoErr;
      break;
    }
  }while(kNoErr != err);
  */
  /* thread loop */
  while(1){
    // do data acquisition
    /*
    ret = DHT11_Read_Data(&dht11_temperature, &dht11_humidity);
    if(0 != ret){
      err = kReadErr;
    }
    else
      */
    {
      err = kNoErr;
      dht11_temperature = 25;
      dht11_humidity = 30;
      // create json object to format upload data
      send_json_object = json_object_new_object();
      if(NULL == send_json_object){
        user_log("create json object error!");
        err = kNoMemoryErr;
      }
      else{
        // add temperature/humidity data into a json oject
        json_object_object_add(send_json_object, "dht11_temperature", json_object_new_int(dht11_temperature)); 
        json_object_object_add(send_json_object, "dht11_humidity", json_object_new_int(dht11_humidity)); 
        upload_data = json_object_to_json_string(send_json_object);
        if(NULL == upload_data){
          user_log("create upload data string error!");
          err = kNoMemoryErr;
        }
        else{
          // check fogcloud connect status
          if(mico_context->appStatus.fogcloudStatus.isCloudConnected){
            // upload data string to fogcloud, the seconde param(NULL) means send to defalut topic: '<device_id>/out'
            MicoFogCloudMsgSend(mico_context, NULL, (unsigned char*)upload_data, strlen(upload_data));
            user_log("upload data success! \t topic=%s/out \t dht11_temperature=%d, dht11_humidity=%d", 
                     mico_context->flashContentInRam.appConfig.fogcloudConfig.deviceId,
                     dht11_temperature, dht11_humidity);
            err = kNoErr;
          }
        }
        
        // free json object memory
        json_object_put(send_json_object);
        send_json_object = NULL;
      }
    }
    
    mico_thread_sleep(2);  // data acquisition && upload every 2 seconds
  }

exit:
  if(kNoErr != err){
    user_log("ERROR: user_uptream exit with err=%d", err);
  }
  mico_rtos_delete_thread(NULL);  // delete current thread
}
/* user main function, called by AppFramework after system init done && wifi
 * station on in user_main thread.
 */
OSStatus user_main( app_context_t * const app_context )
{
  user_log_trace();
  OSStatus err = kUnknownErr;
  unsigned char rdata[64];
  unsigned char sdata[64];
  uint16_t datalen;

  require(app_context, exit);

  // platform initialize
  AaSysComInit();
  AaSysLogInit();

  // application initialize
  ControllerBusInit();
  OuterTriggerInit(NULL);
  TemperatureInit();  // will be support in release 2
  BatteryInit();

  // reset f411 and wait until it startup
  ResetF411();

#if 1
  MOInit();
#endif

  err = SntpInit(app_context);
  if(kNoErr != err) {
    AaSysLogPrint(LOGLEVEL_ERR, "SntpInit finished with err code %d", err);
  }
  else {
    AaSysLogPrint(LOGLEVEL_INF, "SntpInit success");
  }

#if 1
  DeviceInit(app_context);
  HealthInit(app_context);
  LightsInit(app_context);
  MusicInit(app_context);

  // start the downstream thread to handle user command
  err = mico_rtos_create_thread(&user_downstrem_thread_handle, MICO_APPLICATION_PRIORITY, "user_downstream", 
                                user_downstream_thread, STACK_SIZE_USER_DOWNSTREAM_THREAD, 
                                app_context );
  require_noerr_action( err, exit, user_log("ERROR: create user_downstream thread failed!") );
#endif


  user_log("[DBG]net_main: Appilcation Initialize success @"SOFTWAREVERSION);

  // user_main loop, update oled display every 1s
  while(1){

#if 1
    mico_thread_sleep(MICO_WAIT_FOREVER);
#else

    mico_thread_sleep(5);

    datalen = user_uartRecv(rdata, 5);
    if(datalen) {
      user_log("[DBG]user_main: Usart recevice datalen %d", datalen);
      user_log("[DBG]user_main: receive %.*s", datalen, rdata);
    }
    else {
      user_log("[DBG]user_main: Usart didn't recevice data");
    }

    mico_thread_sleep(2);

    sprintf(sdata, "hello, world!\r\n");
    user_uartSend(sdata, strlen(sdata));
#endif

  }

exit:
  if(kNoErr != err){
    user_log("[ERR]user_main: user_main thread exit with err=%d", err);
  }
  mico_rtos_delete_thread(NULL);  // delete current thread
  return err;
}
Exemple #17
0
void user2_upstream_thread(void* arg)
{
  user_log_trace();
  OSStatus err = kUnknownErr;
  app_context_t *app_context = (app_context_t *)arg;
  
  json_object *send_json_object = NULL;
  const char *upload_data = NULL;
  
 
//  user_log("ip address is :%s", ip_address);
  mico_rtos_init_semaphore( &switch_change_sem, 1);
  
  require(app_context, exit);
  
  /* thread loop */
  while(1){
    
    mico_rtos_get_semaphore(&switch_change_sem, MICO_WAIT_FOREVER);
    
    // create json object to format upload data
    send_json_object = json_object_new_object();
    if(NULL == send_json_object){
      user_log("create json object error!");
      err = kNoMemoryErr;
    }
    else{
      
      switch (msg_id )
      {
      case 1:
        {
          json_object_object_add(send_json_object, "lamp_switch", json_object_new_boolean(lamp_switch));
          break;
        }
      case 2:
        {
          json_object_object_add(send_json_object, "pump_switch", json_object_new_boolean(pump_switch)); 
          break;
        }
      case 3:
        {
          json_object_object_add(send_json_object, "ip_address", json_object_new_string(app_context->mico_context->micoStatus.localIp)); 
          break;
        }
      case 4:
        {
          json_object_object_add(send_json_object, "hasImage", json_object_new_boolean(true)); 
          break;
        }
      default:
        {
          break;
        }
      }   
      // add temperature/humidity data into a json oject
      upload_data = json_object_to_json_string(send_json_object);
      if(NULL == upload_data){
        user_log("create upload data string error!");
        err = kNoMemoryErr;
      }
      else{
        // check fogcloud connect status
        if(app_context->appStatus.fogcloudStatus.isCloudConnected){
          // upload data string to fogcloud, the seconde param(NULL) means send to defalut topic: '<device_id>/out'
          MiCOFogCloudMsgSend(app_context, NULL, (unsigned char*)upload_data, strlen(upload_data));
          //            user_log("upload data success! \t topic=%s/out \t dht11_temperature=%d, dht11_humidity=%d", 
          //                     app_context->appConfig->fogcloudConfig.deviceId,
          //                     dht11_temperature, dht11_humidity);
          err = kNoErr;
        }
      }
    }
    // free json object memory
    json_object_put(send_json_object);
    send_json_object = NULL;    
    
  }
exit:
  if(kNoErr != err){
    user_log("ERROR: user_uptream exit with err=%d", err);
  }
  mico_rtos_delete_thread(NULL);  // delete current thread
  
}