Expose WPA2 enterprise APIs

This commit is contained in:
Martino Facchin 2018-10-22 14:23:46 +02:00
parent 2aed17fc1e
commit 50f55a0732

View file

@ -977,6 +977,56 @@ int setAnalogWrite(const uint8_t command[], uint8_t response[])
}
#include "esp_wpa2.h"
int wpa2EntSetIdentity(const uint8_t command[], uint8_t response[]) {
char identity[32 + 1];
memset(identity, 0x00, sizeof(identity));
memcpy(identity, &command[4], command[3]);
esp_wifi_sta_wpa2_ent_set_identity((const unsigned char*)identity, sizeof(identity));
return 0;
}
int wpa2EntSetUsername(const uint8_t command[], uint8_t response[]) {
char username[32 + 1];
memset(username, 0x00, sizeof(username));
memcpy(username, &command[4], command[3]);
esp_wifi_sta_wpa2_ent_set_username((const unsigned char*)username, sizeof(username));
return 0;
}
int wpa2EntSetPassword(const uint8_t command[], uint8_t response[]) {
char password[32 + 1];
memset(password, 0x00, sizeof(password));
memcpy(password, &command[4], command[3]);
esp_wifi_sta_wpa2_ent_set_username((const unsigned char*)password, sizeof(password));
return 0;
}
int wpa2EntSetCACert(const uint8_t command[], uint8_t response[]) {
// not yet implemented (need to decide if writing in the filesystem is better than loading every time)
// keep in mind size limit for messages
return 0;
}
int wpa2EntSetCertKey(const uint8_t command[], uint8_t response[]) {
// not yet implemented (need to decide if writing in the filesystem is better than loading every time)
// keep in mind size limit for messages
return 0;
}
int wpa2EntEnable(const uint8_t command[], uint8_t response[]) {
esp_wpa2_config_t config = WPA2_CONFIG_INIT_DEFAULT();
esp_wifi_sta_wpa2_ent_enable(&config);
return 0;
}
typedef int (*CommandHandlerType)(const uint8_t command[], uint8_t response[]);
const CommandHandlerType commandHandlers[] = {
@ -993,7 +1043,7 @@ const CommandHandlerType commandHandlers[] = {
disconnect, NULL, getIdxRSSI, getIdxEnct, reqHostByName, getHostByName, startScanNetworks, getFwVersion, NULL, sendUDPdata, getRemoteData, getTime, getIdxBSSID, getIdxChannel, ping, getSocket,
// 0x40 -> 0x4f
NULL, NULL, NULL, NULL, sendDataTcp, getDataBufTcp, insertDataBuf, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, sendDataTcp, getDataBufTcp, insertDataBuf, NULL, NULL, NULL, wpa2EntSetIdentity, wpa2EntSetUsername, wpa2EntSetPassword, wpa2EntSetCACert, wpa2EntSetCertKey, wpa2EntEnable,
// 0x50 -> 0x5f
setPinMode, setDigitalWrite, setAnalogWrite,