Exemplo n.º 1
0
void ConfigEasyLinkIsSuccess( mico_Context_t * const inContext )
{
  (void)(inContext); 
  config_delegate_log_trace();
#ifdef USE_MiCOKit_EXT
  char oled_show_line[OLED_DISPLAY_MAX_CHAR_PER_ROW+1] = {'\0'};
#endif

  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  mico_init_timer(&_Led_EL_timer, SYS_LED_TRIGGER_INTERVAL_AFTER_EASYLINK, _led_EL_Timeout_handler, NULL);
  mico_start_timer(&_Led_EL_timer);
#ifdef USE_MiCOKit_EXT
  memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1);
  snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"EasyLink got    ");
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_2, (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, "%16s", inContext->flashContentInRam.micoSystemConfig.ssid);
  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, "%16s", inContext->flashContentInRam.micoSystemConfig.user_key);
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_4, (uint8_t*)oled_show_line);
#endif
  return;
}
Exemplo n.º 2
0
void ConfigSoftApWillStart(mico_Context_t * const inContext )
{
  //OSStatus err;
  //mico_uart_config_t uart_config;

  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  mico_init_timer(&_Led_EL_timer, SYS_LED_TRIGGER_INTERVAL_AFTER_EASYLINK, _led_EL_Timeout_handler, NULL);
  mico_start_timer(&_Led_EL_timer);
  
//  sppProtocolInit(inContext);
//  
//   /*UART receive thread*/
//  uart_config.baud_rate    = inContext->flashContentInRam.appConfig.USART_BaudRate;
//  uart_config.data_width   = DATA_WIDTH_8BIT;
//  uart_config.parity       = NO_PARITY;
//  uart_config.stop_bits    = STOP_BITS_1;
//  uart_config.flow_control = FLOW_CONTROL_DISABLED;
//  ring_buffer_init  ( (ring_buffer_t *)&rx_buffer, (uint8_t *)rx_data, UART_BUFFER_LENGTH );
//  MicoUartInitialize( UART_FOR_APP, &uart_config, (ring_buffer_t *)&rx_buffer );
//  err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "UART Recv", uartRecv_thread, STACK_SIZE_UART_RECV_THREAD, (void*)inContext );
//  require_noerr_action( err, exit, config_delegate_log("ERROR: Unable to start the uart recv thread.") );
//
// if(inContext->flashContentInRam.appConfig.localServerEnable == true){
//   err = mico_rtos_create_thread(NULL, MICO_APPLICATION_PRIORITY, "Local Server", localTcpServer_thread, STACK_SIZE_LOCAL_TCP_SERVER_THREAD, (void*)inContext );
//   require_noerr_action( err, exit, config_delegate_log("ERROR: Unable to start the local server thread.") );
// }

//exit:
  return;
}
Exemplo n.º 3
0
static void led_init_handle(void *inContext)
{
    nearair_Context_t *airContent = inContext;
    static char color_count = 0;
    if( MODE_INIT != airContent->deviceStatus.mode )
    {
      mico_stop_timer(&_led_init_timer);
      mico_deinit_timer(&_led_init_timer);
    }
    switch(color_count)
    {
    case 0:
      set_led_color(99,0,0);
      color_count = 1;
      break;
    case 1:
      set_led_color(99,50,0);
      color_count = 2;
      break;
    case 2:
      set_led_color(0,0,99);
      color_count = 0;
      break;
    default:
      break;
    }
}
WEAK void mico_system_delegate_config_will_stop( void )
{
  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  MicoSysLed(true);
  return;
}
Exemplo n.º 5
0
//tmr.start(id,interval,function)
//id:0~15
static int ltmr_start( lua_State* L )
{
  unsigned id = luaL_checkinteger( L, 1 );
  MOD_CHECK_ID( tmr, id);
  
  unsigned interval = luaL_checkinteger( L, 2 );
  if ( interval <= 0 ) 
    return luaL_error( L, "wrong arg range" );
  
  if (lua_type(L, 3) == LUA_TFUNCTION || lua_type(L, 3) == LUA_TLIGHTFUNCTION)
  {
    lua_pushvalue(L, 3);  // copy argument (func) to the top of stack
    if(tmr_cb_ref[id] != LUA_NOREF)
    {
      luaL_unref(L, LUA_REGISTRYINDEX, tmr_cb_ref[id]);
    }
    gL = L;
    tmr_cb_ref[id] = luaL_ref(L, LUA_REGISTRYINDEX);

    mico_stop_timer(&_timer[id]);
    mico_deinit_timer( &_timer[id] );
    mico_init_timer(&_timer[id], interval, _tmr_handler, (void*)id);
    mico_start_timer(&_timer[id]);    
    tmr_is_started[id] = true;   
  }
  else
    return luaL_error( L, "callback function needed" );
  
  return 0;
}
static void startPutDownTimerGroup()
{
    u8 idx;
    
    for(idx = 0; idx < MAX_DEPTH_PUTDOWN; idx++) {
        if(!GetPutDownEnable(idx)) {
            continue;
        }

        if(GetPutDownRemindDelay(idx) == 0) {
            u8 type = GetPutDownTrackType(idx);
            u16 track_id = GetPutDownSelTrack(idx);
            AaSysLogPrint(LOGLEVEL_DBG, "track type %d index %d will be played", type, track_id);
            SendQuitReq();
            SendPlayReq(type, track_id);
        }
        else {
            // if another putdown action trigger, reset last timers
            if(mico_is_timer_running(&putdown_timer[idx].timer)) {
                mico_stop_timer(&putdown_timer[idx].timer);
                mico_deinit_timer(&putdown_timer[idx].timer);
            }
            
            mico_init_timer(&putdown_timer[idx].timer, 
                            GetPutDownRemindDelay(idx)*60*UpTicksPerSecond(), 
                            PutdownTimeout, 
                            &putdown_timer[idx]);
            mico_start_timer(&putdown_timer[idx].timer);
        }
    }
}
Exemplo n.º 7
0
void ConfigSoftApWillStart(mico_Context_t * const inContext )
{
  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  mico_init_timer(&_Led_EL_timer, SYS_LED_TRIGGER_INTERVAL_AFTER_EASYLINK, _led_EL_Timeout_handler, NULL);
  mico_start_timer(&_Led_EL_timer);
}
WEAK void mico_system_delegate_config_will_start( void )
{
    /*Led trigger*/
  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  mico_init_timer(&_Led_EL_timer, SYS_LED_TRIGGER_INTERVAL, _led_EL_Timeout_handler, NULL);
  mico_start_timer(&_Led_EL_timer);
  return;
}
WEAK void mico_system_delegate_config_recv_ssid ( char *ssid, char *key )
{
  UNUSED_PARAMETER(ssid);
  UNUSED_PARAMETER(key);
  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  mico_init_timer(&_Led_EL_timer, SYS_LED_TRIGGER_INTERVAL_AFTER_EASYLINK, _led_EL_Timeout_handler, NULL);
  mico_start_timer(&_Led_EL_timer);
  return;
}
Exemplo n.º 10
0
void ConfigWillStop( mico_Context_t * const inContext )
{
  (void)(inContext); 
  config_delegate_log_trace();

  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  MicoGpioOutputLow((mico_gpio_t)MICO_SYS_LED);
  return;
}
Exemplo n.º 11
0
static void led_sleep_handle(void *inContext)
{
    nearair_Context_t *airContent = inContext;
    static uint8_t count = 0;
    static uint8_t R;
    uint8_t pluse_count = 0;
    if(MODE_SLEEP != airContent->deviceStatus.mode)
    {
        mico_stop_timer(&_led_sleep_timer);
        mico_deinit_timer(&_led_sleep_timer);
    }
    switch(airContent->sensorStatus.light)
    {
    case NIGHT:
      R = 130;
      break;
    case DAY:
      R = 100;
      break;
    default:
      break;
    }
    count += 1;
    if(count > 200)
    {
      count = 0;
      return;
    }
    if(count < 100)
    {
      pluse_count = R - (int)sqrt(R*R - count*count);
    }
    if(count > 100)
    {
      pluse_count = R - (int)sqrt(R*R - (200 - count)*(200 - count));
      
    }
    if(pluse_count < 3)//避免灯灭导致闪烁感
      return;
    set_led_color(0,0,pluse_count);
/*    switch(airContext->airStatus.airclass)
    {
    case AQ_GOOD:
      set_led_color(0,0,pluse_count);
      break;
    case AQ_SOSO:
      set_led_color(pluse_count,2+(int)(0.3*pluse_count),0);
      break;
    case AQ_BAD:
      set_led_color(pluse_count,0,0);
      break;
    default:
      break;
    }*/
}
Exemplo n.º 12
0
void ConfigAirkissIsSuccess( mico_Context_t * const inContext )
{
  (void)(inContext); 
  config_delegate_log_trace();

  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  mico_init_timer(&_Led_EL_timer, SYS_LED_TRIGGER_INTERVAL_AFTER_EASYLINK, _led_EL_Timeout_handler, NULL);
  mico_start_timer(&_Led_EL_timer);
  return;
}
static void PutdownTimeout(void* arg)
{
    SMngTimer* mng = (SMngTimer*)arg;

    mico_deinit_timer(&mng->timer);
    
    // if this putdown tag is disable during timer timeout, do not need to play song
    if(GetPutDownEnable(mng->index)) {
        u8 type = GetPutDownTrackType(mng->index);
        u16 track_id = GetPutDownSelTrack(mng->index);
        AaSysLogPrint(LOGLEVEL_DBG, "track type %d index %d will be played", type, track_id);
        SendQuitReq();
        SendPlayReq(type, track_id);
    }
}
Exemplo n.º 14
0
void ConfigWillStop( mico_Context_t * const inContext )
{
  (void)(inContext); 
  config_delegate_log_trace();
#ifdef USE_MiCOKit_EXT
  char oled_show_line[OLED_DISPLAY_MAX_CHAR_PER_ROW+1] = {'\0'};
#endif

  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  MicoGpioOutputLow((mico_gpio_t)MICO_SYS_LED);
#ifdef USE_MiCOKit_EXT
  memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1);
  snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"Config          ");
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_2, (uint8_t*)oled_show_line);
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_3, "    Stop.       ");
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_4, "                ");
#endif
  return;
}
Exemplo n.º 15
0
void OTASuccess( mico_Context_t * const inContext )
{
  //config_delegate_log_trace();
  (void)(inContext); 
#ifdef USE_MiCOKit_EXT
  char oled_show_line[OLED_DISPLAY_MAX_CHAR_PER_ROW+1] = {'\0'};
#endif
  
  // led stop
  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  MicoSysLed(true);

#ifdef USE_MiCOKit_EXT
  memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1);
  snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"OTA...          ");
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_2, (uint8_t*)oled_show_line);
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_3, (uint8_t*)"  Success!      ");
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_4, (uint8_t*)"    reboot...   ");
#endif
  return;
}
Exemplo n.º 16
0
void ConfigSoftApWillStart(mico_Context_t * const inContext )
{
#ifdef USE_MiCOKit_EXT
  char oled_show_line[OLED_DISPLAY_MAX_CHAR_PER_ROW+1] = {'\0'};
#endif
  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  mico_init_timer(&_Led_EL_timer, SYS_LED_TRIGGER_INTERVAL_AFTER_EASYLINK, _led_EL_Timeout_handler, NULL);
  mico_start_timer(&_Led_EL_timer);
#ifdef USE_MiCOKit_EXT
  snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", "SoftAP...       ");
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_2, (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, " EasyLink_%c%c%c%c%c%c", 
           inContext->micoStatus.mac[9],  inContext->micoStatus.mac[10],
           inContext->micoStatus.mac[12], inContext->micoStatus.mac[13],
           inContext->micoStatus.mac[15], inContext->micoStatus.mac[16] );
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_3, (uint8_t*)oled_show_line);
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_4, "                ");
#endif

  return;
}
Exemplo n.º 17
0
void mico_system_delegate_config_recv_ssid ( char *ssid, char *key )
{
  config_delegate_log_trace();
#ifdef USE_MiCOKit_EXT
  char oled_show_line[OLED_DISPLAY_MAX_CHAR_PER_ROW+1] = {'\0'};
#endif

  mico_stop_timer(&_Led_EL_timer);
  mico_deinit_timer( &_Led_EL_timer );
  mico_init_timer(&_Led_EL_timer, SYS_LED_TRIGGER_INTERVAL_AFTER_EASYLINK, _led_EL_Timeout_handler, NULL);
  mico_start_timer(&_Led_EL_timer);
  
#ifdef USE_MiCOKit_EXT
  memset(oled_show_line, '\0', OLED_DISPLAY_MAX_CHAR_PER_ROW+1);
  snprintf(oled_show_line, OLED_DISPLAY_MAX_CHAR_PER_ROW+1, "%s", (uint8_t*)"Got ssid/key    ");
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_2, (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, "%16s", ssid);
  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, "%16s", key);
  OLED_ShowString(OLED_DISPLAY_COLUMN_START, OLED_DISPLAY_ROW_4, (uint8_t*)oled_show_line);
#endif
}
void destroy_timer( void )
{
  mico_stop_timer( &timer_handle );
  mico_deinit_timer( &timer_handle );
}