summaryrefslogtreecommitdiff
path: root/fw/fe310/test
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2021-02-24 19:50:20 +0100
committerUros Majstorovic <majstor@majstor.org>2021-02-24 19:50:20 +0100
commit3050565531af2b3a09f2213893f10c64cf9fe43f (patch)
tree689d10ca064dba4480a85b6ec14a4eb8305d5c89 /fw/fe310/test
parentd0a0fee0571be63f023f8f6a49a0b76b89871e56 (diff)
added test app with voice, wifi/cellular data connectivity examples
Diffstat (limited to 'fw/fe310/test')
-rw-r--r--fw/fe310/test/Makefile8
-rw-r--r--fw/fe310/test/cell_data.c115
-rw-r--r--fw/fe310/test/cell_data.h4
-rw-r--r--fw/fe310/test/main.c83
-rw-r--r--fw/fe310/test/modem.c54
-rw-r--r--fw/fe310/test/modem.h2
-rw-r--r--fw/fe310/test/phone.c142
-rw-r--r--fw/fe310/test/phone.h9
-rw-r--r--fw/fe310/test/status.c93
-rw-r--r--fw/fe310/test/status.h2
-rw-r--r--fw/fe310/test/wifi.c108
-rw-r--r--fw/fe310/test/wifi.h4
12 files changed, 596 insertions, 28 deletions
diff --git a/fw/fe310/test/Makefile b/fw/fe310/test/Makefile
index 24efa2f..53e6f2d 100644
--- a/fw/fe310/test/Makefile
+++ b/fw/fe310/test/Makefile
@@ -3,18 +3,20 @@ include ../common.mk
CFLAGS += -I../eos -I../bsp/include -I../bsp/drivers
LDFLAGS = $(CFLAGS) -L.. -Wl,--gc-sections -nostartfiles -nostdlib -Wl,--start-group -lc -lm -lgcc -leos -Wl,--end-group -T../bsp/default.lds
-TARGET = modem
+DEPS = main.o status.o phone.o wifi.o cell_data.o modem.o
+TARGET = phone
all: $(TARGET)
%.o: %.c
$(CC) $(CFLAGS) -c $<
-$(TARGET): $(TARGET).o
- $(CC) $< $(LDFLAGS) -o $@
+$(TARGET): $(DEPS)
+ $(CC) $(DEPS) $(LDFLAGS) -o $@
clean:
rm -f *.o *.a $(TARGET)
upload: $(TARGET)
../bsp/upload --elf ./$(TARGET) --openocd $(RISCV_OPENOCD_HOME)/bin/openocd --gdb $(RISCV_HOME)/bin/riscv64-unknown-elf-gdb --openocd-config ../bsp/openocd.cfg
+
diff --git a/fw/fe310/test/cell_data.c b/fw/fe310/test/cell_data.c
new file mode 100644
index 0000000..007fa0b
--- /dev/null
+++ b/fw/fe310/test/cell_data.c
@@ -0,0 +1,115 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <eos.h>
+#include <event.h>
+#include <spi.h>
+#include <uart.h>
+#include <net.h>
+#include <cell.h>
+
+#include <unicode.h>
+
+#include <eve/eve.h>
+#include <eve/eve_kbd.h>
+
+#include <eve/screen/screen.h>
+#include <eve/screen/window.h>
+#include <eve/screen/view.h>
+#include <eve/screen/page.h>
+#include <eve/screen/form.h>
+
+#include <eve/widget/widgets.h>
+
+#include <app/root.h>
+
+#include "status.h"
+#include "cell_data.h"
+
+extern EVEFont *_app_font_default;
+
+static void cell_data_handler(unsigned char type, unsigned char *buffer, uint16_t size) {
+ switch (type) {
+ case EOS_CELL_MTYPE_DATA_CONNECT:
+ app_status_msg_set("Cell data connected", 1);
+ break;
+
+ case EOS_CELL_MTYPE_DATA_DISCONNECT:
+ app_status_msg_set("Cell data disconnected", 1);
+ break;
+
+ default:
+ break;
+ }
+ eos_net_free(buffer, 0);
+}
+
+void app_cell_data(EVEWindow *window, EVEViewStack *stack) {
+ APPWidgetSpec spec[] = {
+ {
+ .label.g.w = APP_SCREEN_W / 3,
+ .label.font = _app_font_default,
+ .label.title = "APN:",
+
+ .widget.type = EVE_WIDGET_TYPE_STR,
+ .widget.g.w = APP_SCREEN_W - APP_SCREEN_W / 3,
+ .widget.spec.str.font = _app_font_default,
+ .widget.spec.str.str_size = 128,
+ },
+ {
+ .label.g.w = APP_SCREEN_W / 3,
+ .label.font = _app_font_default,
+ .label.title = "User:",
+
+ .widget.type = EVE_WIDGET_TYPE_STR,
+ .widget.g.w = APP_SCREEN_W - APP_SCREEN_W / 3,
+ .widget.spec.str.font = _app_font_default,
+ .widget.spec.str.str_size = 128,
+ },
+ {
+ .label.g.w = APP_SCREEN_W / 3,
+ .label.font = _app_font_default,
+ .label.title = "Pass:",
+
+ .widget.type = EVE_WIDGET_TYPE_STR,
+ .widget.g.w = APP_SCREEN_W - APP_SCREEN_W / 3,
+ .widget.spec.str.font = _app_font_default,
+ .widget.spec.str.str_size = 128,
+ },
+ };
+
+ EVEForm *form = app_form_create(window, stack, spec, 3, app_cell_data_action, app_cell_data_close);
+}
+
+void app_cell_data_action(EVEForm *form) {
+ unsigned char *buf = eos_net_alloc();
+ unsigned char *p;
+ EVEStrWidget *apn = (EVEStrWidget *)eve_form_widget(form, 0);
+ EVEStrWidget *user = (EVEStrWidget *)eve_form_widget(form, 1);
+ EVEStrWidget *pass = (EVEStrWidget *)eve_form_widget(form, 2);
+
+ buf[0] = EOS_CELL_MTYPE_DATA | EOS_CELL_MTYPE_DATA_CONFIGURE;
+ p = buf + 1;
+ strcpy(p, apn->str);
+ p += strlen(apn->str) + 1;
+ strcpy(p, user->str);
+ p += strlen(user->str) + 1;
+ strcpy(p, pass->str);
+ p += strlen(pass->str) + 1;
+ eos_net_send(EOS_NET_MTYPE_CELL, buf, p - buf, 1);
+
+ eos_net_acquire();
+ buf = eos_net_alloc();
+ buf[0] = EOS_CELL_MTYPE_DATA | EOS_CELL_MTYPE_DATA_CONNECT;
+ eos_net_send(EOS_NET_MTYPE_CELL, buf, 1, 0);
+}
+
+void app_cell_data_close(EVEForm *form) {
+ app_form_destroy(form);
+}
+
+void app_cell_data_init(void) {
+ eos_cell_set_handler(EOS_CELL_MTYPE_DATA, cell_data_handler);
+}
diff --git a/fw/fe310/test/cell_data.h b/fw/fe310/test/cell_data.h
new file mode 100644
index 0000000..69ae2ef
--- /dev/null
+++ b/fw/fe310/test/cell_data.h
@@ -0,0 +1,4 @@
+void app_cell_data(EVEWindow *window, EVEViewStack *stack);
+void app_cell_data_action(EVEForm *form);
+void app_cell_data_close(EVEForm *form);
+void app_cell_data_init(void); \ No newline at end of file
diff --git a/fw/fe310/test/main.c b/fw/fe310/test/main.c
new file mode 100644
index 0000000..095746d
--- /dev/null
+++ b/fw/fe310/test/main.c
@@ -0,0 +1,83 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <eos.h>
+#include <event.h>
+#include <spi.h>
+#include <i2s.h>
+#include <net.h>
+#include <cell.h>
+
+#include <unicode.h>
+
+#include <eve/eve.h>
+#include <eve/eve_kbd.h>
+
+#include <eve/screen/screen.h>
+#include <eve/screen/window.h>
+#include <eve/screen/view.h>
+#include <eve/screen/page.h>
+#include <eve/screen/form.h>
+
+#include <eve/widget/widgets.h>
+
+#include <app/root.h>
+
+#include "status.h"
+#include "phone.h"
+#include "wifi.h"
+#include "cell_data.h"
+#include "modem.h"
+
+extern EVEFont *_app_font_default;
+
+void app_home_page(EVEWindow *window, EVEViewStack *stack) {
+ APPWidgetSpec spec[] = {
+ {
+ .widget.type = EVE_WIDGET_TYPE_PAGE,
+ .widget.g.w = APP_SCREEN_W,
+ .widget.spec.page.font = _app_font_default,
+ .widget.spec.page.title = "Phone",
+ .widget.spec.page.constructor = app_phone
+ },
+ {
+ .widget.type = EVE_WIDGET_TYPE_PAGE,
+ .widget.g.w = APP_SCREEN_W,
+ .widget.spec.page.font = _app_font_default,
+ .widget.spec.page.title = "WiFi",
+ .widget.spec.page.constructor = app_wifi
+ },
+ {
+ .widget.type = EVE_WIDGET_TYPE_PAGE,
+ .widget.g.w = APP_SCREEN_W,
+ .widget.spec.page.font = _app_font_default,
+ .widget.spec.page.title = "Cellular data",
+ .widget.spec.page.constructor = app_cell_data
+ },
+ {
+ .widget.type = EVE_WIDGET_TYPE_PAGE,
+ .widget.g.w = APP_SCREEN_W,
+ .widget.spec.page.font = _app_font_default,
+ .widget.spec.page.title = "Modem",
+ .widget.spec.page.constructor = app_modem
+ },
+ };
+
+ EVEForm *form = app_form_create(window, stack, spec, 4, NULL, NULL);
+}
+
+int main() {
+ printf("\nREADY.\n");
+
+ eos_init();
+
+ app_root_init(app_home_page);
+ app_status_init();
+ app_phone_init();
+ app_wifi_init();
+ app_cell_data_init();
+
+ eos_evtq_loop();
+}
diff --git a/fw/fe310/test/modem.c b/fw/fe310/test/modem.c
index 5fa17cc..6453b24 100644
--- a/fw/fe310/test/modem.c
+++ b/fw/fe310/test/modem.c
@@ -26,18 +26,27 @@
#include <app/root.h>
+#include "modem.h"
+
typedef struct {
uint32_t mem;
EVEViewStack *stack;
+ eos_evt_handler_t cell_dev_handler;
EVEText text;
} VParam;
static void key_down(void *p, int c) {
- EVEText *text = p;
- unsigned char *buf = eos_net_alloc();
+ EVEView *view = p;
+ EVEText *text = &((VParam *)view->param)->text;
+ unsigned char *buf;
int i = 2;
- buf[0] = EOS_CELL_MTYPE_UART_DATA;
+ if (c == 0x11) {
+ app_modem_close(view);
+ return;
+ }
+ buf = eos_net_alloc();
+ buf[0] = EOS_CELL_MTYPE_DEV | EOS_CELL_MTYPE_UART_DATA;
if (c == '\n') {
buf[1] = '\r';
buf[2] = '\n';
@@ -59,7 +68,7 @@ static void handle_uart(unsigned char type) {
if (c == EOS_ERR_EMPTY) return;
buf = eos_net_alloc();
- buf[0] = EOS_CELL_MTYPE_UART_DATA;
+ buf[0] = EOS_CELL_MTYPE_DEV | EOS_CELL_MTYPE_UART_DATA;
buf[1] = c;
i = 2;
while ((c = eos_uart_getc(0)) != EOS_ERR_EMPTY) {
@@ -72,10 +81,11 @@ static void handle_uart(unsigned char type) {
}
static void handle_cell_msg(unsigned char type, unsigned char *buffer, uint16_t len) {
+ EVEScreen *screen = app_screen();
+ EVEWindow *window = eve_window_get(screen, "main");
+ VParam *param = window->view->param;
+
if (type == EOS_CELL_MTYPE_UART_DATA) {
- EVEScreen *screen = app_screen();
- EVEWindow *window = eve_window_get(screen, "main");
- VParam *param = window->view->param;
EVEText *text = &param->text;
int i;
@@ -88,9 +98,10 @@ static void handle_cell_msg(unsigned char type, unsigned char *buffer, uint16_t
eve_screen_draw(window->screen);
}
eos_spi_dev_stop();
-
+ eos_net_free(buffer, 0);
+ } else {
+ param->cell_dev_handler(type, buffer, len);
}
- eos_net_free(buffer, 0);
}
static int modem_touch(EVEView *view, uint8_t tag0, int touch_idx) {
@@ -107,7 +118,7 @@ static uint8_t modem_draw(EVEView *view, uint8_t tag) {
return eve_text_draw(text, tag);
}
-void app_modem_create(EVEWindow *window, EVEViewStack *stack) {
+void app_modem(EVEWindow *window, EVEViewStack *stack) {
unsigned char *buf;
EVEScreen *screen = window->screen;
EVEKbd *kbd = eve_screen_get_kbd(screen);
@@ -119,10 +130,11 @@ void app_modem_create(EVEWindow *window, EVEViewStack *stack) {
param = eve_malloc(sizeof(VParam));
param->mem = screen->mem_next;
param->stack = stack;
+ param->cell_dev_handler = eos_cell_get_handler(EOS_CELL_MTYPE_DEV);
eve_text_init(&param->text, &g, 30, 16, 200, screen->mem_next, &screen->mem_next);
eve_view_init(view, window, modem_touch, modem_draw, param);
- eve_kbd_set_handler(kbd, key_down, &param->text);
+ eve_kbd_set_handler(kbd, key_down, view);
eve_screen_show_kbd(screen);
eos_uart_set_handler(EOS_UART_ETYPE_RX, handle_uart);
@@ -130,37 +142,29 @@ void app_modem_create(EVEWindow *window, EVEViewStack *stack) {
eos_net_acquire_for_evt(EOS_EVT_UART | EOS_UART_ETYPE_RX, 1);
buf = eos_net_alloc();
- buf[0] = EOS_CELL_MTYPE_UART_TAKE;
+ buf[0] = EOS_CELL_MTYPE_DEV | EOS_CELL_MTYPE_UART_TAKE;
eos_net_send(EOS_NET_MTYPE_CELL, buf, 1, 0);
eos_uart_rxwm_set(0);
}
-void app_modem_destroy(EVEView *view) {
+void app_modem_close(EVEView *view) {
unsigned char *buf = eos_net_alloc();
VParam *param = view->param;
EVEWindow *window = view->window;
EVEScreen *screen = window->screen;
- EVEKbd *kbd = eve_screen_get_kbd(screen);
EVEViewStack *stack = param->stack;
- buf[0] = EOS_CELL_MTYPE_UART_GIVE;
+ buf[0] = EOS_CELL_MTYPE_DEV | EOS_CELL_MTYPE_RESET;
eos_net_send(EOS_NET_MTYPE_CELL, buf, 1, 0);
eos_uart_rxwm_clear();
eos_uart_set_handler(EOS_UART_ETYPE_RX, NULL);
- eos_cell_set_handler(EOS_CELL_MTYPE_DEV, NULL);
+ eos_cell_set_handler(EOS_CELL_MTYPE_DEV, param->cell_dev_handler);
eos_net_acquire_for_evt(EOS_EVT_UART | EOS_UART_ETYPE_RX, 0);
- eve_screen_hide_kbd(screen);
- eve_kbd_set_handler(kbd, NULL, NULL);
-
screen->mem_next = param->mem;
eve_free(param);
eve_free(view);
- eve_view_destroy(window, stack);
-}
-int main() {
- eos_init();
- app_root_init(app_modem_create);
- eos_evtq_loop();
+ eve_screen_hide_kbd(screen);
+ eve_view_destroy(window, stack);
}
diff --git a/fw/fe310/test/modem.h b/fw/fe310/test/modem.h
new file mode 100644
index 0000000..3a6bc35
--- /dev/null
+++ b/fw/fe310/test/modem.h
@@ -0,0 +1,2 @@
+void app_modem(EVEWindow *window, EVEViewStack *stack);
+void app_modem_close(EVEView *view);
diff --git a/fw/fe310/test/phone.c b/fw/fe310/test/phone.c
new file mode 100644
index 0000000..6f88698
--- /dev/null
+++ b/fw/fe310/test/phone.c
@@ -0,0 +1,142 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <eos.h>
+#include <event.h>
+#include <spi.h>
+#include <i2s.h>
+#include <net.h>
+#include <cell.h>
+
+#include <unicode.h>
+
+#include <eve/eve.h>
+#include <eve/eve_kbd.h>
+
+#include <eve/screen/screen.h>
+#include <eve/screen/window.h>
+#include <eve/screen/view.h>
+#include <eve/screen/page.h>
+#include <eve/screen/form.h>
+
+#include <eve/widget/widgets.h>
+
+#include <app/root.h>
+
+#include "status.h"
+#include "phone.h"
+
+extern EVEFont *_app_font_default;
+
+#define ABUF_SIZE 512
+#define MIC_WM 128
+
+static uint8_t mic_arr[ABUF_SIZE];
+static uint8_t spk_arr[ABUF_SIZE];
+
+#define VOICE_STATE_IDLE 0
+#define VOICE_STATE_DIAL 1
+#define VOICE_STATE_RING 2
+#define VOICE_STATE_CIP 3
+
+static unsigned char voice_state = 0;
+
+static void cell_dev_handler(unsigned char type, unsigned char *buffer, uint16_t len) {
+ switch (type) {
+ case EOS_CELL_MTYPE_READY:
+ app_status_msg_set("Modem ready", 1);
+ break;
+
+ case EOS_CELL_MTYPE_PCM_DATA:
+ if (voice_state == VOICE_STATE_CIP) {
+ eos_i2s_spk_write(buffer+1, len-1);
+ }
+ break;
+ }
+ eos_net_free(buffer, 0);
+}
+
+static void cell_voice_handler(unsigned char type, unsigned char *buffer, uint16_t len) {
+ char msg[128];
+
+ printf("VOICE: %d\n", type);
+ msg[0] = 0;
+ switch (type) {
+ case EOS_CELL_MTYPE_VOICE_RING:
+ voice_state = VOICE_STATE_RING;
+ sprintf(msg, "RING:%s", buffer+1);
+ break;
+ case EOS_CELL_MTYPE_VOICE_MISS:
+ voice_state = VOICE_STATE_IDLE;
+ break;
+ case EOS_CELL_MTYPE_VOICE_BEGIN:
+ voice_state = VOICE_STATE_CIP;
+ eos_i2s_start(8000, EOS_I2S_FMT_PCM16);
+ break;
+ case EOS_CELL_MTYPE_VOICE_END:
+ voice_state = VOICE_STATE_IDLE;
+ eos_i2s_stop();
+ break;
+ }
+ app_status_msg_set(msg, 1);
+ eos_net_free(buffer, 0);
+}
+
+static void handle_mic(unsigned char type) {
+ uint16_t size;
+ unsigned char *buf = eos_net_alloc();
+
+ buf[0] = EOS_CELL_MTYPE_PCM_DATA;
+ size = eos_i2s_mic_read(buf+1, MIC_WM);
+ eos_net_send(EOS_NET_MTYPE_CELL, buf, size+1, 0);
+}
+
+void app_phone(EVEWindow *window, EVEViewStack *stack) {
+ char *title = "Phone:";
+ uint16_t w = eve_font_str_w(_app_font_default, title) + 10;
+ APPWidgetSpec spec[] = {
+ {
+ .label.g.w = w,
+ .label.font = _app_font_default,
+ .label.title = title,
+
+ .widget.type = EVE_WIDGET_TYPE_STR,
+ .widget.g.w = APP_SCREEN_W - w,
+ .widget.spec.str.font = _app_font_default,
+ .widget.spec.str.str_size = 128,
+ },
+ };
+
+ EVEForm *form = app_form_create(window, stack, spec, 1, app_phone_action, NULL);
+}
+
+void app_phone_action(EVEForm *form) {
+ char msg[128];
+ EVEStrWidget *w = (EVEStrWidget *)eve_form_widget(form, 0);
+ unsigned char *buf = eos_net_alloc();
+
+ buf[0] = EOS_CELL_MTYPE_VOICE | EOS_CELL_MTYPE_VOICE_DIAL;
+ strcpy(buf + 1, w->str);
+ eos_net_send(EOS_NET_MTYPE_CELL, buf, 1 + strlen(w->str), 0);
+
+ voice_state = VOICE_STATE_DIAL;
+ sprintf(msg, "DIAL:%s", w->str);
+ app_status_msg_set(msg, 0);
+}
+
+void app_phone_init(void) {
+ eos_cell_set_handler(EOS_CELL_MTYPE_DEV, cell_dev_handler);
+ eos_cell_set_handler(EOS_CELL_MTYPE_VOICE, cell_voice_handler);
+
+ eos_i2s_mic_init(mic_arr, ABUF_SIZE);
+ eos_i2s_mic_set_wm(MIC_WM);
+ eos_i2s_mic_set_handler(handle_mic);
+ eos_i2s_spk_init(spk_arr, ABUF_SIZE);
+ eos_net_acquire_for_evt(EOS_EVT_I2S | EOS_I2S_ETYPE_MIC, 1);
+}
+
+unsigned char app_phone_state_get(void) {
+ return voice_state;
+}
diff --git a/fw/fe310/test/phone.h b/fw/fe310/test/phone.h
new file mode 100644
index 0000000..f346a38
--- /dev/null
+++ b/fw/fe310/test/phone.h
@@ -0,0 +1,9 @@
+#define VOICE_STATE_IDLE 0
+#define VOICE_STATE_DIAL 1
+#define VOICE_STATE_RING 2
+#define VOICE_STATE_CIP 3
+
+void app_phone(EVEWindow *window, EVEViewStack *stack);
+void app_phone_action(EVEForm *form);
+void app_phone_init(void);
+unsigned char app_phone_state_get(void);
diff --git a/fw/fe310/test/status.c b/fw/fe310/test/status.c
new file mode 100644
index 0000000..489bf78
--- /dev/null
+++ b/fw/fe310/test/status.c
@@ -0,0 +1,93 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <eos.h>
+#include <event.h>
+#include <spi.h>
+#include <i2s.h>
+#include <net.h>
+#include <cell.h>
+
+#include <unicode.h>
+
+#include <eve/eve.h>
+#include <eve/eve_kbd.h>
+
+#include <eve/screen/screen.h>
+#include <eve/screen/window.h>
+#include <eve/screen/view.h>
+#include <eve/screen/page.h>
+#include <eve/screen/form.h>
+
+#include <eve/widget/widgets.h>
+
+#include <app/root.h>
+
+#include "phone.h"
+#include "status.h"
+
+extern EVEFont *_app_font_default;
+
+static char status_msg[128];
+
+static int status_touch(EVEView *v, uint8_t tag0, int touch_idx) {
+ if (touch_idx == 0) {
+ EVETouch *t;
+ uint16_t evt;
+ unsigned char state = app_phone_state_get();
+
+ t = eve_touch_evt(tag0, touch_idx, v->window->tag, 2, &evt);
+ if (t && (evt & EVE_TOUCH_ETYPE_POINT_UP)) {
+ if ((state == VOICE_STATE_RING) && (t->eevt & EVE_TOUCH_EETYPE_TRACK_LEFT)) {
+ unsigned char *buf = eos_net_alloc();
+
+ buf[0] = EOS_CELL_MTYPE_VOICE | EOS_CELL_MTYPE_VOICE_ANSWER;
+ eos_net_send(EOS_NET_MTYPE_CELL, buf, 1, 0);
+ status_msg[0] = '\0';
+ }
+ if ((state != VOICE_STATE_IDLE) && (t->eevt & EVE_TOUCH_EETYPE_TRACK_RIGHT)) {
+ unsigned char *buf = eos_net_alloc();
+
+ buf[0] = EOS_CELL_MTYPE_VOICE | EOS_CELL_MTYPE_VOICE_HANGUP;
+ eos_net_send(EOS_NET_MTYPE_CELL, buf, 1, 0);
+ status_msg[0] = '\0';
+ }
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static uint8_t status_draw(EVEView *v, uint8_t tag0) {
+ uint8_t tag_opt = EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_XY;
+ if (v->window->tag != EVE_TAG_NOTAG) eve_touch_set_opt(v->window->tag, eve_touch_get_opt(v->window->tag) | tag_opt);
+
+ if (tag0 != EVE_TAG_NOTAG) {
+ eve_touch_set_opt(tag0, eve_touch_get_opt(tag0) | tag_opt);
+ eve_cmd_dl(TAG(tag0));
+ tag0++;
+ }
+
+ eve_cmd(CMD_TEXT, "hhhhs", 0, 0, 31, 0, status_msg);
+
+ return tag0;
+}
+
+void app_status_msg_set(char *msg, int refresh) {
+ strcpy(status_msg, msg);
+
+ if (refresh) {
+ eos_spi_dev_start(EOS_DEV_DISP);
+ eve_screen_draw(app_screen());
+ eos_spi_dev_stop();
+ }
+}
+
+void app_status_init(void) {
+ EVEScreen *screen = app_screen();
+ EVEWindow *status = eve_window_get(screen, "status");
+ status->view->touch = status_touch;
+ status->view->draw = status_draw;
+}
diff --git a/fw/fe310/test/status.h b/fw/fe310/test/status.h
new file mode 100644
index 0000000..c891b7d
--- /dev/null
+++ b/fw/fe310/test/status.h
@@ -0,0 +1,2 @@
+void app_status_msg_set(char *msg, int refresh);
+void app_status_init(void);
diff --git a/fw/fe310/test/wifi.c b/fw/fe310/test/wifi.c
new file mode 100644
index 0000000..595a87c
--- /dev/null
+++ b/fw/fe310/test/wifi.c
@@ -0,0 +1,108 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+
+#include <eos.h>
+#include <event.h>
+#include <spi.h>
+#include <uart.h>
+#include <net.h>
+#include <wifi.h>
+
+#include <unicode.h>
+
+#include <eve/eve.h>
+#include <eve/eve_kbd.h>
+
+#include <eve/screen/screen.h>
+#include <eve/screen/window.h>
+#include <eve/screen/view.h>
+#include <eve/screen/page.h>
+#include <eve/screen/form.h>
+
+#include <eve/widget/widgets.h>
+
+#include <app/root.h>
+
+#include "status.h"
+#include "wifi.h"
+
+extern EVEFont *_app_font_default;
+
+void wifi_scan_handler(unsigned char type, unsigned char *buffer, uint16_t size) {
+ EVEScreen *screen = app_screen();
+ EVEWindow *window = eve_window_get(screen, "main");
+ EVEForm *form = (EVEForm *)window->view;
+ EVESelectWidget *select = (EVESelectWidget *)eve_form_widget(form, 0);
+
+ eve_selectw_option_set(select, buffer + 1, size - 1);
+ eos_net_free(buffer, 0);
+
+ eos_spi_dev_start(EOS_DEV_DISP);
+ eve_screen_draw(app_screen());
+ eos_spi_dev_stop();
+}
+
+static void wifi_connect_handler(unsigned char type, unsigned char *buffer, uint16_t size) {
+ app_status_msg_set("WiFi connected", 1);
+ eos_net_free(buffer, 0);
+}
+
+static void wifi_disconnect_handler(unsigned char type, unsigned char *buffer, uint16_t size) {
+ app_status_msg_set("WiFi disconnected", 1);
+ eos_net_free(buffer, 0);
+}
+
+void app_wifi(EVEWindow *window, EVEViewStack *stack) {
+ char *title = "Password:";
+ uint16_t w = eve_font_str_w(_app_font_default, title) + 10;
+ APPWidgetSpec spec[] = {
+ {
+ .label.g.w = APP_SCREEN_W,
+ .label.font = _app_font_default,
+ .label.title = "Select network:",
+
+ .widget.type = EVE_WIDGET_TYPE_SELECT,
+ .widget.g.w = APP_SCREEN_W,
+ .widget.spec.select.font = _app_font_default,
+ .widget.spec.select.option_size = 1500,
+ },
+ {
+ .widget.type = EVE_WIDGET_TYPE_SPACER,
+ .widget.g.w = APP_SCREEN_W,
+ .widget.g.h = 50,
+ },
+ {
+ .label.g.w = w,
+ .label.font = _app_font_default,
+ .label.title = title,
+
+ .widget.type = EVE_WIDGET_TYPE_STR,
+ .widget.g.w = APP_SCREEN_W - w,
+ .widget.spec.str.font = _app_font_default,
+ .widget.spec.str.str_size = 128,
+ },
+ };
+
+ EVEForm *form = app_form_create(window, stack, spec, 3, app_wifi_action, app_wifi_close);
+ eos_wifi_scan();
+}
+
+void app_wifi_action(EVEForm *form) {
+ EVESelectWidget *sel = (EVESelectWidget *)eve_form_widget(form, 0);
+ EVEStrWidget *str = (EVEStrWidget *)eve_form_widget(form, 2);
+ char *ssid = eve_selectw_option_get_select(sel);
+
+ eos_wifi_connect(ssid, str->str);
+}
+
+void app_wifi_close(EVEForm *form) {
+ app_form_destroy(form);
+}
+
+void app_wifi_init(void) {
+ eos_wifi_set_handler(EOS_WIFI_MTYPE_SCAN, wifi_scan_handler);
+ eos_wifi_set_handler(EOS_WIFI_MTYPE_CONNECT, wifi_connect_handler);
+ eos_wifi_set_handler(EOS_WIFI_MTYPE_DISCONNECT, wifi_disconnect_handler);
+}
diff --git a/fw/fe310/test/wifi.h b/fw/fe310/test/wifi.h
new file mode 100644
index 0000000..5adaebd
--- /dev/null
+++ b/fw/fe310/test/wifi.h
@@ -0,0 +1,4 @@
+void app_wifi(EVEWindow *window, EVEViewStack *stack);
+void app_wifi_action(EVEForm *form);
+void app_wifi_close(EVEForm *form);
+void app_wifi_init(void); \ No newline at end of file