Is there any library to manage TCP connection on send messsage and received on Android - tcp

I am trying to make connection between smart watch to machine
Is there any good library to send and receive message for an Android and to make things easier? Phone must work as a client which can send and receive data from server.

Related

ESP-NOW with HTTPClient Request Returning Status Code -1

I'm building a project where I use 2 ESP8266 and 1 ESP32 devices, where I collect data with sensors on ESP8266's and send those gathered data to ESP32. Then, this ESP32 device sends an HTTP request (w/ HTTPClient) to my NodeJS Web Server, with the data received, which will eventually be processed there and saved to the database.
I'm having a problem though; when I use some mock data, and use only ESP32 without ESP-NOW and any other connection with other devices, I get status code 200, which indicates that my HTTP Request is sent succesfully. And when I use ESP-NOW to establish conenction between ESP devices, and not send any HTTP Request, I can successfully send and receive data.
However, when I use ESP-NOW to send and receive data, and send the data using HTTPClient request to my Web server on ESP32, I get status code -1 (refused connection). I couldn't find any other issues regarding this topic, so I figured I might ask for some help.
I have also used painlessmesh library to send/receive data between ESP devices, but that gave me the same exact issue. I'm using Wifi mode STA on my ESP32 device, which I connect it to my router to connect to the internet.
Thanks in advance for any help and support.
You cannot use ESP-NOW and WiFi in parallel at the same time; it's either-or. Exception: if you use the same channel for both (may not be possible)!
Option 1
You can alternate between the two protocols. So, as soon as the ESP-NOW transmissions from node 1 has completed (data fully received) you turn off ESP-NOW, connect to WiFi, publish via MQTT and then reverse. Needless to say that while your ESP32 is on WiFi you cannot receive data via ESP-NOW from either node 1 or node 2.
Option 2
Use some sort of gateway between ESP-NOW and WiFi. This product for example contains two ESP32 (connected over UART), one for ESP-NOW, one for WiFi: https://thingpulse.com/product/espgateway/. Disclaimer: I am a ThingPulse co-founder.
It is possible to run a web server and esp_now in the same esp32. Check my code here https://github.com/Servayejc/esp_now_web_server for the server
https://github.com/Servayejc/esp_now_web_server for the sender
This code make also automatic pairing of the nodes of esp_now.
This code is based on randomnerdtutorial…

Send message from website to SIM900 without SIM900 HTTP REQUEST

At the moment I'm working with the Arduino and SIM900, well, I could say I'm intermediate with the SIM, I could accomplish sending data to my website and receiving data from another phone. But now I would need that when I press a toggle button on my website it will send a message to the SIM900, for example, If I check the button it will send 1 if uncheck it, it will send 0. The problem is, I don't know how to start, I already searched up how to send data to the SIM900, But what I always get is the SIM making a request to the server, I would need the server to send the message whenever it is pressed, without the need of the SIM to keep making requests. Will I need an API for this? Please Help
Your phone (client) is behind a NAT. To reach it, you should read about NAT Traversal tactics, which will enable you to push a message to a client.
You can achieve that with Socket.IO or MQTT.
Your server will have a piece of code that the client should connect to when it's up, and the server will maintain the connection alive so that the server can push messages over this connection.

update device with settings from cloud

I have a device which has a settings on it.
The device is uploading data to the cloud.
In the cloud I have settings of the device that I want to do a smart way to update the device settings, but still leave the device the master and stateless. I mean that every request shall come from the device towards the cloud and NACK/ACK will come back to the device.
Currently what we do is to put a command in the database to send to the device according to its serial number. when the device pings to the server, it gets the message with the update. But I do not want to wait for the ping of the BSS. How can I notify the device that a message is waiting for it ?
How do Apple does it with icloud settings to the devices ?
Thanks
Look at the MQTT protocol. This is being promoted by Amazon for IOT devices, and a broker (message router) is available from Amazon. The protocol uses a publish and subscriber model. The devices subscribe to their "topic" something like yourcompany/todevice/serialnumber, and when the server publishes to the same topic, the MQTT broker delivers the message. the messages normally use JSON protocol.

Bluetooth: How to read messages from "Message Notification Service" (MNS) from MAP? QT

I am writing a QT 5 application on my laptop (Debian 8) where i want to be notified if a new SMS is available on my phone (OnePlus One, Android 5.1).
I managed to register the MAP service and read SMS manually. For this i created a socket. When there is new data available the readyRead() signal should be called. This works fine for getting SMS manually. Over the same socket i register the Message Notification Service.
The problem i have is, that the readyRead() signal is never emitted when a new message arraives. To monitor the data flow i use wireshark. Wireshark shows the event. So the smartphone sends the event to laptop, but not to socket which starts the connection request?
The information for registration i got from the (MAP) specification here: https://www.bluetooth.org/docman/handlers/DownloadDoc.ashx?doc_id=409110
My idea was that smartphone and laptop create a new socket, but not sure. And even when, i have no idea how to access this socket with QT.
Can anybody help? Thank you.
Over the same socket i register the Message Notification Service.
MAS and MNS should be two RFCOMM links, i.e. you may have two sockets, one for MAS client and the other one for MNS server.
You may refer the figure 6.3 at MAP spec 1.1 section 6.4.2.

Access COMPORT 1 through three different applications

I have an SMS Appliaction, which receives the messages through GPS Modem and revert back through GPS Modem. The Modem is using COM1.
Now, i need two more appliactions which can send messages through the same GPS Modem. I tried making a webservice which can access the COM1 to send data, but when i try to connect through webService, it throw an error saying, 'COM1 is already occupied, Access denied.'.
Can anybody help me to connect through the modem in above scenario.
Khushi
You have to make sure only 1 connection is made.
Easiest (and most low-tech, but probably most flexible) is having a script checking a directory for files regularly and sending the messages in the file to the modem. The webservice then just writes a file for every SMS it received. (this can be trivially extended to accept emails, web requests, etc, ...)
A bit more sophistacated is to start a thread to do the communication and push the messages on a FIFO like datastructure provided by your favorite programming platform. A BlockinQueue would be perfect. The thread reads the messages from the queue and sends them to the GSM modem.
If you want to have confirmation the SMS is sent (which in my experience does not mean anything and certainly not that the recipient actually received it) you'll need to find a way to return feedback to the caller. This can be as simple a setting a boolean flag in the message to sending another message or performing a callback. But I would not bother. I had situations where 30% of messages dissapeared even when we had confirmation of the message central.

Resources