1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Added API to set static IP and DNS server

This commit is contained in:
Mimmo La Fauci
2013-03-21 09:24:07 +01:00
parent 9c30c73c2b
commit dc3102d2f4
13 changed files with 15997 additions and 15682 deletions

View File

@ -151,6 +151,55 @@ int8_t WiFiDrv::wifiSetKey(char* ssid, uint8_t ssid_len, uint8_t key_idx, const
SpiDrv::spiSlaveDeselect();
return _data;
}
void WiFiDrv::config(uint8_t validParams, uint32_t local_ip, uint32_t gateway, uint32_t subnet)
{
WAIT_FOR_SLAVE_SELECT();
// Send Command
SpiDrv::sendCmd(SET_IP_CONFIG_CMD, PARAM_NUMS_4);
SpiDrv::sendParam((uint8_t*)&validParams, 1, NO_LAST_PARAM);
SpiDrv::sendParam((uint8_t*)&local_ip, 4, NO_LAST_PARAM);
SpiDrv::sendParam((uint8_t*)&gateway, 4, NO_LAST_PARAM);
SpiDrv::sendParam((uint8_t*)&subnet, 4, LAST_PARAM);
//Wait the reply elaboration
SpiDrv::waitForSlaveReady();
// Wait for reply
uint8_t _data = 0;
uint8_t _dataLen = 0;
if (!SpiDrv::waitResponseCmd(SET_IP_CONFIG_CMD, PARAM_NUMS_1, &_data, &_dataLen))
{
WARN("error waitResponse");
_data = WL_FAILURE;
}
SpiDrv::spiSlaveDeselect();
}
void WiFiDrv::setDNS(uint8_t validParams, uint32_t dns_server1, uint32_t dns_server2)
{
WAIT_FOR_SLAVE_SELECT();
// Send Command
SpiDrv::sendCmd(SET_DNS_CONFIG_CMD, PARAM_NUMS_3);
SpiDrv::sendParam((uint8_t*)&validParams, 1, NO_LAST_PARAM);
SpiDrv::sendParam((uint8_t*)&dns_server1, 4, NO_LAST_PARAM);
SpiDrv::sendParam((uint8_t*)&dns_server2, 4, LAST_PARAM);
//Wait the reply elaboration
SpiDrv::waitForSlaveReady();
// Wait for reply
uint8_t _data = 0;
uint8_t _dataLen = 0;
if (!SpiDrv::waitResponseCmd(SET_DNS_CONFIG_CMD, PARAM_NUMS_1, &_data, &_dataLen))
{
WARN("error waitResponse");
_data = WL_FAILURE;
}
SpiDrv::spiSlaveDeselect();
}
int8_t WiFiDrv::disconnect()
{