Skip to content

Commit c0a9040

Browse files
test nradio
1 parent 3655065 commit c0a9040

File tree

17 files changed

+2783
-3
lines changed

17 files changed

+2783
-3
lines changed

.github/workflows/build_image_mt7981.yml

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,60 @@ jobs:
201201
name: luci-app-netdata-${{ matrix.arch }}-${{ matrix.version }}
202202
path: luci-app-netdata
203203

204+
build_5G:
205+
strategy:
206+
fail-fast: false
207+
matrix:
208+
version: [master, 23.05.3]
209+
arch: [mediatek-filogic]
210+
name: Build Argon for OpenWRT-${{ matrix.arch }}-${{ matrix.version }}
211+
runs-on: ubuntu-latest
212+
container:
213+
image: openwrt/sdk:${{ matrix.arch }}-${{ matrix.version }}
214+
options: --user root
215+
defaults:
216+
run:
217+
shell: bash
218+
steps:
219+
- uses: actions/checkout@v4
220+
- name: Run Make
221+
run: |
222+
export VOLUME_HOME=$(pwd)
223+
export BUILD_DIR="/builder"
224+
export BUILDER="buildbot"
225+
cd $BUILD_DIR
226+
apt-get update
227+
apt install sudo -y
228+
sudo -u $BUILDER mv $VOLUME_HOME/nradio/luci-app-zmodem package/luci-app-zmodem
229+
sudo -u $BUILDER mv $VOLUME_HOME/nradio/luci-app-sms-tool package/luci-app-sms-tool
230+
sudo -u $BUILDER mv $VOLUME_HOME/nradio/sendat package/sendat
231+
sudo -u $BUILDER mv $VOLUME_HOME/nradio/sms-tool package/sms-tool
232+
while ! sudo -u $BUILDER ./scripts/feeds update -a; do echo "Try again"; done
233+
while ! sudo -u $BUILDER ./scripts/feeds install -a; do echo "Try again"; done
234+
sudo -u $BUILDER make defconfig
235+
sudo -u $BUILDER make package/luci-app-zmodem/compile V=s -j1
236+
sudo -u $BUILDER make package/luci-app-sms-tool/compile V=s -j1
237+
sudo -u $BUILDER make package/sendat/compile V=s -j1
238+
sudo -u $BUILDER make package/sms-tool/compile V=s -j1
239+
mkdir -p $VOLUME_HOME/package_5g
240+
cp bin/packages/*/base/luci-i18n-sms-tool-zh-cn*.ipk $VOLUME_HOME/package_5g/
241+
cp bin/packages/*/base/luci-app-sms-tool*.ipk $VOLUME_HOME/package_5g/
242+
cp bin/packages/*/base/sms-tool*.ipk $VOLUME_HOME/package_5g/
243+
cp bin/packages/*/base/sendat*.ipk $VOLUME_HOME/package_5g/
244+
cp bin/packages/*/base/luci-app-zmodem*.ipk $VOLUME_HOME/package_5g/
245+
- uses: actions/upload-artifact@v3
246+
with:
247+
name: package_5g-${{ matrix.arch }}-${{ matrix.version }}
248+
path: package_5g
249+
204250
build_image:
205251
strategy:
206252
fail-fast: false
207253
matrix:
208-
version: [master, 22.03.6, 23.05.3]
254+
version: [master, 23.05.3]
209255
arch: [mediatek-filogic]
210256
if: ${{ always() }}
211-
needs: [build_passwall, build_theme_argon, build_luci_app_netdata, build_openclash]
257+
needs: [build_passwall, build_theme_argon, build_luci_app_netdata, build_openclash, build_5G]
212258
name: Build Image for OpenWRT-${{ matrix.arch }}-${{ matrix.version }}
213259
runs-on: ubuntu-latest
214260
# container:
@@ -243,6 +289,9 @@ jobs:
243289
- uses: actions/download-artifact@v3
244290
with:
245291
name: openclash-${{ matrix.arch }}-${{ matrix.version }}
292+
- uses: actions/download-artifact@v3
293+
with:
294+
name: package_5g-${{ matrix.arch }}-${{ matrix.version }}
246295
# - uses: actions/download-artifact@v3
247296
# with:
248297
# name: luci-app-netdata
@@ -267,7 +316,7 @@ jobs:
267316
268317
- name: Set profile
269318
run: |
270-
echo "profile=mediatek-filogic-nradio-c8-668" >> $GITHUB_ENV
319+
echo "profile=confiabits_mt7981" >> $GITHUB_ENV
271320
- name: Make Image
272321
run: |
273322
export VOLUME_HOME=${{ github.workspace }}

nradio/luci-app-sms-tool/.DS_Store

6 KB
Binary file not shown.

nradio/luci-app-sms-tool/LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

nradio/luci-app-sms-tool/Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Copyright 2020-2023 Rafał Wabik - IceG - From eko.one.pl forum
3+
# Licensed to the GNU General Public License v3.0.
4+
#
5+
6+
include $(TOPDIR)/rules.mk
7+
8+
PKG_NAME:=luci-app-sms-tool
9+
LUCI_TITLE:=LuCI Support for sms-tool
10+
LUCI_DESCRIPTION:=LuCI interface for the sms-tool. The user interface supports SMS/USSD Codes/AT Commands.
11+
LUCI_PKGARCH:=all
12+
LUCI_DEPENDS:=+sms-tool +kmod-usb-serial +kmod-usb-serial-option +comgt
13+
PKG_VERSION:=1.9.7
14+
15+
include $(TOPDIR)/feeds/luci/luci.mk
16+
17+
# call BuildPackage - OpenWrt buildroot signature
Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
-- Copyright 2020-2022 Rafa³ Wabik (IceG) - From eko.one.pl forum
2+
-- Licensed to the GNU General Public License v3.0.
3+
4+
5+
local util = require "luci.util"
6+
local fs = require "nixio.fs"
7+
local sys = require "luci.sys"
8+
local http = require "luci.http"
9+
local dispatcher = require "luci.dispatcher"
10+
local http = require "luci.http"
11+
local sys = require "luci.sys"
12+
local uci = require "luci.model.uci".cursor()
13+
14+
-- module("luci.controller.modem.sms", package.seeall)
15+
module("luci.controller.sms", package.seeall)
16+
-- I18N = require "luci.i18n"
17+
-- translate = I18N.translate
18+
function index()
19+
-- entry({"admin", "modem"}, firstchild(), "蜂窝", 30).dependent=false
20+
-- entry({"admin", "modem", "sms"}, alias("admin", "modem", "sms", "readsms"), translate("SMS Messages"), 10)
21+
-- entry({"admin", "modem", "sms", "readsms"},template("modem/readsms"),translate("Received Messages"), 10)
22+
-- entry({"admin", "modem", "sms", "sendsms"},template("modem/sendsms"),translate("Send Messages"), 20)
23+
entry({"admin", "modem", "readsms"},template("modem/readsms"),translate("Received Messages"), 20)
24+
entry({"admin", "modem", "sendsms"},template("modem/sendsms"),translate("Send Messages"), 30)
25+
-- entry({"admin", "modem", "sms", "ussd"},template("modem/ussd"),translate("USSD Codes"), 30)
26+
-- entry({"admin", "modem", "sms", "atcommands"},template("modem/atcommands"),translate("AT Commands"), 40)
27+
if nixio.fs.access("/etc/config/smsconfig") then
28+
entry({"admin", "modem", "smsconfig"}, cbi("smsconfig"),translate("Configuration"), 50)
29+
end
30+
-- entry({"admin", "modem", "smsconfig"},cbi("smsconfig"),translate("Configuration"), 50)
31+
entry({"admin", "modem", "delete_one"}, call("delete_sms", smsindex), nil).leaf = true
32+
entry({"admin", "modem", "delete_all"}, call("delete_all_sms"), nil).leaf = true
33+
-- entry({"admin", "modem", "sms", "run_ussd"}, call("ussd"), nil).leaf = true
34+
-- entry({"admin", "modem", "sms", "run_at"}, call("at"), nil).leaf = true
35+
entry({"admin", "modem", "run_sms"}, call("sms"), nil).leaf = true
36+
entry({"admin", "modem", "readsim"}, call("slots"), nil).leaf = true
37+
-- entry({"admin", "modem", "countsms"}, call("count_sms"), nil).leaf = true
38+
-- entry({"admin", "modem", "sms", "user_ussd"}, call("userussd"), nil).leaf = true
39+
-- entry({"admin", "modem", "sms", "user_atc"}, call("useratc"), nil).leaf = true
40+
-- entry({"admin", "modem", "sms", "user_phonebook"}, call("userphb"), nil).leaf = true
41+
end
42+
43+
44+
function delete_sms(smsindex)
45+
local devv = tostring(uci:get("sms_tool", "general", "readport"))
46+
local s = smsindex
47+
for d in s:gmatch("%d+") do
48+
os.execute("sms_tool -d " .. devv .. " delete " .. d .. "")
49+
end
50+
end
51+
52+
function delete_all_sms()
53+
local devv = tostring(uci:get("sms_tool", "general", "readport"))
54+
os.execute("sms_tool -d " .. devv .. " delete all")
55+
end
56+
57+
58+
function sms()
59+
local devv = tostring(uci:get("sms_tool", "general", "sendport"))
60+
local sms_code = http.formvalue("scode")
61+
62+
nr = (string.sub(sms_code, 1, 20))
63+
msgall = string.sub(sms_code, 21)
64+
msg = string.gsub(msgall, "\n", " ")
65+
nr = string.gsub(nr, "%s", "")
66+
if sms_code then
67+
-- local odpall = io.popen("sms_tool -d " .. devv .. " send " .. nr .." '".. msg .."'")
68+
local odpall = encodeToPDU(nr, msg)
69+
local odp = odpall:read("*a")
70+
odpall:close()
71+
http.write(tostring(odp))
72+
else
73+
http.write_json(http.formvalue())
74+
end
75+
76+
end
77+
78+
function encodeToPDU(phoneNumber, message)
79+
local smsc=""
80+
local function TONGen(input, isPhonenum)
81+
local TONBegin = "91"
82+
local orinInput = input
83+
if #input % 2 == 1 then
84+
input = input .. 'F'
85+
end
86+
-- 交换数位
87+
local transformed = {}
88+
for i = 1, #input, 2 do
89+
local firstChar = input:sub(i, i)
90+
local secondChar = input:sub(i + 1, i + 1)
91+
transformed[#transformed + 1] = secondChar
92+
transformed[#transformed + 1] = firstChar
93+
end
94+
local TONStr = TONBegin .. table.concat(transformed)
95+
local TONLength = 0
96+
if (isPhonenum == false) then
97+
TONLength = string.len(TONStr) / 2
98+
else
99+
TONLength = string.format("%02X", string.len(orinInput))
100+
end
101+
if (string.len(TONLength) < 2) then --当短信中心号码过短时,最开头需要补0
102+
TONLength = "0" .. TONLength
103+
end
104+
return TONLength .. TONStr
105+
end
106+
107+
local function splitMessage(msg,subLen)
108+
local segments = {}
109+
local len = string.len(msg)
110+
local i = 1
111+
while i <= len do
112+
local segment = msg:sub(i,i+subLen-1)
113+
segments[#segments + 1] = segment
114+
i = i + subLen
115+
end
116+
return segments
117+
end
118+
119+
local function generateRandomInt8()
120+
math.randomseed(os.time())
121+
local randomInt8 = math.random(0, 255)
122+
return randomInt8
123+
end
124+
125+
126+
local SCA=TONGen(smsc, false)
127+
local MTI0='1'
128+
local MTI1='0'
129+
local RD='0'
130+
local VPF0='0'
131+
local VPF1='0'
132+
local SR='0'
133+
local UDHI='0'
134+
local RP='0'
135+
local pdu
136+
local TPMR = "00" -- TP-MR 消息基准
137+
local phoneNumEncode = TONGen(phoneNumber, true) --DA
138+
local TPPID = "00" -- TP-PID
139+
local TPDCS = "08" -- TP-DCS
140+
local MSG = encodeToUCS2(message)
141+
local sendLimit=60*4 ---单条短信字符限制
142+
143+
if string.len(MSG) >= sendLimit then
144+
UDHI='1'
145+
end
146+
local PDUType = RP .. UDHI .. SR .. VPF1 .. VPF0 .. RD .. MTI1 .. MTI0 -- PDU-Type
147+
148+
local decimalValue = tonumber(PDUType, 2) -- 将二进制字符串转换为十进制数
149+
PDUType = string.format("%02X", decimalValue) -- 将十进制数转换为十六进制字符串
150+
if (string.len(smsc) == 0) then
151+
pdu = "00" .. PDUType .. TPMR .. phoneNumEncode
152+
else
153+
pdu = SCA .. PDUType .. TPMR .. phoneNumEncode
154+
end
155+
156+
local sendList={}
157+
if string.len(MSG) <= sendLimit then
158+
local MSGLen = string.format("%02X", string.len(MSG) / 2)
159+
local AllMsgLen = 7 + string.len(phoneNumEncode) / 2 + string.len(MSG) / 2 - 2
160+
pdu = AllMsgLen .. " " .. pdu .. TPPID .. TPDCS .. MSGLen .. MSG
161+
sendList[#sendList + 1]=pdu
162+
else
163+
local RefSeq=generateRandomInt8()
164+
local segments = splitMessage(MSG,sendLimit)
165+
for i, segment in ipairs(segments) do
166+
local UDHIHeader = string.format("05%02X%02X%02X%02X%02X", 0,3,RefSeq,#segments,i) -- 长短信的UDHI头 --05 00 03 85 03 02.
167+
local MSGLen = string.format("%02X", string.len(segment) / 2 + 6)
168+
segment=UDHIHeader .. segment
169+
local AllMsgLen = 7 + string.len(phoneNumEncode) / 2 + string.len(segment) / 2 - 2
170+
local currentPdu = AllMsgLen .. " " .. pdu .. TPPID .. TPDCS .. MSGLen .. segment
171+
sendList[#sendList + 1]=currentPdu
172+
end
173+
end
174+
local file = io.open("/tmp/sms.log", "a") -- 打开文件以追加内容
175+
if file then
176+
file:write(table.concat(sendList),"\n") -- 写入内容到文件,以空格分隔并在结尾加入换行符
177+
file:close() -- 关闭文件
178+
end
179+
180+
for i, segment in ipairs(sendList) do
181+
local odpall = io.popen("/usr/share/modem/mopdu " .. segment)
182+
os.execute("sleep " .. 2) --需要一点等待的时间
183+
184+
end
185+
return odpall
186+
187+
end
188+
189+
function encodeToUCS2(text)
190+
local ucs2 = {}
191+
local index = 1
192+
local length = string.len(text)
193+
194+
while index <= length do
195+
local byte1 = string.byte(text, index)
196+
197+
if byte1 < 128 then
198+
ucs2[#ucs2 + 1] = string.format("%04X", byte1)
199+
index = index + 1
200+
elseif byte1 >= 192 and byte1 < 224 then
201+
local byte2 = string.byte(text, index + 1)
202+
ucs2[#ucs2 + 1] = string.format("%04X", (byte1 - 192) * 64 + (byte2 - 128))
203+
index = index + 2
204+
elseif byte1 >= 224 then
205+
local byte2 = string.byte(text, index + 1)
206+
local byte3 = string.byte(text, index + 2)
207+
ucs2[#ucs2 + 1] = string.format("%04X", (byte1 - 224) * 4096 + (byte2 - 128) * 64 + (byte3 - 128))
208+
index = index + 3
209+
else
210+
return nil
211+
end
212+
end
213+
214+
return table.concat(ucs2)
215+
end
216+
217+
218+
function slots()
219+
local sim = { }
220+
local devv = tostring(uci:get("sms_tool", "general", "readport"))
221+
-- local led = tostring(uci:get("sms_tool", "general", "smsled"))
222+
-- local dsled = tostring(uci:get("sms_tool", "general", "ledtype"))
223+
-- local ln = tostring(uci:get("sms_tool", "general", "lednotify"))
224+
225+
local smsmem = tostring(uci:get("sms_tool", "general", "storage"))
226+
227+
local statusb = luci.util.exec("sms_tool -s" .. smsmem .. " -d ".. devv .. " status")
228+
local usex = string.sub (statusb, 23, 27)
229+
local max = statusb:match('[^: ]+$')
230+
sim["use"] = string.match(usex, '%d+')
231+
local smscount = string.match(usex, '%d+')
232+
-- if ln == "1" then
233+
-- luci.sys.call("echo " .. smscount .. " > /etc/config/sms_count")
234+
-- if dsled == "S" then
235+
-- luci.util.exec("/etc/init.d/led restart")
236+
-- end
237+
-- if dsled == "D" then
238+
-- luci.sys.call("echo 0 > '/sys/class/leds/" .. led .. "/brightness'")
239+
-- end
240+
-- end
241+
sim["all"] = string.match(max, '%d+')
242+
luci.http.prepare_content("application/json")
243+
luci.http.write_json(sim)
244+
end
245+

0 commit comments

Comments
 (0)