atd

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/atd
Log | Files | Refs

commit 6cb2f184dba4f150513f26ebd8cfb0650286395b
parent 1ebc105303485bce4d68022b9f539c3b33171f7b
Author: Nihal Jere <nihal@nihaljere.xyz>
Date:   Mon,  2 Aug 2021 00:11:31 -0500

atd: decode pdu

Diffstat:
Matd.c | 24++++++++++++++++++++++++
1 file changed, 24 insertions(+), 0 deletions(-)

diff --git a/atd.c b/atd.c @@ -14,6 +14,7 @@ #include "atd.h" #include "encdec.h" +#include "pdu.h" #include "util.h" #include "queue.h" @@ -37,6 +38,8 @@ #define BUFSIZE 256 +int nextline(); + int curline_len; char *startup[] = { "AT+CLIP=1\r", "AT+COLP=1\r", "AT+CNMI=2,2,0,1,0" }; @@ -173,6 +176,27 @@ send_colp(char *start, size_t len) } int +process_cmt(char *start, size_t len) +{ + char pdubuf[1024]; + struct pdu_msg pdu_msg; + unsigned int pdulen; + int ret = sscanf(start, "+CMT: ,%u", &pdulen); + if (ret != 1) + return -1; + + ret = nextline(); + if (ret == -1) + return -1; + fprintf(stderr, "nextline len: %d\n", curline_len - 2); + + memcpy(pdubuf, fdbufs[BACKEND].out, curline_len - 2); + pdubuf[curline_len - 2] = 0; + decode_pdu(&pdu_msg, pdubuf); + fprintf(stderr, "message from %s: %s\n", pdu_msg.d.d.sender.number, pdu_msg.d.d.msg.data); +} + +int lprint(char *buf, size_t len) { for (int i = 0; i < len; i++) {