summaryrefslogtreecommitdiff
path: root/fw/esp32/components/eos/cell_pdp.c
diff options
context:
space:
mode:
Diffstat (limited to 'fw/esp32/components/eos/cell_pdp.c')
-rw-r--r--fw/esp32/components/eos/cell_pdp.c93
1 files changed, 64 insertions, 29 deletions
diff --git a/fw/esp32/components/eos/cell_pdp.c b/fw/esp32/components/eos/cell_pdp.c
index 4c5321a..fc4739a 100644
--- a/fw/esp32/components/eos/cell_pdp.c
+++ b/fw/esp32/components/eos/cell_pdp.c
@@ -4,45 +4,80 @@
#include <esp_log.h>
#include "eos.h"
+#include "net.h"
#include "cell.h"
void eos_cell_pdp_handler(unsigned char mtype, unsigned char *buffer, uint16_t buf_len) {
- char *apn, *user, *pass, *_buf;
- uint16_t _buf_len;
-
switch (mtype) {
- case EOS_CELL_MTYPE_PDP_CONFIG:
- _buf = (char *)buffer;
- _buf_len = 0;
-
- apn = _buf;
- _buf_len = strnlen(_buf, buf_len);
- if (_buf_len == buf_len) break;
- _buf += _buf_len + 1;
- buf_len -= _buf_len + 1;
-
- user = _buf;
- _buf_len = strnlen(_buf, buf_len);
- if (_buf_len == buf_len) break;
- _buf += _buf_len + 1;
- buf_len -= _buf_len + 1;
-
- pass = _buf;
- _buf_len = strnlen(_buf, buf_len);
- if (_buf_len == buf_len) break;
- _buf += _buf_len + 1;
- buf_len -= _buf_len + 1;
-
- eos_ppp_set_apn(apn);
- eos_ppp_set_auth(user, pass);
+ case EOS_CELL_MTYPE_PDP_SET_APN:
+ case EOS_CELL_MTYPE_PDP_SET_USR:
+ case EOS_CELL_MTYPE_PDP_SET_PWD: {
+ char *arg;
+ size_t arg_len;
+
+ buffer++;
+ buf_len--;
+
+ arg = (char *)buffer;
+ arg_len = strnlen(arg, buf_len);
+ if (arg_len == buf_len) break;
+ if (arg_len >= EOS_CELL_PDP_SIZE_ARG) break;
+
+ switch (mtype) {
+ case EOS_CELL_MTYPE_PDP_SET_APN: {
+ eos_ppp_set_apn(arg);
+ break;
+
+ }
+ case EOS_CELL_MTYPE_PDP_SET_USR: {
+ eos_ppp_set_usr(arg);
+ break;
+
+ }
+ case EOS_CELL_MTYPE_PDP_SET_PWD: {
+ eos_ppp_set_pwd(arg);
+ break;
+ }
+ }
+ break;
+ }
+
+ case EOS_CELL_MTYPE_PDP_GET_APN:
+ case EOS_CELL_MTYPE_PDP_GET_USR:
+ case EOS_CELL_MTYPE_PDP_GET_PWD: {
+ char *arg;
+
+ buffer[0] = EOS_CELL_MTYPE_PDP | mtype;
+ arg = (char *)(buffer + 1);
+ switch (mtype) {
+ case EOS_CELL_MTYPE_PDP_GET_APN: {
+ eos_ppp_get_apn(arg);
+ break;
+
+ }
+ case EOS_CELL_MTYPE_PDP_GET_USR: {
+ eos_ppp_get_usr(arg);
+ break;
+
+ }
+ case EOS_CELL_MTYPE_PDP_GET_PWD: {
+ eos_ppp_get_pwd(arg);
+ break;
+ }
+ }
+
+ eos_net_reply(EOS_NET_MTYPE_CELL, buffer, 1 + strlen(arg));
break;
+ }
- case EOS_CELL_MTYPE_PDP_CONNECT:
+ case EOS_CELL_MTYPE_PDP_CONNECT: {
eos_ppp_connect();
break;
+ }
- case EOS_CELL_MTYPE_PDP_DISCONNECT:
+ case EOS_CELL_MTYPE_PDP_DISCONNECT: {
eos_ppp_disconnect();
break;
+ }
}
}