summaryrefslogtreecommitdiff
path: root/fw/esp32/components/eos/cell.c
diff options
context:
space:
mode:
Diffstat (limited to 'fw/esp32/components/eos/cell.c')
-rw-r--r--fw/esp32/components/eos/cell.c50
1 files changed, 35 insertions, 15 deletions
diff --git a/fw/esp32/components/eos/cell.c b/fw/esp32/components/eos/cell.c
index 19245bb..2584884 100644
--- a/fw/esp32/components/eos/cell.c
+++ b/fw/esp32/components/eos/cell.c
@@ -31,46 +31,66 @@ static void _cell_handler(unsigned char _mtype, unsigned char *buffer, uint16_t
if (buf_len < 1) return;
mtype = buffer[0];
- buffer++;
- buf_len--;
-
switch (mtype & EOS_CELL_MTYPE_MASK) {
- case EOS_CELL_MTYPE_DEV:
+ case EOS_CELL_MTYPE_DEV: {
switch (mtype & ~EOS_CELL_MTYPE_MASK) {
- case EOS_CELL_MTYPE_RESET:
- eos_modem_reset();
+ case EOS_CELL_MTYPE_STATUS: {
+ size_t rv;
+
+ rv = eos_modem_get_status(buffer + 1);
+ eos_net_reply(EOS_NET_MTYPE_CELL, buffer, rv + 1);
break;
+ }
- case EOS_CELL_MTYPE_UART_DATA:
- if (eos_modem_get_mode() == EOS_CELL_UART_MODE_RELAY) eos_modem_write(buffer, buf_len);
+ case EOS_CELL_MTYPE_RESET: {
+ eos_modem_reset();
break;
+ }
+
+ case EOS_CELL_MTYPE_UART_TAKE: {
+ uint8_t mode;
+
+ mode = eos_modem_get_mode();
+ if (mode == EOS_CELL_UART_MODE_NONE) break;
- case EOS_CELL_MTYPE_UART_TAKE:
- cell_mode = eos_modem_get_mode();
eos_modem_set_mode(EOS_CELL_UART_MODE_RELAY);
+ cell_mode = mode;
break;
+ }
- case EOS_CELL_MTYPE_UART_GIVE:
+ case EOS_CELL_MTYPE_UART_GIVE: {
+ eos_modem_atinit();
eos_modem_set_mode(cell_mode);
break;
+ }
+
+ case EOS_CELL_MTYPE_UART_DATA: {
+ if (eos_modem_get_mode() == EOS_CELL_UART_MODE_RELAY) eos_modem_write(buffer + 1, buf_len - 1);
+ break;
+ }
}
break;
+ }
- case EOS_CELL_MTYPE_VOICE:
+ case EOS_CELL_MTYPE_VOICE: {
eos_cell_voice_handler(mtype & ~EOS_CELL_MTYPE_MASK, buffer, buf_len);
break;
+ }
- case EOS_CELL_MTYPE_SMS:
+ case EOS_CELL_MTYPE_SMS: {
eos_cell_sms_handler(mtype & ~EOS_CELL_MTYPE_MASK, buffer, buf_len);
break;
+ }
- case EOS_CELL_MTYPE_USSD:
+ case EOS_CELL_MTYPE_USSD: {
eos_cell_ussd_handler(mtype & ~EOS_CELL_MTYPE_MASK, buffer, buf_len);
break;
+ }
- case EOS_CELL_MTYPE_PDP:
+ case EOS_CELL_MTYPE_PDP: {
eos_cell_pdp_handler(mtype & ~EOS_CELL_MTYPE_MASK, buffer, buf_len);
break;
+ }
}
}