0

Error 603 when using Sim7000 and AT Commands
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Error 603 when using Sim7000 and AT Commands

by krish2487 on Thu May 09, 2019 8:24 am

Hello,

I apologize in advance if this seems out of place or relevance. I am just trying to get started with adafruit.io for some datalogging.
Let me start off by saying I am just getting started out with adafruit.io and do not have much (if at all) knowledge or experience about the HTTP and REST and APIs and such.
I am fairly comfortable with electronics and microcontrollers. I am trying to use a STM32 processor with libopencm3 and SIM7000 to post some environmental data to adafruit.io.
I understand that it can be done by making a HTTP Post request. I am just trying to manually send AT commands to the SIM7000 using a USB UART converter to check my understanding is right and the data is successfully posted.

The feed is setup and I am able to manually post the data using curl

Code: Select all | TOGGLE FULL SIZE
curl -F 'value=33' -H "X-AIO-Key: *********************" https://io.adafruit.com/api/v2/krish2487/feeds/temp/data


This is what I have tried to do manually by sending AT commands to the module. I am trying to post the same data using HTTP POST request.

Code: Select all | TOGGLE FULL SIZE
AT+SAPBR=3,1,"Contype","GPRS"

OK
AT+SAPBR=3,1,"APN","TM"

OK
AT+SAPBR=1,1

OK
AT+SAPBR=2,1

+SAPBR: 1,1,"10.162.11.38"

OK
AT+HTTPINIT

OK
AT+HTTPPARA="CID",1

OK
AT+HTTPPARA="URL","https://io.adafruit.com/api/v2/krish2487/feeds/temp/data"

OK
AT+HTTPPARA="USERDATA","X-AIO-Key:*******************************"

OK
AT+HTTPPARA="CONTENT","Content-Length: 9"

OK
AT+HTTPPARA="CONTENT","Content-Type: application/json"

OK
AT+HTTPDATA=9,30000

DOWNLOAD

OK
AT+HTTPACTION=1

OK

+HTTPACTION: 1,603,0


I have entered "value=123" after the "DOWNLOAD" message from the sim7000. I keep getting the Error 603 which I understand is a DNS error. I read that it might be related to the APN. I have replicated the same steps with a hologram sim and a thingsmobile sim but the same issues persisted.

I suspect it is something I am doing wrong while constructing the body of the POST request. I will be extremely grateful if someone can point out what I am doing wrong.

I am aware that the Arduino FONA library can do the job, but I would like to learn how to do it myself since the final application is an STM32 processor with gnu arm toolchain and libopencm3.

Thanks in advance.

krish2487
 
Posts: 6
Joined: Thu Dec 21, 2017 1:59 pm

Re: Error 603 when using Sim7000 and AT Commands

by brubell on Thu May 09, 2019 9:05 am

Are you able to GET data from a page, like Google.com, with your module?

brubell
 
Posts: 732
Joined: Fri Jul 17, 2015 10:33 pm

Re: Error 603 when using Sim7000 and AT Commands

by krish2487 on Thu May 09, 2019 9:26 am

Yes I am able to get a response back from google.com

This is what is the output from the module when I execute a GET request for www.google.com


Code: Select all | TOGGLE FULL SIZE
AT+SAPBR=3,1,"Contype","GPRS"

OK
AT+SAPBR=3,1,"APN","TM"

OK
AT+SAPBR=1,1

OK
AT+SAPBR=2,1

+SAPBR: 1,1,"10.162.180.140"

OK
AT+HTTPINIT

OK
AT+HTTPPARA="URL","www.google.com"

OK
AT+HTTPPARA="CID",1

OK
AT+HTTPACTION=0

OK

+HTTPACTION: 0,200,11861



However when I try to execute the same for https://io.adafruit.com, I get the same error 603
This is the output when I try GET for io.adafruit.com

Code: Select all | TOGGLE FULL SIZE
AT+HTTPINIT

OK
AT+HTTPPARA="URL","https://io.adafruit.com"

OK
AT+HTTPPARA="CID",1

OK
AT+HTTPACTION=0

OK

+HTTPACTION: 0,603,0

krish2487
 
Posts: 6
Joined: Thu Dec 21, 2017 1:59 pm

Re: Error 603 when using Sim7000 and AT Commands

by krish2487 on Fri May 10, 2019 4:59 am

Ok.. after much experimenting with the different methods I found that I could post to the adafruit io using TCP methods.

This is what the logs looks like.

Code: Select all | TOGGLE FULL SIZE
AT+CGATT=1

OK
AT+CSTT="TM"

OK
AT+CGDCONT=1,"IP","TM"

OK
AT+CGACT=1,1

OK
AT+CIICR

OK
AT+CIFSR

10.162.30.221
AT+CIPSTART="TCP","io.adafruit.com",80

OK

CONNECT OK
AT+CIPSEND

> POST /api/v2/krish2487/feeds/temp/data HTTP/1.1
Host: io.adafruit.com
Accept: */*
X-AIO-Key: **************************
Content-Length: 8
Content-Type: application/x-www-form-urlencoded

value=66
.
SEND OK
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 10 May 2019 08:50:30 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
Referrer-Policy: strict-origin-when-cross-origin
X-AIO-Worker: io-rails-2
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: false
Access-Control-Request-Method: *
Access-Control-Allow-Methods: POST, PUT, DELETE, GET, OPTIONS, PATCH
Access-Control-Allow-Headers: DNT, Origin, X-Requested-With, X-AIO-Key, Content-Type, Accept, Authorization
Access-Control-Expose-Headers: X-Pagination-Limit, X-Pagination-Start, X-Pagination-End, X-Pagination-Count, X-Pagination-Total
Access-Control-Max-Age: 1728000
ETag: W/"4c06688b5073aaa353a1a00c2b832473"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: 29a2b4e2-df8d-4b57-b332-47f2d0f8bcc7
X-Runtime: 0.052030
X-AIO-Proxy: 2

e8
{"id":"0E594NVNWJ9J0SJR20G1FGHDXT","value":"66","feed_id":1004087,"feed_key":"temp","created_at":"2019-05-10T08:50:30Z","location":null,"lat":null,"lon":null,"ele":null,"created_epoch":1557478230,"expiration":"2019-06-09T08:50:30Z"}
0


The Port to be specified in the AT+CIPSTART is really confusing. The documentation mentions that ports 1883 and 8883 are used for MQTT.
Only port 80 works and 443/8443/1883/8883 do NOT work for the above mentioned method. When I tried the above steps with ports other than 80, it simply returns a SEND OK message and nothing else.

However, this is only one part of the problem. The fact that I am able to post using TCP means
1. I should also be able to post using the earlier HTTP Post method
2. There is something wrong with how my HTTP post method is being constructed.

I will be extremely grateful is someone more knowledgeable than me can help me learn. :-)

Thanks in advance.!!

krish2487
 
Posts: 6
Joined: Thu Dec 21, 2017 1:59 pm

Re: Error 603 when using Sim7000 and AT Commands

by brubell on Fri May 10, 2019 9:50 am

Glad you got it POST'ing. You may find some utility digging through Adafruit IO Arduino's FONA sub-class, it uses the same MQTT port as the documentation specifies. (https://github.com/adafruit/Adafruit_IO ... FONA.h#L36)

brubell
 
Posts: 732
Joined: Fri Jul 17, 2015 10:33 pm

Re: Error 603 when using Sim7000 and AT Commands

by krish2487 on Fri May 10, 2019 9:59 am

@brubell
Thank you. On a totally unrelated note, I just need a clarification.
If I have to post to multiple feeds, there is no straightforward way to do it in one POST request right.
I need to construct different requests for different feeds.
I know there is MQTT but as I said, this HTTP stuff is blackmagic to me. :-P

Is there is a beginner friendly (read web noobs friendly) write up on adafruit io and at commands for mqtt?

Say, I have a temperature, humidity and pressure sensor. I will need to construct three payloads to post them. Is there a way to post them in one message??

Thank you :-)

krish2487
 
Posts: 6
Joined: Thu Dec 21, 2017 1:59 pm

Please be positive and constructive with your questions and comments.