Hi,
while working on a B4R experiment to monitor the state of REED switches connected to a NodeMCU.
If the state changes, data is send to a B4J server and stored in a MongoDB which is accessed via Browser (via WebSockets with port; shown in jQuery datatable).
To send data from the B4R client to the B4J server, two options (or may be more) either using asyncstreams with the new B4RSerializer (server is listening server.listen) or WebSocket send event (server is running server.start).
It not clear which is the best way to use? Any advice appreciated.
' Taken from the B4RSerializer example.
' If using asyncstreams then two ports are required else the Browser clients can not connect
' Taken from ArduinoWebSockets Example
' One port required; data must be strings
while working on a B4R experiment to monitor the state of REED switches connected to a NodeMCU.
If the state changes, data is send to a B4J server and stored in a MongoDB which is accessed via Browser (via WebSockets with port; shown in jQuery datatable).
To send data from the B4R client to the B4J server, two options (or may be more) either using asyncstreams with the new B4RSerializer (server is listening server.listen) or WebSocket send event (server is running server.start).
It not clear which is the best way to use? Any advice appreciated.
' Taken from the B4RSerializer example.
' If using asyncstreams then two ports are required else the Browser clients can not connect
B4X:
astream.Write(ser.ConvertArrayToBytes(Array("STATECHANGE", "REED Switch 1", State)))
' Taken from ArduinoWebSockets Example
' One port required; data must be strings
B4X:
websocket.SendEventToServer("Switch_StateChanged", Array As String("flag", "statechange", "switch", "reed 1", "state", State))
Last edited: