From 412a8f99928beff605805807b0f07f6bf8d0a965 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Fri, 13 May 2022 12:45:53 +0200 Subject: code rename --- fw/fe310/eos/net/wifi.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 fw/fe310/eos/net/wifi.c (limited to 'fw/fe310/eos/net/wifi.c') diff --git a/fw/fe310/eos/net/wifi.c b/fw/fe310/eos/net/wifi.c new file mode 100644 index 0000000..0663582 --- /dev/null +++ b/fw/fe310/eos/net/wifi.c @@ -0,0 +1,106 @@ +#include +#include +#include + +#include "eos.h" +#include "event.h" +#include "net.h" + +#include "wifi.h" + +static eos_evt_handler_t evt_handler[EOS_WIFI_MAX_MTYPE]; + +static void wifi_handle_msg(unsigned char type, unsigned char *buffer, uint16_t len) { + unsigned char mtype; + + if ((buffer == NULL) || (len < 1)) { + eos_net_bad_handler(type, buffer, len); + return; + } + + mtype = buffer[0]; + if ((mtype < EOS_WIFI_MAX_MTYPE) && evt_handler[mtype]) { + evt_handler[mtype](mtype, buffer, len); + } else { + eos_net_bad_handler(type, buffer, len); + } +} + +void eos_wifi_netinit(void) { + int i; + + for (i=0; i EOS_NET_MTU) return EOS_ERR_SIZE; + + buf = buffer; + buf[0] = EOS_WIFI_MTYPE_AUTH; + buf++; + strcpy(buf, ssid); + buf += ssid_len; + strcpy(buf, pass); + buf += pass_len; + + return _eos_net_send(EOS_NET_MTYPE_WIFI, buffer, 1 + ssid_len + pass_len, async, 1); +} + +int eos_wifi_connect(unsigned char *buffer) { + int async; + + async = 0; + if (buffer == NULL) { + buffer = eos_net_alloc(); + async = 1; + } + buffer[0] = EOS_WIFI_MTYPE_CONNECT; + return _eos_net_send(EOS_NET_MTYPE_WIFI, buffer, 1, async, 1); +} + +int eos_wifi_disconnect(unsigned char *buffer) { + int async; + + async = 0; + if (buffer == NULL) { + buffer = eos_net_alloc(); + async = 1; + } + buffer[0] = EOS_WIFI_MTYPE_DISCONNECT; + return _eos_net_send(EOS_NET_MTYPE_WIFI, buffer, 1, async, 1); +} -- cgit v1.2.3