move sms-tool_q

This commit is contained in:
fujr 2024-10-09 13:57:42 +08:00
parent 54fc042d30
commit e5486f2e0f
2 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,28 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=sms-tool_q
PKG_RELEASE:=1
PKG_SOURCE_URL:=https://github.com/obsy/sms_tool
PKG_SOURCE_PROTO:=git
PKG_SOURCE_DATE:=2024-7-25
PKG_SOURCE_VERSION:=fce2b931c8d749c28b8281363950e963c98324eb
include $(INCLUDE_DIR)/package.mk
define Package/sms-tool_q
SECTION:=utils
CATEGORY:=Utilities
TITLE:=sms tool
URL:=https://github.com/obsy/sms_tool
endef
define Package/sms-tool_q/description
SMS Tool for 3G/4G modem
endef
define Package/sms-tool_q/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/sms_tool $(1)/usr/bin/sms_tool_q
endef
$(eval $(call BuildPackage,sms-tool_q))

View File

@ -0,0 +1,65 @@
--- a/sms_main.c 2024-10-08 23:11:01.169908895 +0800
+++ b/sms_main.c 2024-10-08 23:10:52.929909691 +0800
@@ -200,7 +200,12 @@
{
if(argc < 2)
usage();
- }else if (!strcmp("recv", argv[0]))
+ }
+ else if (!strcmp("send_raw_pdu", argv[0])){
+ if(argc < 2)
+ usage();
+ }
+ else if (!strcmp("recv", argv[0]))
{
}else if (!strcmp("status", argv[0]))
{
@@ -288,6 +293,48 @@
fprintf(stderr,"reading port\n");
}
+ if (!strcmp("send_raw_pdu", argv[0]))
+ {
+ int pdu_len;
+ int pdu_len_except_smsc;
+ char pdustr[1024];
+
+ alarm(5);
+ pdu_len_except_smsc = strlen(argv[1]) / 2 - 1;
+ sprintf(pdustr, "%s%c\r\n", argv[1],0x1A);
+ sprintf(cmdstr, "AT+CMGS=%d\r\n", pdu_len_except_smsc);
+ //set to pdu mode
+ fputs("AT+CMGF=0\r\n", pf);
+ while(fgets(buf, sizeof(buf), pfi)) {
+ if(starts_with("OK", buf))
+ break;
+ }
+ fputs(cmdstr, pf);
+ sleep(1);
+ fputs(pdustr, pf);
+
+ 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);