Continuously Read(Subscribe) Data from BLE Device

Continuously Read(Subscribe) Data from BLE Device

  

Hey,

I am using the BLE Plugin to connect a SH-M08 BLE module with a phone to read analog values from an Arduino Nano V3. 

I created a client action reading the value on the click of a button, which works fine. However, I am struggling to find a way to automatically read the values sent by the Arduino without having to press a button. 

I would like the data to be read in the background at all times with no human activity needed.

How do I set that up in OutSystems 10?


Thanks in advance!  

Solution

Hi Torben,

In the OnReady of the Screen, you can place a JavaScript Statement (), with the following content:

$parameters.OutIntervalVar = window.setInterval(function(){

  $actions.YourScreenAction();

}, $parameters.InRefreshRate * 1000);

(OutIntervalVar is an output variable of the Statement, InRefreshRate an input variable, YourScreenAction the Screen Action that handles whatever you want).

In the OnDestroy() you must disable the interval again:

clearInterval($parameters.InIntervalVar);


Solution