4IceG / luci-app-sms-tool

Simple user interface to handle SMS / USSD / AT commands via sms_tool application. | OpenWrt =< 19.07
GNU General Public License v3.0
123 stars 38 forks source link

Empty list in "Received Messages" #16

Closed Nowaker closed 2 years ago

Nowaker commented 2 years ago

image

sms_tool sees the messages:

# sms_tool -d /dev/ttyUSB2 -s SM recv
MSG: 0
From: 7535
Date/Time: 03/22/22 18:23:23
AT&T Free Msg: Paperless Billing was requested to start for acct # ending in [SNIPPED]. If done in error, call 800-331-0500 or 611 from your wireless phone.

MSG: 1
From: 7535
Date/Time: 03/22/22 18:48:35
AT&T FREE MSG: AutoPay Enrollment Processed. Please submit payments until you see confirmation of your enrollment on the first page of your bill.

MSG: 2
From: 7535
Date/Time: 03/23/22 10:27:59
AT&T FREE MSG: AutoPay Enrollment Processed. Please submit payments until you see confirmation of your enrollment on the first page of your bill.

MSG: 3
From: 7535
Date/Time: 03/25/22 09:03:51
Reference number: 116
SMS segment 1 of 2
AT&T Free Msg: Your data use this month has reached 16.5GB. If you exceed 22GB before your next cycle on 04/21/2022, you can still use unlimited data ho

MSG: 4
From: 7535
Date/Time: 03/25/22 09:03:51
Reference number: 116
SMS segment 2 of 2
wever your speeds may be reduced in areas with network congestion. Wi-Fi helps avoid reduced speeds. Visit att.com/datainfo for more info.

luci-app-sms-tool config:

# uci export sms_tool
package sms_tool

config sms_tool 'general'
        option ledtimeon '1'
        option ledtimeoff '5'
        option lednotify '0'
        option checktime '10'
        option information '1'
        option ussd '0'
        option pdu '0'
        option storage 'SM'
        option prestart '6'
        option ledtype 'D'
        option readport '/dev/ttyUSB2'
        option sendport '/dev/ttyUSB2'
        option ussdport '/dev/ttyUSB2'
        option atport '/dev/ttyUSB2'
        option mergesms '1'
        option pnumber '1'
        option prefix '1'
Nowaker commented 2 years ago

It appears to be an in-browser JavaScript error.

Uncaught SyntaxError: Unexpected token ':'

image

Seems related to the SIM card capacity logic. sms_tool is doing fine:

# sms_tool -d /dev/ttyUSB2 status
Storage type: SM, used: 5, total: 5

XHR request to readsim also works fine, regardless of whether I configure SIM card or memory storage area - but only when done independently of the UI:

% curl 'http://XXX/cgi-bin/luci/admin/modem/sms/readsim?XXX' \
  -H 'Connection: keep-alive' \
  -H 'User-Agent: XXX' \
  -H 'DNT: 1' \
  -H 'Accept: */*' \
  -H 'Referer: http://XXX/cgi-bin/luci/admin/modem/sms/readsms' \
  -H 'Accept-Language: en-US,en;q=0.9,pl;q=0.8' \
  -H 'Cookie: sysauth=XXX' \
  --compressed \
  --insecure
{"all":"255","use":"0"}

% curl 'http://192.168.10.1/cgi-bin/luci/admin/modem/sms/readsim?XXX' \
  -H 'Connection: keep-alive' \
  -H 'User-Agent: XXX' \
  -H 'DNT: 1' \
  -H 'Accept: */*' \
  -H 'Referer: http://XXX/cgi-bin/luci/admin/modem/sms/readsms' \
  -H 'Accept-Language: en-US,en;q=0.9,pl;q=0.8' \
  -H 'Cookie: sysauth=XXX' \
  --compressed \
  --insecure
{"all":"5","use":"5"}

It's worth noting that when memory storage is set up, the UI doesn't throw any in-browser exceptions, and the capacity is correctly shown as 0/255.

image

Nowaker commented 2 years ago

Okay, found the bug:

    local statusb = luci.util.exec("sms_tool -s" .. smsmem .. " -d ".. devv .. " status")
    local all = string.sub (statusb, -4)

The code assumes the number has 3 digits. Well. Mine has one. Smarter parsing of sms_tool status is needed.

Nowaker commented 2 years ago

Fix:

        local all = statusb:match('[^: ]+$')