Perfect
@MaheshGulavani if you specify what you mean with āsend data directly to your serverā maybe it comes out there is a better solution.
Particleās publisher/subscriber system let you completely separate the hardware and software context, removing the need of a synchronized communication between the device and the backend. This has many many benefits. I call it a pull scheme (the backend pulls from the cloud the most recent data whenever itās needed). I call a push scheme what you seem to describe (the data is pushed by the device) and I would suggest to avoid it.
A solution for synchronous communication is using webhooks:
- An events occur in the device
- The particle pushes a predefined ālogā event in the cloud
- A webhook which sends the data to the backend is triggered
Same result but still a decoupled system, with no handling of synchronous communication with the device.
Hi Alain1405,
Sorry for the delayed reply. Thanks for your inputs.
What I was looking for was a direct data transfer from Electron to my Server without going to Particle Cloud.
@rickkas7, I was able to setup a server in my office with static IP and was able to communicate from Electron using it as a TCPclient.
When it is connected in this configuration and I am using tcpclient.write(byte) command, I see the speed is very very slow even though I am getting 3G here.
Thanks
Mahesh
Do not write a byte at a time, as you have found it will be unbelievably slow. Instead, build the data in a buffer and call the version of write that takes a buffer and a length.
https://docs.particle.io/reference/firmware/electron/#write--3
You should size the write appropriately for your data, but anything larger than 512 bytes will be broken up and sent in 512 byte chunks anyway.
Hello All.
I am new to the electron and I am faced with a similar problem. Using AUTOMATIC system mode, I am able to use the Electron as a TCP client and connect to my server directly. I understand however that in this mode, a connection is first made to the Particle cloud.
I would like to connect my electron to my server directly without passing through the cloud.
Can anyone point me to sample code that will be useful?
Thanks!
@mbyamukama, looking at documentation never hurts! Take a look here:
https://docs.particle.io/reference/firmware/photon/#system-modes
The TCP is in addition to the cloud connection. It wonāt get routed through the cloud.
Dear MaheshGulavani,
Would you be so kind to post some instructions how were you able to configure sending data from the Electron to the server directly? Iām trying to accomplish the exact same thing.
Thanks.