Compare commits
2 commits
master
...
if_statist
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53c45b18fd | ||
|
|
50f55a0732 |
2 changed files with 85 additions and 3 deletions
|
|
@ -237,6 +237,38 @@ int getTemperature(const uint8_t command[], uint8_t response[])
|
|||
return 9;
|
||||
}
|
||||
|
||||
static int stats_display_proto(struct stats_proto *proto, char* buf)
|
||||
{
|
||||
int cc = 0;
|
||||
cc += snprintf(buf + cc, 256, "xmit: %hu\n", proto->xmit);
|
||||
cc += snprintf(buf + cc, 256, "recv: %hu\n", proto->recv);
|
||||
cc += snprintf(buf + cc, 256, "fw: %hu\n", proto->fw);
|
||||
cc += snprintf(buf + cc, 256, "drop: %hu\n", proto->drop);
|
||||
cc += snprintf(buf + cc, 256, "chkerr: %hu\n", proto->chkerr);
|
||||
cc += snprintf(buf + cc, 256, "lenerr: %hu\n", proto->lenerr);
|
||||
cc += snprintf(buf + cc, 256, "memerr: %hu\n", proto->memerr);
|
||||
cc += snprintf(buf + cc, 256, "rterr: %hu\n", proto->rterr);
|
||||
cc += snprintf(buf + cc, 256, "proterr: %hu\n", proto->proterr);
|
||||
cc += snprintf(buf + cc, 256, "opterr: %hu\n", proto->opterr);
|
||||
cc += snprintf(buf + cc, 256, "err: %hu\n", proto->err);
|
||||
cc += snprintf(buf + cc, 256, "cachehit: %hu\n", proto->cachehit);
|
||||
return cc;
|
||||
}
|
||||
|
||||
int getStats(const uint8_t command[], uint8_t response[])
|
||||
{
|
||||
int ret = 0;
|
||||
if (command[4] == 0)
|
||||
ret = stats_display_proto(&lwip_stats.tcp, (char*)&response[4]);
|
||||
else
|
||||
ret = stats_display_proto(&lwip_stats.udp, (char*)&response[4]);
|
||||
|
||||
response[2] = 1; // number of parameters
|
||||
response[3] = ret; // parameter 1 length
|
||||
|
||||
return ret + 4;
|
||||
}
|
||||
|
||||
int getConnStatus(const uint8_t command[], uint8_t response[])
|
||||
{
|
||||
uint8_t status = WiFi.status();
|
||||
|
|
@ -977,6 +1009,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[] = {
|
||||
|
|
@ -984,7 +1066,7 @@ const CommandHandlerType commandHandlers[] = {
|
|||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
|
||||
// 0x10 -> 0x1f
|
||||
setNet, setPassPhrase, setKey, NULL, setIPconfig, setDNSconfig, setHostname, setPowerMode, setApNet, setApPassPhrase, setDebug, getTemperature, NULL, NULL, NULL, NULL,
|
||||
setNet, setPassPhrase, setKey, NULL, setIPconfig, setDNSconfig, setHostname, setPowerMode, setApNet, setApPassPhrase, setDebug, getTemperature, NULL, NULL, NULL, getStats,
|
||||
|
||||
// 0x20 -> 0x2f
|
||||
getConnStatus, getIPaddr, getMACaddr, getCurrSSID, getCurrBSSID, getCurrRSSI, getCurrEnct, scanNetworks, startServerTcp, getStateTcp, dataSentTcp, availDataTcp, getDataTcp, startClientTcp, stopClientTcp, getClientStateTcp,
|
||||
|
|
@ -993,7 +1075,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,
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ CONFIG_LWIP_SO_RCVBUF=y
|
|||
CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=1
|
||||
CONFIG_LWIP_IP_FRAG=
|
||||
CONFIG_LWIP_IP_REASSEMBLY=
|
||||
CONFIG_LWIP_STATS=
|
||||
CONFIG_LWIP_STATS=y
|
||||
CONFIG_LWIP_ETHARP_TRUST_IP_MAC=y
|
||||
CONFIG_TCPIP_RECVMBOX_SIZE=32
|
||||
CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y
|
||||
|
|
|
|||
Loading…
Reference in a new issue