I am not sure how to write this but I will try. Please bear with me as I am a newbie at JavaScript.
I have a 16byte (69C7E98730B2472CB8B5DE17A703C3F0) value that I need to write to BLE unit(clients unit).
I connect to the BLE unit , read the service and get the 16byte value , which I need to write back to the same service. I am not sure how to write the value back. I have tried the following and it does not seem to work and the crappy part is that the unit has no feedback to tell me.
I do know that I am reading the value right, so that's at least a starting point. Here is an example of my code. I would really appreciated it if anyone has some insight into this.
Code: Select all
$scope.writePassword = function(device, resultCode){
  data=new Uint8Array(resultCode.length);
  for(var i=0,j=resultCode.length;i<j;++i){
     data[i]=resultCode.charCodeAt(i);
  }
  device.writeCharacteristic(
        '69C7E987-30B2-472C-B8B5-DE17A703C3F0',
        data.buffer,
        function(data){
            console.log("TAG writeCharacteristic is ok");
            evothings.easyble.closeConnectedDevices(device);
            $scope.scanForUnits();
        },
        function(error){
            console.log('TAG Error: writeCharacteristic failed ' + error);
        });
};
Thank you in advance
Robby