BLE reading on TI C2650

Hi all,

I am starting playing with the BLE Texas Instrument C2650 SensorTag, and all does not work as i wish:)

I am using ionic-native BLE plugin, the device scanning is working like a charm :

I also can connect to my sensor and retrieve the list of the services and characteristics :

But i have some problems to read some characteristics. Here is my reading function :

onReadCharacteristic(deviceID, service, characteristic){

    this.ble.read(deviceID,service,characteristic).then(
        function(buffer){
            var databuffer = new Uint8Array(buffer);
            alert("buffer " + String.fromCharCode.apply(null,databuffer));
        }
    )}

It works well when i tryc to read the Device Information service 0x180A, the buffer return me the good informations (device name, manufacturer name, device number etc…).

But when i try to read the Battery Service 0x180F (characteristic 0x2A19) for example, the buffer return me a strange thing like “[” :

And for other services the result can be nothing or really strange results like below :

I searched a lot but i only found topics which deals with the scan or connection with device but not about reading characteristics…

Anyone have an idea ?

1 Like

Can you show a screenshot of how this looks?
I have problem connecting your code to the screenshots you posted…

battery level is a number (0-100) not a string, instead of

String.fromCharCode.apply(null,databuffer)
try
databuffer[0]

2 Likes

Yes of course :

1 Like

Yes that’s it ! thanks a lot :wink:

1 Like

Have you ever try to read IR Temperature on Ti SensorTag ?

I am trying to read the IR temperature object, first i write “01” in 0xAA02 characteristic config like mentionned in the documentation

var value = "01";
this.ble.write("F000AA00-0451-4000-B000-000000000000","F000AA02-0451-4000-B000-000000000000",value).then(
  function(res){
     alert("Ecriture : " + JSON.stringify(res));
  }
);

But when i read the temperature object i always get 00 00 00 00. And when i read the config parameter i have “211” instead of “01”. I also tried the following values :

 var value = "0x01";
 var value = 1;

 var value = new Uint8Array(1);
 value[0] = 0x01

But the characteristic config still return “211”

Do you have an idea ?

Ok, i found the problem ! To correctly write 0x01 in the characteristic we have to use value.buffer

  var value = new Uint8Array(1);
  value[0] = 0x01;
  this.onWriteCharacteristic("F000AA00-0451-4000-B000-000000000000","F000AA02-0451-4000-B000-000000000000",value.buffer);