Program to send data to xively using arduino & 3G + GPS shield cooking hacks

Hey everybody,

I'm actually working with the 3G + GPS shield from cooking hacks to upload data to xively cloud service. I saw the code of an older topic and it works to send data. But the problem is when it executes "sendATcommand(message_TCP, "Send OK", 20000);" in the "void send_data()" (line 97 in my code below).

After the delay it restarts from the beginning of the code and of course the socket and the network are not closed therefore I can't open it again. I think the problem come from the method "int8_t sendATcommand(char* ATcommand, char* expected_answer1, unsigned int timeout)" but I don't really understand why given that it works before.

Here the link of my code: http://codepad.org/roN2nxaU

Here you can see my serial monitor: Starting...


************************* SETUP ***********************


Turn on the module AT AT AT AT Module ON

Sets the PIN code AT+CPIN=0000 PIN code sets

Network registration AT+CREG? AT+CREG? Authentification to the network AT+CGSOCKCONT=1,"mmsbouygtel.com" AT+CSOCKAUTH=1,1,"","" Success authentification Success network registration


********************* SETUP : DONE ********************


AT+NETOPEN="TCP",8081 Network opened AT+TCPCONNECT="api.xively.com",8081 Socket opened AT+TCPWRITE=273 {"method": "put","resource": "/feeds/1819176350/","params": {},"headers": {"X-ApiKey": "aLWKMwlAcdlPK9TrLytC1sKrZxWguK2sl0dwHybMFrFTGhvl"},"body": {"version": "1.0.0","datastreams": [{"id": "Distance","current_value": "28"},{"id": "Coordinates","current_value": "2525"}]}}

Starting...


************************* SETUP ***********************


Turn on the module AT Module ON

Sets the PIN code AT+CPIN=0000 PIN code sets

Network registration AT+CREG? AT+CREG? Authentification to the network AT+CGSOCKCONT=1,"mmsbouygtel.com" AT+CSOCKAUTH=1,1,"","" Success authentification Success network registration


********************* SETUP : DONE ********************


AT+NETOPEN="TCP",8081 Error opening the network AT+NETOPEN="TCP",8081 Error opening the network AT+NETOPEN="TCP",8081 Error opening the network AT+NETOPEN="TCP",8081 Error opening the network AT+NETOPEN="TCP",8081

Thanks for your help Regards Pierre

Here the link of my code

The forum provides a mechanism to post your code HERE if you want help HERE. Read the stickies at the top of the forum.

@PierBJX is currently enjoying a brief forum timeout for quadruple cross-posting. Hopefully, they'll use the time to read the guidelines on how to post code; they managed to find colour tags, it's amazing they couldn't find the code tags.