-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvsms.lua
More file actions
37 lines (31 loc) · 822 Bytes
/
Copy pathconvsms.lua
File metadata and controls
37 lines (31 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
-- converts the pointed sms from hex to ascii
local socket = require "socket"
local ip, port = "127.0.0.1", 23000
local server, err = socket.connect(ip,port)
if server == nil then
print (err)
else
server:send('AT+CPMS="ME"\r\n')
s, status, partial = server:receive()
s, status, partial = server:receive()
s, status, partial = server:receive()
s, status, partial = server:receive()
server:send('AT+CMGR='..arg[1]..'\r\n')
s, status, partial = server:receive()
s, status, partial = server:receive()
while true do
s, status, partial = server:receive()
if status == "closed" then
break
end
if s == "OK" then
break
end
for i=1, #s do
local c=s:sub(i,i+1)
if math.mod(i,2) == 1 then
io.write(string.char(tonumber(c, 16)))
end
end
end
end