I am trying to connect my custom board (set as Generic Board in the app) to the Blynk server. I am using NetX from Express Logic to send and receive TCP packets using the Blynk HTTP API on port 8080. I am able to connect to the Blynk server, send a packet and receive a 200 OK response. However, the Blynk app reports that my Generic Board is not in the network.
This is what I am sending (auth key fuzzed).
PUT /xxxx8cb426664864a3c656fb834axxxx/pin/V0 HTTP/1.1\r\nHost: blynk-cloud.com\r\nContent-Type: application/json\r\nContent-Length: 5\r\nConnection: close\r\n\r\n[“0”]
I send a message every second. After a few attempts (less than 10) the connection drops and I cannot connect again - maybe Blynk server is refusing my connection? The Blynk server IP I am connecting to is 46.101.143.225.
Any advice on where I am going wrong would be appreciated - I feel like I am so close to getting it working! Do I need to send any other data like a heartbeat or is simply sending periodic data updates enough?
Hello. That’s correct. HTTP API is stateless. Every request is independent from others and there is no way to find out is that hardware making requests or not. This “not in the network” indicates your board doesn’t have keep-alive tcp/ip/ssl connection to server. That’s it.
HTTP API was designed mostly for 3-d parties services and integration with non-compatible platforms. It is not supposed to be used like in your example.
So, it looks like my approach is wrong to try and use the HTTP API in this way. What do you recommend for the following situation? I have custom hardware running an RTOS and a TCP/IP stack without SSL support. I have HTTP server and client applications available to me. I am able to send and receive UDP and TCP packets.
Any advice would be gratefully received. I would really like to get Blynk up and running on this platform as a demonstrator for our customers and engineers.
HTTP is fine if it fits your needs. However some issues like “not in the network” will not be resolved. Also HTTP is limited in comparison to keep-alive connections. We usually recommend to implement missing part for you hardware. It shouldn’t be hard.
Or you can request support of that particular board from Blynk. However this is not free .