diff options
Diffstat (limited to 'fw/fe310/phone/cell.c')
-rw-r--r-- | fw/fe310/phone/cell.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/fw/fe310/phone/cell.c b/fw/fe310/phone/cell.c new file mode 100644 index 0000000..47ce8e5 --- /dev/null +++ b/fw/fe310/phone/cell.c @@ -0,0 +1,64 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> + +#include <eos.h> +#include <dev/net.h> +#include <net/cell.h> + +#include "app/log.h" +#include "cell.h" + +void cell_init(void) { + eos_cell_set_handler(EOS_CELL_MTYPE_DEV, cell_msg_handler); +} + +void cell_msg_handler(unsigned char type, unsigned char *buffer, uint16_t len) { + switch (type) { + case EOS_CELL_MTYPE_STATUS: { + uint8_t status, connected; + int rv; + + rv = eos_cell_status_parse(buffer, len, &status, &connected); + if (rv) { + APP_LOG(APP_LOG_ERR, "BAD STATUS ERR:%d\n", rv); + return; + } + APP_LOG(APP_LOG_DEBUG, "MODEM STATUS: "); + switch (status) { + case EOS_CELL_STATUS_RESET: { + APP_LOG(APP_LOG_DEBUG, "RESET\n"); + break; + } + + case EOS_CELL_STATUS_IDLE: { + APP_LOG(APP_LOG_DEBUG, "IDLE\n"); + break; + } + + case EOS_CELL_STATUS_RELAY: { + APP_LOG(APP_LOG_DEBUG, "RELAY\n"); + break; + } + + case EOS_CELL_STATUS_PPP: { + APP_LOG(APP_LOG_DEBUG, "PPP, "); + if (connected) { + APP_LOG(APP_LOG_DEBUG, "CONNECTED\n"); + } else { + APP_LOG(APP_LOG_DEBUG, "NOT CONNECTED\n"); + } + break; + } + + default: { + APP_LOG(APP_LOG_DEBUG, "BAD STATUS\n"); + break; + } + } + break; + } + } + eos_net_free(buffer, 0); +} |