I’ve been working on a small Go program for my X3000 modem that connects directly to the SIM module’s serial port and communicates through AT commands. It looks for new messages in the incoming SMS directory and automatically sends a reply through the COM port if the message matches a specific regex pattern.
It works about half the time, but the other half it just locks up. I think the GL.iNet core packages are running into a race condition whenever both streams overlap. When that happens, everything starts to glitch, sometimes it fails completely, and sometimes it even takes down my internet connection.
Is there a cleaner or more reliable way to handle AT commands on the client side? Maybe some sort of queue I could send commands through instead of pushing them directly?
Rename it to /etc/forward.real and make sure that you call exec /etc/forward.real "$@" at the end of your script. You might need to wrap a shell script around your go app, I am not sure if you can run it directly.
/etc/forward will be used as soon as you enable forwarding an SMS inside the GL interface. So this script will always be notified about new SMS.
Hi again, it doesn’t seem to work completely. I can successfully send an SMS to my own phone number, however when using To: 4000 it gets sent as +4000, which is incorrect. The + forces it to be treated as an international number, so it will never reach the provider, as the provider expects the short code to be sent as just 4000.
This confirms the issue: the message is being encoded with TON 91 (international). For short codes like 4000, it should instead use TON 81 (unknown / national). In other words, it should be sent as something like: