sms-tool: add support for sending raw pdu
This commit is contained in:
parent
41f4fa3ee0
commit
5f39470aba
@ -5,8 +5,9 @@ PKG_RELEASE:=1
|
||||
|
||||
PKG_SOURCE_URL:=https://github.com/obsy/sms_tool
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_DATE:=2021-08-24
|
||||
PKG_SOURCE_VERSION:=57a68d07c3d38fd8766d2705fd2a2c1ae01ee004
|
||||
PKG_SOURCE_DATE:=2023-09-21
|
||||
PKG_SOURCE_VERSION:=1b6ca03284fd65db8799dbf7c6224210093786b0
|
||||
PKG_MIRROR_HASH:=6cfb176b475471462709b1e917276b7bade8ec58cff1ee6d5130caac80586b4e
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
@ -1,29 +0,0 @@
|
||||
From e59637cdf9d29e23639e7ca4530a4cc9d613ded0 Mon Sep 17 00:00:00 2001
|
||||
From: dwj0 <45187345+dwj0@users.noreply.github.com>
|
||||
Date: Thu, 14 Oct 2021 12:40:03 +0800
|
||||
Subject: [PATCH] Update sms_main.c
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
修正中文编码首字节大于0x80时显示错误
|
||||
---
|
||||
sms_main.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/sms_main.c b/sms_main.c
|
||||
index 2eb4f5d..f591f6a 100644
|
||||
--- a/sms_main.c
|
||||
+++ b/sms_main.c
|
||||
@@ -155,7 +155,7 @@ static void print_json_escape_char(char c1, char c2)
|
||||
else if(c2 < ' ') printf("\\u00%02x", c2);
|
||||
else printf("%c", c2);
|
||||
} else {
|
||||
- printf("\\u%02x%02x", c1, c2);
|
||||
+ printf("\\u%02x%02x", (unsigned char)c1, (unsigned char)c2);
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
70
sms-tool/patches/send_raw_pdu.patch
Normal file
70
sms-tool/patches/send_raw_pdu.patch
Normal file
@ -0,0 +1,70 @@
|
||||
diff --git a/sms_main.c b/sms_main.c
|
||||
index 5945f02..168b424 100644
|
||||
--- a/sms_main.c
|
||||
+++ b/sms_main.c
|
||||
@@ -193,7 +193,13 @@ int main(int argc, char* argv[])
|
||||
usage();
|
||||
if(strlen(argv[2]) > 160)
|
||||
fprintf(stderr,"sms message too long: '%s'\n", argv[2]);
|
||||
- }else if (!strcmp("delete",argv[0]))
|
||||
+ }
|
||||
+ else if (!strcmp("send_raw_pdu", argv[0]))
|
||||
+ {
|
||||
+ if(argc < 2)
|
||||
+ usage();
|
||||
+ }
|
||||
+ else if (!strcmp("delete",argv[0]))
|
||||
{
|
||||
if(argc < 2)
|
||||
usage();
|
||||
@@ -285,6 +291,50 @@ int main(int argc, char* argv[])
|
||||
fprintf(stderr,"reading port\n");
|
||||
}
|
||||
|
||||
+ if (!strcmp("send_raw_pdu", argv[0]))
|
||||
+ {
|
||||
+ int pdu_len = strlen(argv[1]);
|
||||
+ //append ctrl-z to pdustr
|
||||
+ char* pdu_str;
|
||||
+ pdu_str = malloc(pdu_len + 4);
|
||||
+ memcpy(pdu_str, argv[1], pdu_len);
|
||||
+ sprintf(pdu_str + pdu_len, "%c\r\n", 0x1A);
|
||||
+ const int pdu_len_except_smsc = 18;
|
||||
+ snprintf(cmdstr, sizeof(cmdstr), "AT+CMGS=%d\r\n", pdu_len_except_smsc);
|
||||
+ fputs("AT+CMGF=0\r\n", pf);
|
||||
+ while(fgets(buf, sizeof(buf), pfi)) {
|
||||
+ if(starts_with("OK", buf))
|
||||
+ break;
|
||||
+ }
|
||||
+ fputs(cmdstr, pf);
|
||||
+ printf("cmdstr: %s\n", cmdstr);
|
||||
+ sleep(1);
|
||||
+ fputs(pdu_str, pf);
|
||||
+ printf("pdu_str: %s\n", pdu_str);
|
||||
+ free(pdu_str);
|
||||
+ alarm(5);
|
||||
+ errno = 0;
|
||||
+
|
||||
+ while(fgets(buf, sizeof(buf), pfi))
|
||||
+ {
|
||||
+ if(starts_with("+CMGS:", buf))
|
||||
+ {
|
||||
+ printf("sms sent sucessfully: %s", buf + 7);
|
||||
+ return 0;
|
||||
+ } else if(starts_with("+CMS ERROR:", buf))
|
||||
+ {
|
||||
+ fprintf(stderr,"sms not sent, code: %s\n", buf + 11);
|
||||
+ } else if(starts_with("ERROR", buf))
|
||||
+ {
|
||||
+ fprintf(stderr,"sms not sent, command error\n");
|
||||
+ } else if(starts_with("OK", buf))
|
||||
+ {
|
||||
+ return 0;
|
||||
+ }
|
||||
+ }
|
||||
+ fprintf(stderr,"reading port\n");
|
||||
+ }
|
||||
+
|
||||
if (!strcmp("recv", argv[0]))
|
||||
{
|
||||
alarm(10);
|
Loading…
x
Reference in New Issue
Block a user