Hi Dave,
I tested the FILTER ID idea you suggested as below, but it didn’t solve the
AT Commands that are occurring as a followup SMS after the intended SMS.
I am happy to test any other ideas you feel might be worth trying.
I tested using your ‘Test-SMS.py’ as F7 shortcut in ‘sms-to-shell.py’
I got ;
(1st SMS)
This is a test sms
(then 2nd SMS)
+CMGS: 96
OK
OK
I am puzzled as to what is making it send the AT response SMS after the initial SMS.
I also tested waveshare’s 7600X HAT ‘demo code’ SMS.py
and got three separate SMS of AT Commands telling me what it was doing.
So same problem but with more verbose AT response.
I feel a little context might be useful, just so you have an overview of how I am using
‘sms-to-shell’
I am using the ‘sms-to-shell’ script to monitor for my incoming sms commands.
I am adding my own commands to the ‘keyboard shortcuts’ built into your code.
For example: I send ‘F1’ as an sms to the modem.
‘sms-to shell’ gets the sms and executes the command for F1
This runs a python script that gets the temperature from a sensor and sends it back to me as an SMS; “Current coolroom temp is 4.5C”
I also have other commands that send a CSV spreadsheet temperature log via email and other things like that.
Interesting the email script sends me an SMS with:
‘Email with CSV sent
OK’
I gave it no instruction in my code to SMS anything to me.
The end part of my code is:
print (‘Email with CSV sent’)
so it is apparently getting the response from there
For your reference;
[Below is my placement of the test code within your program - so you can see if I put it in the correct place.]
I put this at the top with the Script parameters
FILTER_ID = “Z1Z”
####then included the ‘Z1Z’ in the SMS message that went to the modem for sending.
Excerpt from ‘sms-to-shell.py’ to show you where I put the code for testing.
Between these two pars.
…
Print debug information
print("Received SMS:")
print("Phone number:", phone_number)
print("Command:", content)
# Log the phone number, time, date, and command received
logger.info('D: %s T: %s Ph: %s Command: %s',
time.strftime('%Y-%m-%d'), time.strftime('%H:%M:%S'), phone_number, content)
# Skip processing if the message contains the filter identifier
if FILTER_ID in content:
logger.info("Message skipped due to identifier '%s' in content: %s", FILTER_ID, content)
return
# Check if the phone number is allowed
if phone_number not in ACL: # make ACL a black list by reversing line to "if phone_number in ACL:"
# Phone number not allowed, send rejection message
rejection_message = "Access denied"
send_sms_response(modem, phone_number, rejection_message)
logger.warning("D: %s T: %s UNAUTHORISED ACCESS ATTEMPT Ph: %s Command: %s",
time.strftime('%Y-%m-%d'), time.strftime('%H:%M:%S'), phone_number, content)
return
…
Any ideas welcome. Cheers Paul