summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fw/esp32/components/eos/cell.c16
-rw-r--r--fw/esp32/components/eos/cell_modem.c2
-rw-r--r--fw/esp32/components/eos/cell_pcm.c4
-rw-r--r--fw/esp32/components/eos/cell_pdp.c (renamed from fw/esp32/components/eos/cell_data.c)8
-rw-r--r--fw/esp32/components/eos/cell_voice.c4
-rw-r--r--fw/esp32/components/eos/include/cell.h36
-rw-r--r--fw/esp32/components/eos/include/wifi.h9
-rwxr-xr-xfw/esp32/components/eos/wifi.c35
-rw-r--r--fw/fe310/eos/cell.h34
-rw-r--r--fw/fe310/eos/wifi.c25
-rw-r--r--fw/fe310/eos/wifi.h11
-rw-r--r--fw/fe310/test/Makefile2
-rw-r--r--fw/fe310/test/cell_data.h4
-rw-r--r--fw/fe310/test/cell_pdp.c (renamed from fw/fe310/test/cell_data.c)62
-rw-r--r--fw/fe310/test/cell_pdp.h4
-rw-r--r--fw/fe310/test/main.c9
-rw-r--r--fw/fe310/test/phone.c39
-rw-r--r--fw/fe310/test/wifi.c33
18 files changed, 168 insertions, 169 deletions
diff --git a/fw/esp32/components/eos/cell.c b/fw/esp32/components/eos/cell.c
index 886cc7a..b31e973 100644
--- a/fw/esp32/components/eos/cell.c
+++ b/fw/esp32/components/eos/cell.c
@@ -49,18 +49,6 @@ static void _cell_handler(unsigned char _mtype, unsigned char *buffer, uint16_t
case EOS_CELL_MTYPE_UART_GIVE:
eos_modem_set_mode(cell_mode);
break;
-
- case EOS_CELL_MTYPE_PCM_DATA:
- eos_cell_pcm_push(buffer+1, size-1);
- break;
-
- case EOS_CELL_MTYPE_PCM_START:
- eos_cell_pcm_start();
- break;
-
- case EOS_CELL_MTYPE_PCM_STOP:
- eos_cell_pcm_stop();
- break;
}
break;
@@ -76,8 +64,8 @@ static void _cell_handler(unsigned char _mtype, unsigned char *buffer, uint16_t
eos_cell_ussd_handler(mtype & ~EOS_CELL_MTYPE_MASK, buffer, size);
break;
- case EOS_CELL_MTYPE_DATA:
- eos_cell_data_handler(mtype & ~EOS_CELL_MTYPE_MASK, buffer, size);
+ case EOS_CELL_MTYPE_PDP:
+ eos_cell_pdp_handler(mtype & ~EOS_CELL_MTYPE_MASK, buffer, size);
break;
}
}
diff --git a/fw/esp32/components/eos/cell_modem.c b/fw/esp32/components/eos/cell_modem.c
index 3bbce90..58dc97c 100644
--- a/fw/esp32/components/eos/cell_modem.c
+++ b/fw/esp32/components/eos/cell_modem.c
@@ -364,7 +364,7 @@ static void ppp_status_cb(ppp_pcb *pcb, int err_code, void *ctx) {
ESP_LOGI(TAG," his_ipaddr = %s\n", ipaddr_ntoa(&pppif->gw));
ESP_LOGI(TAG," netmask = %s\n", ipaddr_ntoa(&pppif->netmask));
rbuf = eos_net_alloc();
- rbuf[0] = EOS_CELL_MTYPE_DATA | EOS_CELL_MTYPE_DATA_CONNECT;
+ rbuf[0] = EOS_CELL_MTYPE_PDP | EOS_CELL_MTYPE_PDP_CONNECT;
rbuf[1] = EOS_OK;
eos_net_send(EOS_NET_MTYPE_CELL, rbuf, 2);
return;
diff --git a/fw/esp32/components/eos/cell_pcm.c b/fw/esp32/components/eos/cell_pcm.c
index 4930d66..cf3eeb7 100644
--- a/fw/esp32/components/eos/cell_pcm.c
+++ b/fw/esp32/components/eos/cell_pcm.c
@@ -61,14 +61,14 @@ static void i2s_event_task(void *pvParameters) {
// Event of I2S receiving data
if (!hold_cnt) {
buf = eos_net_alloc();
- buf[0] = EOS_CELL_MTYPE_DEV | EOS_CELL_MTYPE_PCM_DATA;
+ buf[0] = EOS_CELL_MTYPE_VOICE | EOS_CELL_MTYPE_VOICE_PCM;
bytes_r = eos_cell_pcm_read(buf + 1, PCM_MIC_WM);
eos_net_send(EOS_NET_MTYPE_CELL, buf, bytes_r + 1);
} else {
hold_cnt--;
if (hold_buf == NULL) {
hold_buf = eos_net_alloc();
- hold_buf[0] = EOS_CELL_MTYPE_DEV | EOS_CELL_MTYPE_PCM_DATA;
+ hold_buf[0] = EOS_CELL_MTYPE_VOICE | EOS_CELL_MTYPE_VOICE_PCM;
}
if (1 + hold_bytes_r + PCM_MIC_WM <= EOS_NET_SIZE_BUF) hold_bytes_r += eos_cell_pcm_read(hold_buf + 1 + hold_bytes_r, PCM_MIC_WM);
if (hold_cnt == 0) {
diff --git a/fw/esp32/components/eos/cell_data.c b/fw/esp32/components/eos/cell_pdp.c
index f9a755f..1aa0575 100644
--- a/fw/esp32/components/eos/cell_data.c
+++ b/fw/esp32/components/eos/cell_pdp.c
@@ -6,13 +6,13 @@
#include "eos.h"
#include "cell.h"
-void eos_cell_data_handler(unsigned char mtype, unsigned char *buffer, uint16_t size) {
+void eos_cell_pdp_handler(unsigned char mtype, unsigned char *buffer, uint16_t size) {
char *apn, *user, *pass;
buffer += 1;
size -= 1;
switch (mtype) {
- case EOS_CELL_MTYPE_DATA_CONFIGURE:
+ case EOS_CELL_MTYPE_PDP_CONFIG:
apn = (char *)buffer;
user = apn + strlen(apn) + 1;
pass = user + strlen(user) + 1;
@@ -20,11 +20,11 @@ void eos_cell_data_handler(unsigned char mtype, unsigned char *buffer, uint16_t
eos_ppp_set_auth(user, pass);
break;
- case EOS_CELL_MTYPE_DATA_CONNECT:
+ case EOS_CELL_MTYPE_PDP_CONNECT:
eos_ppp_connect();
break;
- case EOS_CELL_MTYPE_DATA_DISCONNECT:
+ case EOS_CELL_MTYPE_PDP_DISCONNECT:
eos_ppp_disconnect();
break;
}
diff --git a/fw/esp32/components/eos/cell_voice.c b/fw/esp32/components/eos/cell_voice.c
index f820b63..f0655bd 100644
--- a/fw/esp32/components/eos/cell_voice.c
+++ b/fw/esp32/components/eos/cell_voice.c
@@ -57,6 +57,10 @@ void eos_cell_voice_handler(unsigned char mtype, unsigned char *buffer, uint16_t
eos_modem_give();
break;
+
+ case EOS_CELL_MTYPE_VOICE_PCM:
+ eos_cell_pcm_push(buffer+1, size-1);
+ break;
}
}
diff --git a/fw/esp32/components/eos/include/cell.h b/fw/esp32/components/eos/include/cell.h
index 07d1144..fa9a0e2 100644
--- a/fw/esp32/components/eos/include/cell.h
+++ b/fw/esp32/components/eos/include/cell.h
@@ -6,7 +6,7 @@
#define EOS_CELL_MTYPE_SMS 0x30
#define EOS_CELL_MTYPE_CBS 0x40
#define EOS_CELL_MTYPE_USSD 0x50
-#define EOS_CELL_MTYPE_DATA 0x70
+#define EOS_CELL_MTYPE_PDP 0x60
#define EOS_CELL_MTYPE_MASK 0xf0
#define EOS_CELL_MAX_MTYPE 8
@@ -16,20 +16,18 @@
#define EOS_CELL_MTYPE_UART_DATA 2
#define EOS_CELL_MTYPE_UART_TAKE 3
#define EOS_CELL_MTYPE_UART_GIVE 4
-#define EOS_CELL_MTYPE_PCM_DATA 5
-#define EOS_CELL_MTYPE_PCM_START 6
-#define EOS_CELL_MTYPE_PCM_STOP 7
-#define EOS_CELL_MTYPE_RESET 8
-
-#define EOS_CELL_MTYPE_VOICE_DIAL 1
-#define EOS_CELL_MTYPE_VOICE_RING 2
-#define EOS_CELL_MTYPE_VOICE_ANSWER 3
-#define EOS_CELL_MTYPE_VOICE_HANGUP 4
-#define EOS_CELL_MTYPE_VOICE_BEGIN 5
-#define EOS_CELL_MTYPE_VOICE_END 6
-#define EOS_CELL_MTYPE_VOICE_MISS 7
-#define EOS_CELL_MTYPE_VOICE_BUSY 8
-#define EOS_CELL_MTYPE_VOICE_ERR 9
+#define EOS_CELL_MTYPE_RESET 5
+
+#define EOS_CELL_MTYPE_VOICE_PCM 1
+#define EOS_CELL_MTYPE_VOICE_DIAL 2
+#define EOS_CELL_MTYPE_VOICE_RING 3
+#define EOS_CELL_MTYPE_VOICE_ANSWER 4
+#define EOS_CELL_MTYPE_VOICE_HANGUP 5
+#define EOS_CELL_MTYPE_VOICE_BEGIN 6
+#define EOS_CELL_MTYPE_VOICE_END 7
+#define EOS_CELL_MTYPE_VOICE_MISS 8
+#define EOS_CELL_MTYPE_VOICE_BUSY 9
+#define EOS_CELL_MTYPE_VOICE_ERR 10
#define EOS_CELL_MTYPE_SMS_LIST 1
#define EOS_CELL_MTYPE_SMS_SEND 2
@@ -40,9 +38,9 @@
#define EOS_CELL_MTYPE_USSD_REPLY 2
#define EOS_CELL_MTYPE_USSD_CANCEL 3
-#define EOS_CELL_MTYPE_DATA_CONFIGURE 1
-#define EOS_CELL_MTYPE_DATA_CONNECT 2
-#define EOS_CELL_MTYPE_DATA_DISCONNECT 3
+#define EOS_CELL_MTYPE_PDP_CONFIG 1
+#define EOS_CELL_MTYPE_PDP_CONNECT 2
+#define EOS_CELL_MTYPE_PDP_DISCONNECT 3
#define EOS_CELL_SMS_ADDRTYPE_INTL 1
#define EOS_CELL_SMS_ADDRTYPE_ALPHA 2
@@ -86,7 +84,7 @@ void eos_cell_pcm_stop(void);
void eos_cell_voice_handler(unsigned char mtype, unsigned char *buffer, uint16_t size);
void eos_cell_sms_handler(unsigned char mtype, unsigned char *buffer, uint16_t size);
void eos_cell_ussd_handler(unsigned char mtype, unsigned char *buffer, uint16_t size);
-void eos_cell_data_handler(unsigned char mtype, unsigned char *buffer, uint16_t size);
+void eos_cell_pdp_handler(unsigned char mtype, unsigned char *buffer, uint16_t size);
void eos_cell_voice_init(void);
void eos_cell_sms_init(void);
diff --git a/fw/esp32/components/eos/include/wifi.h b/fw/esp32/components/eos/include/wifi.h
index d579fc5..11bccec 100644
--- a/fw/esp32/components/eos/include/wifi.h
+++ b/fw/esp32/components/eos/include/wifi.h
@@ -1,12 +1,13 @@
#define EOS_WIFI_MTYPE_SCAN 1
-#define EOS_WIFI_MTYPE_CONNECT 2
-#define EOS_WIFI_MTYPE_DISCONNECT 3
+#define EOS_WIFI_MTYPE_CONFIG 2
+#define EOS_WIFI_MTYPE_CONNECT 3
+#define EOS_WIFI_MTYPE_DISCONNECT 4
-#define EOS_WIFI_MAX_MTYPE 4
+#define EOS_WIFI_MAX_MTYPE 5
void eos_wifi_init(void);
int eos_wifi_scan(void);
-int eos_wifi_set_auth(char *ssid, char *pass);
+int eos_wifi_set_config(char *ssid, char *pass);
int eos_wifi_connect(void);
int eos_wifi_disconnect(void);
diff --git a/fw/esp32/components/eos/wifi.c b/fw/esp32/components/eos/wifi.c
index 7fae635..05c91c1 100755
--- a/fw/esp32/components/eos/wifi.c
+++ b/fw/esp32/components/eos/wifi.c
@@ -126,14 +126,8 @@ static void wifi_event_handler(void *arg, esp_event_base_t event_base, int32_t e
if (_disconnect) {
rbuf = eos_net_alloc();
- if (_action == WIFI_ACTION_CONNECT) {
- rbuf[0] = EOS_WIFI_MTYPE_CONNECT;
- rbuf[1] = EOS_ERR;
- eos_net_send(EOS_NET_MTYPE_WIFI, rbuf, 2);
- } else {
- rbuf[0] = EOS_WIFI_MTYPE_DISCONNECT;
- eos_net_send(EOS_NET_MTYPE_WIFI, rbuf, 1);
- }
+ rbuf[0] = EOS_WIFI_MTYPE_DISCONNECT;
+ eos_net_send(EOS_NET_MTYPE_WIFI, rbuf, 1);
if (!_action) ret = esp_wifi_stop();
} else {
ret = esp_wifi_connect();
@@ -175,26 +169,37 @@ static void wifi_event_handler(void *arg, esp_event_base_t event_base, int32_t e
}
static void wifi_handler(unsigned char _mtype, unsigned char *buffer, uint16_t size) {
- int rv = EOS_OK;
- uint8_t mtype = buffer[0];
+ uint8_t mtype;
+ int rv;
char *ssid, *pass;
+ if (size < 1) return;
+
+ mtype = buffer[0];
+ rv = EOS_OK;
+ buffer += 1;
+ size -= 1;
+
switch (mtype) {
case EOS_WIFI_MTYPE_SCAN:
rv = eos_wifi_scan();
break;
+ case EOS_WIFI_MTYPE_CONFIG:
+ ssid = (char *)buffer;
+ pass = ssid + strlen(ssid) + 1;
+ rv = eos_wifi_set_config(ssid, pass);
+ break;
+
case EOS_WIFI_MTYPE_CONNECT:
- ssid = (char *)buffer+1;
- pass = ssid+strlen(ssid)+1;
- rv = eos_wifi_set_auth(ssid, pass);
- if (!rv) rv = eos_wifi_connect();
+ rv = eos_wifi_connect();
break;
case EOS_WIFI_MTYPE_DISCONNECT:
rv = eos_wifi_disconnect();
break;
}
+
if (rv) ESP_LOGE(TAG, "MSG HANDLER ERR:%d MSG:%d", rv, mtype);
}
@@ -264,7 +269,7 @@ int eos_wifi_scan(void) {
return rv;
}
-int eos_wifi_set_auth(char *ssid, char *pass) {
+int eos_wifi_set_config(char *ssid, char *pass) {
int rv = EOS_OK;
xSemaphoreTake(mutex, portMAX_DELAY);
diff --git a/fw/fe310/eos/cell.h b/fw/fe310/eos/cell.h
index 90bb349..0fc2052 100644
--- a/fw/fe310/eos/cell.h
+++ b/fw/fe310/eos/cell.h
@@ -6,7 +6,7 @@
#define EOS_CELL_MTYPE_SMS 0x30
#define EOS_CELL_MTYPE_CBS 0x40
#define EOS_CELL_MTYPE_USSD 0x50
-#define EOS_CELL_MTYPE_DATA 0x70
+#define EOS_CELL_MTYPE_PDP 0x60
#define EOS_CELL_MTYPE_MASK 0xf0
#define EOS_CELL_MAX_MTYPE 8
@@ -16,20 +16,18 @@
#define EOS_CELL_MTYPE_UART_DATA 2
#define EOS_CELL_MTYPE_UART_TAKE 3
#define EOS_CELL_MTYPE_UART_GIVE 4
-#define EOS_CELL_MTYPE_PCM_DATA 5
-#define EOS_CELL_MTYPE_PCM_START 6
-#define EOS_CELL_MTYPE_PCM_STOP 7
-#define EOS_CELL_MTYPE_RESET 8
-
-#define EOS_CELL_MTYPE_VOICE_DIAL 1
-#define EOS_CELL_MTYPE_VOICE_RING 2
-#define EOS_CELL_MTYPE_VOICE_ANSWER 3
-#define EOS_CELL_MTYPE_VOICE_HANGUP 4
-#define EOS_CELL_MTYPE_VOICE_BEGIN 5
-#define EOS_CELL_MTYPE_VOICE_END 6
-#define EOS_CELL_MTYPE_VOICE_MISS 7
-#define EOS_CELL_MTYPE_VOICE_BUSY 8
-#define EOS_CELL_MTYPE_VOICE_ERR 9
+#define EOS_CELL_MTYPE_RESET 5
+
+#define EOS_CELL_MTYPE_VOICE_PCM 1
+#define EOS_CELL_MTYPE_VOICE_DIAL 2
+#define EOS_CELL_MTYPE_VOICE_RING 3
+#define EOS_CELL_MTYPE_VOICE_ANSWER 4
+#define EOS_CELL_MTYPE_VOICE_HANGUP 5
+#define EOS_CELL_MTYPE_VOICE_BEGIN 6
+#define EOS_CELL_MTYPE_VOICE_END 7
+#define EOS_CELL_MTYPE_VOICE_MISS 8
+#define EOS_CELL_MTYPE_VOICE_BUSY 9
+#define EOS_CELL_MTYPE_VOICE_ERR 10
#define EOS_CELL_MTYPE_SMS_LIST 1
#define EOS_CELL_MTYPE_SMS_SEND 2
@@ -40,9 +38,9 @@
#define EOS_CELL_MTYPE_USSD_REPLY 2
#define EOS_CELL_MTYPE_USSD_CANCEL 3
-#define EOS_CELL_MTYPE_DATA_CONFIGURE 1
-#define EOS_CELL_MTYPE_DATA_CONNECT 2
-#define EOS_CELL_MTYPE_DATA_DISCONNECT 3
+#define EOS_CELL_MTYPE_PDP_CONFIG 1
+#define EOS_CELL_MTYPE_PDP_CONNECT 2
+#define EOS_CELL_MTYPE_PDP_DISCONNECT 3
#define EOS_CELL_SMS_ADDRTYPE_INTL 1
#define EOS_CELL_SMS_ADDRTYPE_ALPHA 2
diff --git a/fw/fe310/eos/wifi.c b/fw/fe310/eos/wifi.c
index c3449e8..ca29a95 100644
--- a/fw/fe310/eos/wifi.c
+++ b/fw/fe310/eos/wifi.c
@@ -43,28 +43,3 @@ eos_evt_handler_t eos_wifi_get_handler(unsigned char mtype) {
if (mtype < EOS_WIFI_MAX_MTYPE) return evt_handler[mtype];
return NULL;
}
-
-void eos_wifi_scan(void) {
- unsigned char *buffer = eos_net_alloc();
- buffer[0] = EOS_WIFI_MTYPE_SCAN;
- eos_net_send(EOS_NET_MTYPE_WIFI, buffer, 1, 0);
-}
-
-void eos_wifi_connect(const char *ssid, const char *pass) {
- int ssid_len = strlen(ssid);
- int pass_len = strlen(pass);
- unsigned char *buffer = eos_net_alloc();
-
- buffer[0] = EOS_WIFI_MTYPE_CONNECT;
- strcpy(buffer+1, ssid);
- buffer[ssid_len+1] = 0;
- strcpy(buffer+ssid_len+2, pass);
- buffer[ssid_len+pass_len+2] = 0;
- eos_net_send(EOS_NET_MTYPE_WIFI, buffer, ssid_len+pass_len+3, 0);
-}
-
-void eos_wifi_disconnect(void) {
- unsigned char *buffer = eos_net_alloc();
- buffer[0] = EOS_WIFI_MTYPE_DISCONNECT;
- eos_net_send(EOS_NET_MTYPE_WIFI, buffer, 1, 0);
-}
diff --git a/fw/fe310/eos/wifi.h b/fw/fe310/eos/wifi.h
index 57048af..bb629ed 100644
--- a/fw/fe310/eos/wifi.h
+++ b/fw/fe310/eos/wifi.h
@@ -2,15 +2,12 @@
#include "event.h"
#define EOS_WIFI_MTYPE_SCAN 1
-#define EOS_WIFI_MTYPE_CONNECT 2
-#define EOS_WIFI_MTYPE_DISCONNECT 3
+#define EOS_WIFI_MTYPE_CONFIG 2
+#define EOS_WIFI_MTYPE_CONNECT 3
+#define EOS_WIFI_MTYPE_DISCONNECT 4
-#define EOS_WIFI_MAX_MTYPE 4
+#define EOS_WIFI_MAX_MTYPE 5
void eos_wifi_init(void);
void eos_wifi_set_handler(unsigned char mtype, eos_evt_handler_t handler);
eos_evt_handler_t eos_wifi_get_handler(unsigned char mtype);
-
-void eos_wifi_scan(void);
-void eos_wifi_connect(const char *ssid, const char *pass);
-void eos_wifi_disconnect(void);
diff --git a/fw/fe310/test/Makefile b/fw/fe310/test/Makefile
index 53e6f2d..aef5f29 100644
--- a/fw/fe310/test/Makefile
+++ b/fw/fe310/test/Makefile
@@ -3,7 +3,7 @@ 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
-DEPS = main.o status.o phone.o wifi.o cell_data.o modem.o
+DEPS = main.o status.o cell_dev.o cell_pdp.o phone.o modem.o wifi.o
TARGET = phone
all: $(TARGET)
diff --git a/fw/fe310/test/cell_data.h b/fw/fe310/test/cell_data.h
deleted file mode 100644
index 69ae2ef..0000000
--- a/fw/fe310/test/cell_data.h
+++ /dev/null
@@ -1,4 +0,0 @@
-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/cell_data.c b/fw/fe310/test/cell_pdp.c
index 007fa0b..955b42e 100644
--- a/fw/fe310/test/cell_data.c
+++ b/fw/fe310/test/cell_pdp.c
@@ -26,17 +26,42 @@
#include <app/root.h>
#include "status.h"
-#include "cell_data.h"
+#include "cell_pdp.h"
extern EVEFont *_app_font_default;
-static void cell_data_handler(unsigned char type, unsigned char *buffer, uint16_t size) {
+static void cell_pdp_connect(char *apn, char *user, char *pass) {
+ unsigned char *buffer, *p;
+
+ buffer = eos_net_alloc();
+ buffer[0] = EOS_CELL_MTYPE_PDP | EOS_CELL_MTYPE_PDP_CONFIG;
+ p = buffer + 1;
+ strcpy(p, user);
+ p += strlen(user) + 1;
+ strcpy(p, user);
+ p += strlen(user) + 1;
+ strcpy(p, pass);
+ p += strlen(pass) + 1;
+ eos_net_send(EOS_NET_MTYPE_CELL, buffer, p - buffer, 1);
+
+ buffer = eos_net_alloc();
+ buffer[0] = EOS_CELL_MTYPE_PDP | EOS_CELL_MTYPE_PDP_CONNECT;
+ eos_net_send(EOS_NET_MTYPE_CELL, buffer, 1, 0);
+}
+
+static void cell_pdp_disconnect(void) {
+ unsigned char *buffer = eos_net_alloc();
+ buffer[0] = EOS_CELL_MTYPE_PDP | EOS_CELL_MTYPE_PDP_DISCONNECT;
+ eos_net_send(EOS_NET_MTYPE_CELL, buffer, 1, 0);
+}
+
+static void cell_pdp_handler(unsigned char type, unsigned char *buffer, uint16_t size) {
switch (type) {
- case EOS_CELL_MTYPE_DATA_CONNECT:
+ case EOS_CELL_MTYPE_PDP_CONNECT:
app_status_msg_set("Cell data connected", 1);
break;
- case EOS_CELL_MTYPE_DATA_DISCONNECT:
+ case EOS_CELL_MTYPE_PDP_DISCONNECT:
app_status_msg_set("Cell data disconnected", 1);
break;
@@ -46,7 +71,7 @@ static void cell_data_handler(unsigned char type, unsigned char *buffer, uint16_
eos_net_free(buffer, 0);
}
-void app_cell_data(EVEWindow *window, EVEViewStack *stack) {
+void app_cell_pdp(EVEWindow *window, EVEViewStack *stack) {
APPWidgetSpec spec[] = {
{
.label.g.w = APP_SCREEN_W / 3,
@@ -80,36 +105,21 @@ void app_cell_data(EVEWindow *window, EVEViewStack *stack) {
},
};
- EVEForm *form = app_form_create(window, stack, spec, 3, app_cell_data_action, app_cell_data_close);
+ EVEForm *form = app_form_create(window, stack, spec, 3, app_cell_pdp_action, app_cell_pdp_close);
}
-void app_cell_data_action(EVEForm *form) {
- unsigned char *buf = eos_net_alloc();
- unsigned char *p;
+void app_cell_pdp_action(EVEForm *form) {
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);
+ cell_pdp_connect(apn->str, user->str, pass->str);
}
-void app_cell_data_close(EVEForm *form) {
+void app_cell_pdp_close(EVEForm *form) {
app_form_destroy(form);
}
-void app_cell_data_init(void) {
- eos_cell_set_handler(EOS_CELL_MTYPE_DATA, cell_data_handler);
+void app_cell_pdp_init(void) {
+ eos_cell_set_handler(EOS_CELL_MTYPE_PDP, cell_pdp_handler);
}
diff --git a/fw/fe310/test/cell_pdp.h b/fw/fe310/test/cell_pdp.h
new file mode 100644
index 0000000..3c28176
--- /dev/null
+++ b/fw/fe310/test/cell_pdp.h
@@ -0,0 +1,4 @@
+void app_cell_pdp(EVEWindow *window, EVEViewStack *stack);
+void app_cell_pdp_action(EVEForm *form);
+void app_cell_pdp_close(EVEForm *form);
+void app_cell_pdp_init(void); \ No newline at end of file
diff --git a/fw/fe310/test/main.c b/fw/fe310/test/main.c
index 095746d..6801b97 100644
--- a/fw/fe310/test/main.c
+++ b/fw/fe310/test/main.c
@@ -26,10 +26,11 @@
#include <app/root.h>
#include "status.h"
+#include "cell_dev.h"
+#include "cell_pdp.h"
#include "phone.h"
-#include "wifi.h"
-#include "cell_data.h"
#include "modem.h"
+#include "wifi.h"
extern EVEFont *_app_font_default;
@@ -54,7 +55,7 @@ void app_home_page(EVEWindow *window, EVEViewStack *stack) {
.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.spec.page.constructor = app_cell_pdp
},
{
.widget.type = EVE_WIDGET_TYPE_PAGE,
@@ -77,7 +78,7 @@ int main() {
app_status_init();
app_phone_init();
app_wifi_init();
- app_cell_data_init();
+ app_cell_pdp_init();
eos_evtq_loop();
}
diff --git a/fw/fe310/test/phone.c b/fw/fe310/test/phone.c
index 6f88698..2832fc4 100644
--- a/fw/fe310/test/phone.c
+++ b/fw/fe310/test/phone.c
@@ -43,19 +43,13 @@ static uint8_t spk_arr[ABUF_SIZE];
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;
+static void handle_mic(unsigned char type) {
+ uint16_t size;
+ unsigned char *buf = eos_net_alloc();
- 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);
+ buf[0] = EOS_CELL_MTYPE_VOICE_PCM;
+ size = eos_i2s_mic_read(buf+1, MIC_WM);
+ eos_net_send(EOS_NET_MTYPE_CELL, buf, size+1, 0);
}
static void cell_voice_handler(unsigned char type, unsigned char *buffer, uint16_t len) {
@@ -68,31 +62,31 @@ static void cell_voice_handler(unsigned char type, unsigned char *buffer, uint16
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;
+
+ case EOS_CELL_MTYPE_VOICE_PCM:
+ if (voice_state == VOICE_STATE_CIP) {
+ eos_i2s_spk_write(buffer+1, len-1);
+ }
+ 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;
@@ -122,12 +116,11 @@ void app_phone_action(EVEForm *form) {
eos_net_send(EOS_NET_MTYPE_CELL, buf, 1 + strlen(w->str), 0);
voice_state = VOICE_STATE_DIAL;
- sprintf(msg, "DIAL:%s", w->str);
+ 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);
diff --git a/fw/fe310/test/wifi.c b/fw/fe310/test/wifi.c
index 595a87c..86f6b62 100644
--- a/fw/fe310/test/wifi.c
+++ b/fw/fe310/test/wifi.c
@@ -30,6 +30,35 @@
extern EVEFont *_app_font_default;
+static void wifi_scan(void) {
+ unsigned char *buffer = eos_net_alloc();
+ buffer[0] = EOS_WIFI_MTYPE_SCAN;
+ eos_net_send(EOS_NET_MTYPE_WIFI, buffer, 1, 0);
+}
+
+static void wifi_connect(const char *ssid, const char *pass) {
+ unsigned char *buffer, *p;
+
+ buffer = eos_net_alloc();
+ buffer[0] = EOS_WIFI_MTYPE_CONFIG;
+ p = buffer + 1;
+ strcpy(p, ssid);
+ p += strlen(ssid) + 1;
+ strcpy(p, pass);
+ p += strlen(pass) + 1;
+ eos_net_send(EOS_NET_MTYPE_WIFI, buffer, p - buffer, 1);
+
+ buffer = eos_net_alloc();
+ buffer[0] = EOS_WIFI_MTYPE_CONNECT;
+ eos_net_send(EOS_NET_MTYPE_WIFI, buffer, 1, 0);
+}
+
+static void wifi_disconnect(void) {
+ unsigned char *buffer = eos_net_alloc();
+ buffer[0] = EOS_WIFI_MTYPE_DISCONNECT;
+ eos_net_send(EOS_NET_MTYPE_WIFI, buffer, 1, 0);
+}
+
void wifi_scan_handler(unsigned char type, unsigned char *buffer, uint16_t size) {
EVEScreen *screen = app_screen();
EVEWindow *window = eve_window_get(screen, "main");
@@ -86,7 +115,7 @@ void app_wifi(EVEWindow *window, EVEViewStack *stack) {
};
EVEForm *form = app_form_create(window, stack, spec, 3, app_wifi_action, app_wifi_close);
- eos_wifi_scan();
+ wifi_scan();
}
void app_wifi_action(EVEForm *form) {
@@ -94,7 +123,7 @@ void app_wifi_action(EVEForm *form) {
EVEStrWidget *str = (EVEStrWidget *)eve_form_widget(form, 2);
char *ssid = eve_selectw_option_get_select(sel);
- eos_wifi_connect(ssid, str->str);
+ if (ssid) wifi_connect(ssid, str->str);
}
void app_wifi_close(EVEForm *form) {