开发者

How can I send an SMS via AT command with Zoom 7.2m Tri-Band USB Modem?

开发者 https://www.devze.com 2023-02-06 10:57 出处:网络
I am trying to make a simple python 2.6 application on OSX 10.6.6 that can send and receive SMS on my Zoom 7.2m (3g) USB Modem.

I am trying to make a simple python 2.6 application on OSX 10.6.6 that can send and receive SMS on my Zoom 7.2m (3g) USB Modem.

On initially plugging into the USB modem, no TTY or CU sessions seem to be created. I have to run the modem software to initiate the following sessions;

cu.LJADeviceInterface2621 cu.LJADiagConnector2620 cu.LJAMobileConnector2622 tty.LJADeviceInterface2621 tty.LJADiagConnector2620 tty.LJAMobileConnector2622

After much "fun", it seems the only s开发者_JAVA技巧ession I can read and write to is "cu.LJADeviceInterface2621". On attempting to connect to the tty instance of this, I get an error -

serial.serialutil.SerialException: could not open port /dev/tty.LJADeviceInterface2621: [Errno 16] Resource busy: '/dev/tty.LJADeviceInterface2621'

Thats fine though - I at least have something to work with, the cu equivalent.

My script is as follows;

            ser = serial.Serial("/dev/cu.LJADeviceInterface2621", 9600, timeout=1)

            print "Setting DTR..."
            ser.setDTR(True)

            sleep(3)
            print "Turning off DTR..."
            ser.setDTR(False)
            searching = True

            ser.setDTR(True)
            while searching:
                    print "Write instruction..."
                    txt=raw_input()
                    if txt.find("ZZ")>-1:
                            txt=txt.replace("ZZ",chr(13))
                    ser.write(txt)
                    
            ser.close()

Now, I also have another script that is monitoring the messages on "cu.LJADeviceInterface2621". That script is as follows;

            ser = serial.Serial("/dev/cu.LJADeviceInterface2621", 9600, timeout=1)

            print "Attempting search."
            while True:
                    line = ser.readline()
                    print ">", line

With these scripts both running, in the WRITE code, I enter the following lines;

(Note: ZZ input is replaced for Ctrl-Z via the write script above - chr(13))

AT+CMGF=1ZZ [press enter to commit write]

OK

AT+CMGW="+447725123123"\r\n [press enter to commit write]

ERROR

I should be writing the text of the message, followed by Ctrl-Z (chr(13) but I get an immediate error.

The USB modem has a valid sim, with credit, it has signal, I can send a text from the Zoom Modem Software (this however only works in with PDU mode - but the modem does support text mode, as per the AT+CMGF=? command) and receive messages.

Any ideas?

Happy to provide more information where needed, thanks Stu


Also remember that there are many projects out there that do the task for you (pysms is one of them)


Well, I never use that modem but I suppose it uses standard GSM AT commands, and AT+CMGW is wrong.

You should send: AT+CMGS="+111111111"\r\n SMS TEXT Ctrl-Z

And that should work

0

精彩评论

暂无评论...
验证码 换一张
取 消