コード例 #1
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 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;
}
コード例 #2
0
ファイル: user_main.c プロジェクト: karlnet/mico
/* 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;
}
コード例 #3
0
/* 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;
}
コード例 #4
0
ファイル: user_main.c プロジェクト: bangkr/MiCO_ELink407
/* 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;
}