How can I send an MMS via a GSM/GPRS modem connect

2019-06-05 18:45发布

问题:

I have a directory which contain say 50 image files (.jpg) each less than 300kb. This files should be attached as MMS and send from Linux computer using GSM/GPRS modem. I need to work out how to package a MMS and able to send it to a mobile phone or email from linux computer. Also please note that I want to be able to send the MMS message using my GSM/GPRS modem - NOT via clickatell or some other web service. I also do NOT want to be using a full blown MMSC gateway such as NowSMS (which is windows anyway) or MBuni. Please help me to find any Linux tool which can be worked through command line / any compile source code / any method which is easy to use.

Thanks in advance for your expertise

回答1:

Why do you want to do this? Its an overly complicated process and there is a reason there are MMSC gateways available. You only use the GPRS part to establish a PPP connection, then the rest of the stuff happens over IP.

I strongly suggest you use a gateway for this, and don't do this manually.

In order to establish the PPP connection:

  1. AT+CGDCONT? This should respond with the context you are on. This means you are ready to attach/connect.
  2. AT+CGATT=1 (attach your modem)
  3. AT+CGDATA=? (check what is the data mode)
  4. AT+CGACT=1 (activate your connection)

Now you are on PPP, and then you talk over the modem using whatever your provider is using. It could be anything from direct HTTP to MMSE protocol.

For example, here is a complete transcript over HTTP. First, we need to setup the modem and connection information. All these commands should get a response of OK from the modem.

AT+CMMSINIT # Initialize the MMS method
AT+CMMSCURL="some.url.com" # the MMS center URL
AT+CMMSCID=1 # Set bearer
AT+CMMSPROTO="1.1.1.1",8080 # MMS Proxy information
AT+SAPBR=3,1,"Contype","GPRS" # How you are sending
AT+SAPBR=3,1,"APN","foobar" # Set the APN
AT+SAPBR=1,1 # Activate the bearer context

Next, we prepare the message:

> AT+CMMSEDIT=1  # Enter edit mode
OK
> AT+CMMSDOWN="PIC",54321,30000 # Download a pic that is 54321 bytes
                                # and set the latency
                                # for the download to 30000 ms
CONNECT                         # This means, ready to receive data
                                # so send your file
OK                              # Data received
> AT+CMMSRECP="123456789"       # Set the recipient
OK
> AT+CMMSVIEW                   # View your message
(your message)
OK
> AT+CMMSSEND                   # Send the message
OK                              # Message sent
> AT+CMMSEDIT=0                 # Exit edit mode, and clear the buffer
OK

This of course, is specific to the modem that I was using. Your results may vary. I can tell you that this is an exercise in futility. Go with a proper provider if you want to actually send MMS messages.



回答2:

Hi one way of doing this is to encode your SMIL message using python-messaging and use gammu sendsms MMSINDICATOR to notify the transaction.

Gammu can be downloaded at http://wammu.eu/.

Using this tool you can send the sms indicating message notifying the recipient where to fetch the MMS.

Using python-messaging you can encode you're mms message. Look at this guide for details on message encoding and publishing: https://github.com/pmarti/python-messaging/blob/master/doc/tutorial/mms.rst

Make sure to run the python-messaging commands connected using the GPRS of the modem being on the APN associated with the MMSC of youre operator.

Download at: https://github.com/pmarti/python-messaging

This process gives you good control of you're MMS publishing details, but its not easy.