rwblinn Well-Known Member Licensed User Longtime User Oct 31, 2016 #1 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 Code: Copy astream.Write(ser.ConvertArrayToBytes(Array("STATECHANGE", "REED Switch 1", State))) ' Taken from ArduinoWebSockets Example ' One port required; data must be strings Code: Copy websocket.SendEventToServer("Switch_StateChanged", Array As String("flag", "statechange", "switch", "reed 1", "state", State)) Last edited: Oct 31, 2016
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 Code: Copy astream.Write(ser.ConvertArrayToBytes(Array("STATECHANGE", "REED Switch 1", State))) ' Taken from ArduinoWebSockets Example ' One port required; data must be strings Code: Copy websocket.SendEventToServer("Switch_StateChanged", Array As String("flag", "statechange", "switch", "reed 1", "state", State))
rwblinn Well-Known Member Licensed User Longtime User Oct 31, 2016 #2 SOLVED by using SendEventToServer. Will share soon the experiment - but here a screenshot of the working solution. Attachments upload_2016-10-31_15-39-23.png 327.1 KB · Views: 761 Upvote 0
SOLVED by using SendEventToServer. Will share soon the experiment - but here a screenshot of the working solution.