Ejemplo n.º 1
0
int WiFiClass::begin()
{
    int8_t name[32];
    int16_t NameLen;

    if(_connecting) {
        delay(500);
        return status();
    }

    bool init_success = init();
    if (!init_success) {
        return WL_CONNECT_FAILED;
    }

    int16_t ret = sl_WlanProfileGet(0, name, (short int*)&NameLen, NULL, NULL, NULL, NULL);

    if(ret < 0) {
        return WL_CONNECT_FAILED;
    }

    sl_WlanPolicySet(SL_POLICY_CONNECTION , SL_CONNECTION_POLICY(1,1,0,0,0), 0, 0);

    _connecting = true;

    return WL_IDLE_STATUS;

}
unsigned char cc3200helpers_isProfileConfigured(unsigned char byProfile)
{
  SlSecParams_t SecParams;
  SlGetSecParamsExt_t EntParams;
  _u32 dwPriority;
  signed char achName[32 + 1] = { 0 };
  short sNameLength = sizeof(achName) - 1;
  unsigned char abyMAC[6];
  _i16 sResult = sl_WlanProfileGet(byProfile, achName, &sNameLength, abyMAC, &SecParams, &EntParams, &dwPriority);
  if ( sResult < 0 )
  {
    return 0;
  }
  return !0;
}
Ejemplo n.º 3
0
//--tested, working--//
uint8_t WiFiClass::status()
{
    int8_t name[33];
    int16_t NameLen;
    uint8_t i;

    if (!_initialized) {
        init();
    }

    if (role == ROLE_AP) {
        return WL_AP_MODE;
    }

#ifndef SL_PLATFORM_MULTI_THREADED
    //
    // The class variable WiFi_status is maintained by the slWlanEvenHandler
    //
    sl_Task();
#endif
#if 0
    /* If SimpleConfig was started then wait for SimpleConfig to be complete.
     * Only delete the existing profile if the connection was successfull */
    if(_SimpleConfigComplete && (WiFi_status == WL_CONNECTED)) {
        for (i = 0; i < 7; i++) {
            _SimpleConfigComplete = false;
            int16_t ret = sl_WlanProfileGet(i, name, &NameLen, NULL, NULL, NULL, NULL);
            if (ret < 0) {
                continue;
            }
            name[NameLen] = '\0';
            Serial.print("\nProfile: ");
            Serial.print(i);
            Serial.print("    SSID: ");
            Serial.println((char*)name);
            /* Delete the profiles that do not match the SSID that the board is connected to */
            if (strcmp((char *)name, connected_ssid) != 0) {
                sl_WlanProfileDel(i);
                Serial.print("Deleting Profile: ");
                Serial.println(i);
            }
        }
    }
#endif
    return WiFi_status;
}