BLE plugin

256 views
Skip to first unread message

Ulf Pambor

unread,
Aug 26, 2018, 4:31:45 AM8/26/18
to DroidScript
Folks,

I am rather new to droidscript and want to use it to monitor a BLE device. 

Few questions on the BLE plugin:

1) I want to use the sample to read the content of a characteristic of my device. I just changed the service ID and characteristic ID and tried to read my characteristic with the example code. 

I have two different chars to read: A byte array and a short number. For the short number I used the following code within the example:

function OnConnect()
{
  app.ShowPopup( "Connected!" );

   var svcId = "0000f00d-1212-efde-1523-785fef13d123";  // My Service-ID
  
   var charId = "0000dead-1212-efde-1523-785fef13d123"; // My Characteristic ID
  
   ble.WatchValue( svcId, charId, "short", OnValue );
}

function OnValue( svcId, charId, val )
{
  txt.Log( charId + " -> " + val );
}

I get successfully connected to my device but never see the content of the characteristic on screen. 

I have used Nordic nRFconnect app on my tablet to re-check. With this app I can read the characteristic without any problems...what is going wrong?


2) What do I have to do if I want to write a value into a characteristic that is marked writable?


3) Where can I find a description of all functions of the BLE plugin?


Thanks for your help.

Regards

Ulf

Dave

unread,
Aug 26, 2018, 9:07:21 AM8/26/18
to DroidScript
Try explicitly reading the value instead of waiting for a change using the ble.ReadValue() method, does that work?

Are you changing the value at the server end and triggering an update correctly?
(Watch value will only work if the value changes)

Here is a list of all the BLE plugin methods for your reference:-

this.GetVersion = function( num, txt )
this.StartScan = function()
this.StopScan = function()
this.Connect = function( address, options )
this.Disconnect = function()
this.IsConnected = function()


this.SendUart = function( msg, encoding )
this.SetUartMode = function( mode )
this.SetUartIds = function( svc,tx,rx )
this.SetSplitMode = function( mode,p1,p2 )
this.SetOnUartReceive = function( callback )
this.SetOnDevice = function( callback )
this.SetOnConnect = function( callback )
this.SetOnDisconnect = function( callback )
this.SetOnSelect = function( callback )


this.SetMtu = function( size )
this.WatchValue = function( svcId,charId,charType,callback )
this.UnWatchValue = function( svcId,charId )
this.ReadValue = function( svcId,charId,charType,callback )
this.WriteValue = function( svcId,charId,charType,val )





Reply all
Reply to author
Forward
0 new messages