SMS HTTP API Issue

Post Reply
kf7eel
Posts: 5
Joined: Tue Nov 05, 2019 8:42 pm

SMS HTTP API Issue

Post by kf7eel » Tue Nov 05, 2019 9:02 pm

First off, I love my OpenSpot! This has been one of the best purchases I have made.

I am trying to write a python script to interact with a raspberry pi via SMS. The OpenSpot has been the only thing even close to allowing this. I found a set of scripts in python for the OpenSpot, but they are out dated and don't implement JSON web tokens. I have resorted to modifying, borrowing, and creating code to accomplish my goal.

I am having an issue with sending SMS via HTTP API. I can send GET requests and view the JSON output of various cgi. I can see a received SMS message in hex just fine as well. I can send a POST request and reboot the modem just fine. When I send a POST request with the JSON example from the API documentation about SMS, I receive the same JSON like a GET request, but the modem doesn't send a message to the radio. It returns HTTP 200, so I know its receiving them at least. Any thoughts or ideas? I have been using cUrl to send requests.

Thanks,
KF7EEL

User avatar
HA2NON
SharkRF team
SharkRF team
Posts: 4417
Joined: Fri Mar 25, 2016 3:33 pm
Contact:

Re: SMS HTTP API Issue

Post by HA2NON » Tue Nov 05, 2019 9:29 pm

Is the returned body empty? Please post the curl command line you use to send the message.
Norbert "Nonoo" Varga, HA2NON
SharkRF Team

kf7eel
Posts: 5
Joined: Tue Nov 05, 2019 8:42 pm

Re: SMS HTTP API Issue

Post by kf7eel » Wed Nov 06, 2019 12:18 am

Thanks for getting back to me so quickly.

I run the following:

Code: Select all

curl -i -X POST -H "Content-Type: application/json" \
 -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkNmFjODg1MiJ9.osaFi2v80NDZZwNAc3TZIEAkvi24EIO4O6Ira1C1Hc4" \
 -d '{ \
  "send_dstid": 3153591, \
  "send_calltype": 0, \
  "send_srcid": 9998, \
  "send_format": 2, \
  "send_tdma_channel": 0, \
  "send_to_modem": 1, \
  "send_msg": "0042004500450052" \
 }' \
http://10.10.10.132/status-dmrsms.cgi
curl outputs:

Code: Select all

HTTP/1.1 200 OK
Connection: close
Server: SharkRF HTTP server
Content-Type: application/json
Cache-Control: no-cache
Content-Length: 220
Access-Control-Allow-Headers: Authorization, Origin, X-Requested-With, Content-Type, Accept
Access-Control-Allow-Origin: *
and returns:

Code: Select all

{"default_srcid":9998,"intercept_net":0,"send_ongoing":0,"send_success":0,"send_fail":0,"rx_msg_valid":0,"rx_msg_srcid":3153591,"rx_msg_dstid":9998,"rx_msg_calltype":0,"rx_msg_format":2,"rx_msg_from_modem":1,"rx_msg":""}
The modem does not indicate that anything was sent over RF to radio, the transmit light does not come on. This is an OpenSpot 1, I just realized that I put this in the wrong part of the forum. Appologies for that.

Thanks.

User avatar
HA2NON
SharkRF team
SharkRF team
Posts: 4417
Joined: Fri Mar 25, 2016 3:33 pm
Contact:

Re: SMS HTTP API Issue

Post by HA2NON » Wed Nov 06, 2019 8:28 am

Make sure the modem mode is set to DMR, and monitor what's happening on the USB serial console of the openSPOT. Also the easiest way to grab proper API message format is to look at your browser's developer console to find out what the browser is exactly sending to the device. Under Chrome, press F12 and go to the Network tab of the developer console to see network activity.
Norbert "Nonoo" Varga, HA2NON
SharkRF Team

kf7eel
Posts: 5
Joined: Tue Nov 05, 2019 8:42 pm

Re: SMS HTTP API Issue

Post by kf7eel » Sat Nov 09, 2019 5:56 pm

Thank you so much for the tips! I got it to work! It looks like the JSON was not formatted or there were to many "options" being sent. I used the developer console to send a message, and used the JSON string from it in my curl request. It worked. I really appreciate the help.

kf7eel
Posts: 5
Joined: Tue Nov 05, 2019 8:42 pm

Re: SMS HTTP API Issue

Post by kf7eel » Sat Nov 09, 2019 6:03 pm

"only_save: 0" has to be sent with request.

Post Reply