diff options
author | Uros Majstorovic <majstor@majstor.org> | 2020-05-09 19:43:25 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2020-05-09 19:43:25 +0200 |
commit | e6c06c38ea7ed2c46a605af4c87f154377caadba (patch) | |
tree | 530981ad07b8a5f08a4a03c7ea5f6f4906354803 | |
parent | 2b73dd935359e57ca32f87e3afd2435d5991685e (diff) |
added sleep/wake for modem; fixed ppp driver API
-rw-r--r-- | code/esp32/components/eos/cell_modem.c | 41 | ||||
-rw-r--r-- | code/esp32/components/eos/include/cell.h | 15 |
2 files changed, 52 insertions, 4 deletions
diff --git a/code/esp32/components/eos/cell_modem.c b/code/esp32/components/eos/cell_modem.c index 50aa23a..79e8e86 100644 --- a/code/esp32/components/eos/cell_modem.c +++ b/code/esp32/components/eos/cell_modem.c @@ -16,6 +16,8 @@ #include "at_urc.h" #include "cell.h" +// XXX: Modem init, reconnect on failure + #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) #define MAX(X, Y) (((X) > (Y)) ? (X) : (Y)) @@ -444,7 +446,7 @@ void eos_modem_init(void) { io_conf.pull_up_en = 0; io_conf.pull_down_en = 0; gpio_config(&io_conf); - gpio_set_level(UART_GPIO_DTR, 1); + gpio_set_level(UART_GPIO_DTR, 0); io_conf.intr_type = GPIO_PIN_INTR_ANYEDGE; io_conf.mode = GPIO_MODE_INPUT; @@ -610,3 +612,40 @@ void eos_modem_give(void) { } xSemaphoreGive(mutex); } + +void eos_modem_sleep(void) { + gpio_set_level(UART_GPIO_DTR, 1); +} + +void eos_modem_wake(void) { + gpio_set_level(UART_GPIO_DTR, 0); +} + +void eos_ppp_set_apn(char *apn) { + xSemaphoreTake(mutex, portMAX_DELAY); + strncpy(ppp_apn, apn, sizeof(ppp_apn) - 1); + xSemaphoreGive(mutex); +} + +void eos_ppp_set_auth(char *user, char *pass) { + xSemaphoreTake(mutex, portMAX_DELAY); + strncpy(ppp_user, user, sizeof(ppp_user) - 1); + strncpy(ppp_pass, pass, sizeof(ppp_pass) - 1); + xSemaphoreGive(mutex); +} + +int eos_ppp_connect(void) { + return eos_modem_set_mode(EOS_CELL_UART_MODE_PPP); +} + +int eos_ppp_disconnect(void) { + int rv = eos_modem_set_mode(EOS_CELL_UART_MODE_ATCMD); + + xSemaphoreTake(mutex, portMAX_DELAY); + memset(ppp_apn, 0, sizeof(ppp_apn)); + memset(ppp_user, 0, sizeof(ppp_user)); + memset(ppp_pass, 0, sizeof(ppp_pass)); + xSemaphoreGive(mutex); + + return rv; +}
\ No newline at end of file diff --git a/code/esp32/components/eos/include/cell.h b/code/esp32/components/eos/include/cell.h index 4a2cfbc..3a9e955 100644 --- a/code/esp32/components/eos/include/cell.h +++ b/code/esp32/components/eos/include/cell.h @@ -10,8 +10,8 @@ #define EOS_CELL_MTYPE_AUDIO_STOP 5 #define EOS_CELL_UART_MODE_NONE 0 -#define EOS_CELL_UART_MODE_PPP 1 -#define EOS_CELL_UART_MODE_ATCMD 2 +#define EOS_CELL_UART_MODE_ATCMD 1 +#define EOS_CELL_UART_MODE_PPP 2 #define EOS_CELL_UART_MODE_RELAY 3 void eos_pcm_init(void); @@ -34,4 +34,13 @@ int eos_modem_set_mode(uint8_t mode); int eos_modem_take(void); void eos_modem_give(void); -void eos_cell_init(void);
\ No newline at end of file +void eos_modem_sleep(void); +void eos_modem_wake(void); + +void eos_ppp_set_apn(char *apn); +void eos_ppp_set_auth(char *user, char *pass); + +int eos_ppp_connect(void); +int eos_ppp_disconnect(void); + +void eos_cell_init(void); |