MCPcopy Create free account
hub / github.com/DanielOgorchock/ST_Anything / startAP

Method startAP

Arduino/libraries/WiFi101/src/WiFi.cpp:468–530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

466}
467
468uint8_t WiFiClass::startAP(const char *ssid, uint8_t u8SecType, const void *pvAuthInfo, uint8_t channel)
469{
470 tstrM2MAPConfig strM2MAPConfig;
471
472 if (!_init) {
473 init();
474 }
475
476 if (channel == 0) {
477 channel = 1; // channel 1 is the minium channel
478 }
479
480 // Enter Access Point mode:
481 memset(&strM2MAPConfig, 0x00, sizeof(tstrM2MAPConfig));
482 strcpy((char *)&strM2MAPConfig.au8SSID, ssid);
483 strM2MAPConfig.u8ListenChannel = channel;
484 strM2MAPConfig.u8SecType = u8SecType;
485 if (_localip == 0) {
486 strM2MAPConfig.au8DHCPServerIP[0] = 192;
487 strM2MAPConfig.au8DHCPServerIP[1] = 168;
488 strM2MAPConfig.au8DHCPServerIP[2] = 1;
489 strM2MAPConfig.au8DHCPServerIP[3] = 1;
490 } else {
491 memcpy(strM2MAPConfig.au8DHCPServerIP, &_localip, sizeof(_localip));
492 if (strM2MAPConfig.au8DHCPServerIP[3] == 100) {
493 // limitation of WINC1500 firmware, IP address of client is always x.x.x.100
494 _status = WL_AP_FAILED;
495 return _status;
496 }
497 }
498
499 if (u8SecType == M2M_WIFI_SEC_WEP) {
500 tstrM2mWifiWepParams* wep_params = (tstrM2mWifiWepParams*)pvAuthInfo;
501
502 strM2MAPConfig.u8KeyIndx = wep_params->u8KeyIndx;
503 strM2MAPConfig.u8KeySz = wep_params->u8KeySz;
504 strcpy((char*)strM2MAPConfig.au8WepKey, (char *)wep_params->au8WepKey);
505 }
506
507 if (u8SecType == M2M_WIFI_SEC_WPA_PSK) {
508 strM2MAPConfig.u8KeySz = strlen((char*)pvAuthInfo);
509 strcpy((char*)strM2MAPConfig.au8Key, (char *)pvAuthInfo);
510 }
511
512 if (m2m_wifi_enable_ap(&strM2MAPConfig) < 0) {
513 _status = WL_AP_FAILED;
514 return _status;
515 }
516 _status = WL_AP_LISTENING;
517 _mode = WL_AP_MODE;
518
519 memset(_ssid, 0, M2M_MAX_SSID_LEN);
520 memcpy(_ssid, ssid, strlen(ssid));
521 m2m_memcpy((uint8 *)&_localip, (uint8 *)&strM2MAPConfig.au8DHCPServerIP[0], 4);
522 _submask = 0x00FFFFFF;
523 _gateway = _localip;
524
525 // WiFi led ON (rev A then rev B).

Callers

nothing calls this directly

Calls 3

m2m_wifi_enable_apFunction · 0.85
m2m_memcpyFunction · 0.85
m2m_periph_gpio_set_valFunction · 0.85

Tested by

no test coverage detected