示例#1
0
static void micoNotify_WifiStatusHandler(WiFiEvent event, mico_Context_t * const inContext)
{
  system_log_trace();
  (void)inContext;
  switch (event) {
  case NOTIFY_STATION_UP:
    system_log("Station up");
    MicoRfLed(true);
    break;
  case NOTIFY_STATION_DOWN:
    system_log("Station down");
    MicoRfLed(false);
    break;
  case NOTIFY_AP_UP:
    system_log("uAP established");
    MicoRfLed(true);
    break;
  case NOTIFY_AP_DOWN:
    system_log("uAP deleted");
    MicoRfLed(false);
    break;
  default:
    break;
  }
  return;
}
示例#2
0
static void micoNotify_WlanFatalErrHandler(mico_Context_t * const inContext)
{
  system_log_trace();
  (void)inContext;
  system_log("Wlan Fatal Err!");
  MicoSystemReboot();
}
示例#3
0
static void micoNotify_StackOverflowErrHandler(char *taskname, mico_Context_t * const inContext)
{
  system_log_trace();
  (void)inContext;
  system_log("Thread %s overflow, system rebooting", taskname);
  MicoSystemReboot();
}
示例#4
0
void system_connect_wifi_fast( mico_Context_t * const inContext)
{
  system_log_trace();
  network_InitTypeDef_adv_st wNetConfig;
  memset(&wNetConfig, 0x0, sizeof(network_InitTypeDef_adv_st));
  
  mico_rtos_lock_mutex(&inContext->flashContentInRam_mutex);
  strncpy((char*)wNetConfig.ap_info.ssid, inContext->flashContentInRam.micoSystemConfig.ssid, maxSsidLen);
  memcpy(wNetConfig.ap_info.bssid, inContext->flashContentInRam.micoSystemConfig.bssid, 6);
  wNetConfig.ap_info.channel = inContext->flashContentInRam.micoSystemConfig.channel;
  wNetConfig.ap_info.security = inContext->flashContentInRam.micoSystemConfig.security;
  memcpy(wNetConfig.key, inContext->flashContentInRam.micoSystemConfig.key, inContext->flashContentInRam.micoSystemConfig.keyLength);
  wNetConfig.key_len = inContext->flashContentInRam.micoSystemConfig.keyLength;
  if(inContext->flashContentInRam.micoSystemConfig.dhcpEnable == true)
    wNetConfig.dhcpMode = DHCP_Client;
  else
    wNetConfig.dhcpMode = DHCP_Disable;
  strncpy((char*)wNetConfig.local_ip_addr, inContext->flashContentInRam.micoSystemConfig.localIp, maxIpLen);
  strncpy((char*)wNetConfig.net_mask, inContext->flashContentInRam.micoSystemConfig.netMask, maxIpLen);
  strncpy((char*)wNetConfig.gateway_ip_addr, inContext->flashContentInRam.micoSystemConfig.gateWay, maxIpLen);
  strncpy((char*)wNetConfig.dnsServer_ip_addr, inContext->flashContentInRam.micoSystemConfig.dnsServer, maxIpLen);
  mico_rtos_unlock_mutex(&inContext->flashContentInRam_mutex);

  wNetConfig.wifi_retry_interval = 100;
  system_log("Connect to %s.....", wNetConfig.ap_info.ssid);
  micoWlanStartAdv(&wNetConfig);
}
// for station connect ap error state(no station down event when AP down)
static void appNotify_ConnectFailedHandler(OSStatus err, mico_Context_t * const inContext)
{
  system_log_trace();
  (void)inContext;
  app_log("Wlan Connection Err %d", err);
  if(NULL != app_context_global){
    app_context_global->appStatus.isWifiConnected = false;
    MicoRfLed(false);
  }
}
USED void PlatformStandbyButtonClickedCallback(void)
{
    system_log_trace();
    mico_Context_t* context = NULL;

    context = mico_system_context_get( );
    require( context, exit );

    mico_system_power_perform( context, eState_Standby );

exit:
    return;
}
示例#7
0
static void micoNotify_DHCPCompleteHandler(IPStatusTypedef *pnet, mico_Context_t * const inContext)
{
  system_log_trace();
  require(inContext, exit);
  mico_rtos_lock_mutex(&inContext->flashContentInRam_mutex);
  strcpy((char *)inContext->micoStatus.localIp, pnet->ip);
  strcpy((char *)inContext->micoStatus.netMask, pnet->mask);
  strcpy((char *)inContext->micoStatus.gateWay, pnet->gate);
  strcpy((char *)inContext->micoStatus.dnsServer, pnet->dns);
  mico_rtos_unlock_mutex(&inContext->flashContentInRam_mutex);
exit:
  return;
}
USED void PlatformEasyLinkButtonLongPressedCallback(void)
{
    system_log_trace();
    mico_Context_t* context = NULL;

    context = mico_system_context_get( );
    require( context, exit );

    mico_system_context_restore( context );

    mico_system_power_perform( context, eState_Software_Reset );

exit:
    return;
}
示例#9
0
static void micoNotify_WiFIParaChangedHandler(apinfo_adv_t *ap_info, char *key, int key_len, mico_Context_t * const inContext)
{
  system_log_trace();
  bool _needsUpdate = false;
  require(inContext, exit);
  mico_rtos_lock_mutex(&inContext->flashContentInRam_mutex);
  if(strncmp(inContext->flashContentInRam.micoSystemConfig.ssid, ap_info->ssid, maxSsidLen)!=0){
    strncpy(inContext->flashContentInRam.micoSystemConfig.ssid, ap_info->ssid, maxSsidLen);
    _needsUpdate = true;
  }

  if(memcmp(inContext->flashContentInRam.micoSystemConfig.bssid, ap_info->bssid, 6)!=0){
    memcpy(inContext->flashContentInRam.micoSystemConfig.bssid, ap_info->bssid, 6);
    _needsUpdate = true;
  }

  if(inContext->flashContentInRam.micoSystemConfig.channel != ap_info->channel){
    inContext->flashContentInRam.micoSystemConfig.channel = ap_info->channel;
    _needsUpdate = true;
  }
  
  if(inContext->flashContentInRam.micoSystemConfig.security != ap_info->security){
    inContext->flashContentInRam.micoSystemConfig.security = ap_info->security;
    _needsUpdate = true;
  }

  if(memcmp(inContext->flashContentInRam.micoSystemConfig.key, key, maxKeyLen)!=0){
    memcpy(inContext->flashContentInRam.micoSystemConfig.key, key, maxKeyLen);
    _needsUpdate = true;
  }

  if(inContext->flashContentInRam.micoSystemConfig.keyLength != key_len){
    inContext->flashContentInRam.micoSystemConfig.keyLength = key_len;
    _needsUpdate = true;
  }

  if(_needsUpdate== true)  
    mico_system_context_update( inContext );
  mico_rtos_unlock_mutex(&inContext->flashContentInRam_mutex);
  
exit:
  return;
}
示例#10
0
void system_connect_wifi_normal( mico_Context_t * const inContext)
{
  system_log_trace();
  network_InitTypeDef_adv_st wNetConfig;
  memset(&wNetConfig, 0x0, sizeof(network_InitTypeDef_adv_st));
  
  mico_rtos_lock_mutex(&inContext->flashContentInRam_mutex);
  strncpy((char*)wNetConfig.ap_info.ssid, inContext->flashContentInRam.micoSystemConfig.ssid, maxSsidLen);
  wNetConfig.ap_info.security = SECURITY_TYPE_AUTO;
  memcpy(wNetConfig.key, inContext->flashContentInRam.micoSystemConfig.user_key, maxKeyLen);
  wNetConfig.key_len = inContext->flashContentInRam.micoSystemConfig.user_keyLength;
  wNetConfig.dhcpMode = inContext->flashContentInRam.micoSystemConfig.dhcpEnable;
  strncpy((char*)wNetConfig.local_ip_addr, inContext->flashContentInRam.micoSystemConfig.localIp, maxIpLen);
  strncpy((char*)wNetConfig.net_mask, inContext->flashContentInRam.micoSystemConfig.netMask, maxIpLen);
  strncpy((char*)wNetConfig.gateway_ip_addr, inContext->flashContentInRam.micoSystemConfig.gateWay, maxIpLen);
  strncpy((char*)wNetConfig.dnsServer_ip_addr, inContext->flashContentInRam.micoSystemConfig.dnsServer, maxIpLen);
  wNetConfig.wifi_retry_interval = 100;
  mico_rtos_unlock_mutex(&inContext->flashContentInRam_mutex);

  system_log("connect to %s.....", wNetConfig.ap_info.ssid);
  micoWlanStartAdv(&wNetConfig);
}
USED void PlatformEasyLinkButtonClickedCallback(void)
{
    system_log_trace();
    mico_Context_t* context = NULL;

    context = mico_system_context_get( );
    require( context, exit );

    if(context->flashContentInRam.micoSystemConfig.easyLinkByPass != EASYLINK_BYPASS_NO) {
        context->flashContentInRam.micoSystemConfig.easyLinkByPass = EASYLINK_BYPASS_NO;
        needs_update = true;
    }

    if(context->flashContentInRam.micoSystemConfig.configured == allConfigured) {
        context->flashContentInRam.micoSystemConfig.configured = wLanUnConfigured;
        needs_update = true;
    }

    mico_system_power_perform( context, eState_Software_Reset );

exit:
    return;
}
示例#12
0
static void micoNotify_ConnectFailedHandler(OSStatus err, mico_Context_t * const inContext)
{
  system_log_trace();
  (void)inContext;
  system_log("Wlan Connection Err %d", err);
}