summaryrefslogtreecommitdiff
path: root/code/esp32/components/eos/cell.c
diff options
context:
space:
mode:
Diffstat (limited to 'code/esp32/components/eos/cell.c')
-rw-r--r--code/esp32/components/eos/cell.c59
1 files changed, 43 insertions, 16 deletions
diff --git a/code/esp32/components/eos/cell.c b/code/esp32/components/eos/cell.c
index 2da1450..c2e03e1 100644
--- a/code/esp32/components/eos/cell.c
+++ b/code/esp32/components/eos/cell.c
@@ -10,27 +10,54 @@
static uint8_t cell_mode;
static void cell_handler(unsigned char _mtype, unsigned char *buffer, uint16_t size) {
- uint8_t mtype = buffer[0];
+ uint8_t mtype;
- switch (mtype) {
- case EOS_CELL_MTYPE_DATA:
- if (eos_modem_get_mode() == EOS_CELL_UART_MODE_RELAY) eos_modem_write(buffer+1, size-1);
- break;
- case EOS_CELL_MTYPE_DATA_START:
- cell_mode = eos_modem_get_mode();
- eos_modem_set_mode(EOS_CELL_UART_MODE_RELAY);
+ if (size < 1) return;
+ mtype = buffer[0];
+ switch (mtype & EOS_CELL_MTYPE_MASK) {
+ case EOS_CELL_MTYPE_DEV:
+ switch (mtype) {
+ case EOS_CELL_MTYPE_UART_DATA:
+ if (eos_modem_get_mode() == EOS_CELL_UART_MODE_RELAY) eos_modem_write(buffer+1, size-1);
+ break;
+
+ case EOS_CELL_MTYPE_UART_TAKE:
+ cell_mode = eos_modem_get_mode();
+ eos_modem_set_mode(EOS_CELL_UART_MODE_RELAY);
+ break;
+
+ 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;
- case EOS_CELL_MTYPE_DATA_STOP:
- eos_modem_set_mode(cell_mode);
+
+ case EOS_CELL_MTYPE_VOICE:
+ eos_cell_voice_handler(mtype & ~EOS_CELL_MTYPE_MASK, buffer, size);
break;
- case EOS_CELL_MTYPE_AUDIO:
- eos_pcm_push(buffer+1, size-1);
+
+ case EOS_CELL_MTYPE_SMS:
+ eos_cell_sms_handler(mtype & ~EOS_CELL_MTYPE_MASK, buffer, size);
break;
- case EOS_CELL_MTYPE_AUDIO_START:
- eos_pcm_start();
+
+ case EOS_CELL_MTYPE_USSD:
+ eos_cell_ussd_handler(mtype & ~EOS_CELL_MTYPE_MASK, buffer, size);
break;
- case EOS_CELL_MTYPE_AUDIO_STOP:
- eos_pcm_stop();
+
+ case EOS_CELL_MTYPE_DATA:
+ eos_cell_data_handler(mtype & ~EOS_CELL_MTYPE_MASK, buffer, size);
break;
}
}