Skip to content

Commit 3b4e5a9

Browse files
authored
Merge pull request #101 from sandeepmistry/ap-config
Use local IP set by config in beginAP if provided
2 parents bc463ca + ec7bd3f commit 3b4e5a9

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/WiFi.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,19 @@ uint8_t WiFiClass::startAP(const char *ssid, uint8_t u8SecType, const void *pvAu
400400
strcpy((char *)&strM2MAPConfig.au8SSID, ssid);
401401
strM2MAPConfig.u8ListenChannel = channel - 1;
402402
strM2MAPConfig.u8SecType = u8SecType;
403-
strM2MAPConfig.au8DHCPServerIP[0] = 0xC0; /* 192 */
404-
strM2MAPConfig.au8DHCPServerIP[1] = 0xA8; /* 168 */
405-
strM2MAPConfig.au8DHCPServerIP[2] = 0x01; /* 1 */
406-
strM2MAPConfig.au8DHCPServerIP[3] = 0x01; /* 1 */
403+
if (_localip == 0) {
404+
strM2MAPConfig.au8DHCPServerIP[0] = 192;
405+
strM2MAPConfig.au8DHCPServerIP[1] = 168;
406+
strM2MAPConfig.au8DHCPServerIP[2] = 1;
407+
strM2MAPConfig.au8DHCPServerIP[3] = 1;
408+
} else {
409+
memcpy(strM2MAPConfig.au8DHCPServerIP, &_localip, sizeof(_localip));
410+
if (strM2MAPConfig.au8DHCPServerIP[3] == 100) {
411+
// limitation of WINC1500 firmware, IP address of client is always x.x.x.100
412+
_status = WL_AP_FAILED;
413+
return _status;
414+
}
415+
}
407416

408417
if (u8SecType == M2M_WIFI_SEC_WEP) {
409418
tstrM2mWifiWepParams* wep_params = (tstrM2mWifiWepParams*)pvAuthInfo;

0 commit comments

Comments
 (0)