summaryrefslogtreecommitdiff
path: root/fw/esp32/components/eos/sock.c
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2022-09-04 18:43:50 +0200
committerUros Majstorovic <majstor@majstor.org>2022-09-04 18:43:50 +0200
commit6a4b3ef0e72ee134b81a523ce41fd4c45f3b4429 (patch)
treec4cb9b524711238b162511f515d484df4052e3ab /fw/esp32/components/eos/sock.c
parent03ec4d6158bd3c555b6c60b9e7476740464f19fa (diff)
fixed wifi and cell
Diffstat (limited to 'fw/esp32/components/eos/sock.c')
-rw-r--r--fw/esp32/components/eos/sock.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/fw/esp32/components/eos/sock.c b/fw/esp32/components/eos/sock.c
index ec198f0..e1b703f 100644
--- a/fw/esp32/components/eos/sock.c
+++ b/fw/esp32/components/eos/sock.c
@@ -108,15 +108,18 @@ static void udp_rcvr_task(void *pvParameters) {
vTaskDelete(NULL);
}
-static void sock_handler(unsigned char type, unsigned char *buffer, uint16_t buf_len) {
- EOSNetAddr addr;
+static void sock_handler(unsigned char _mtype, unsigned char *buffer, uint16_t buf_len) {
+ unsigned char mtype;
uint8_t sock_i;
int sock, i;
if (buf_len < 1) return;
- switch(buffer[0]) {
- case EOS_SOCK_MTYPE_PKT:
+ mtype = buffer[0];
+ switch (mtype) {
+ case EOS_SOCK_MTYPE_PKT: {
+ EOSNetAddr addr;
+
if (buf_len < EOS_SOCK_SIZE_UDP_HDR) return;
sock_i = buffer[1]-1;
@@ -131,8 +134,9 @@ static void sock_handler(unsigned char type, unsigned char *buffer, uint16_t buf
buffer += sizeof(addr.port);
t_sendto(sock, buffer, buf_len - EOS_SOCK_SIZE_UDP_HDR, &addr);
break;
+ }
- case EOS_SOCK_MTYPE_OPEN_DGRAM:
+ case EOS_SOCK_MTYPE_OPEN_DGRAM: {
sock = t_open_dgram();
sock_i = 0;
if (sock > 0) {
@@ -151,8 +155,9 @@ static void sock_handler(unsigned char type, unsigned char *buffer, uint16_t buf
buffer[1] = sock_i;
eos_net_reply(EOS_NET_MTYPE_SOCK, buffer, 2);
break;
+ }
- case EOS_SOCK_MTYPE_CLOSE:
+ case EOS_SOCK_MTYPE_CLOSE: {
if (buf_len < 2) return;
sock_i = buffer[1]-1;
@@ -161,10 +166,7 @@ static void sock_handler(unsigned char type, unsigned char *buffer, uint16_t buf
sock = _socks[sock_i];
t_close(sock);
break;
-
- default:
- ESP_LOGE(TAG, "BAD TYPE:%d", buffer[0]);
- break;
+ }
}
}