Getting BLE 4.0 Floral Sensor data in ionic v1

Using this to scan the mi floral plant sensor

ble.startScan(
        [],
        function(device){
					$scope.spinner = false;
          if(device.name){
            DeviceFactory.addDevice({ 'id': device.id, 'name': device.name });
          }
        },
        function(err){
          alert('Scanning failed. Please try again.');
        }

got list of device

function connect(){
ble.connect(
$stateParams.device_id,
function(res){
$scope.response = JSON.stringify(res);
}
);
}

connected to device got response

{“characteristics”:[{“characteristic”:“2a00”,“service”:“1800”,“properties”:[“Read”]},{“characteristic”:“2a01”,“service”:“1800”,“properties”:[“Read”]},{“characteristic”:“2a02”,“service”:“1800”,“properties”:[“Read”,“Write”]},{“characteristic”:“2a04”,“service”:“1800”,“properties”:[“Read”]},{“descriptors”:[{“uuid”:“2902”}],“characteristic”:“2a05”,“service”:“1801”,“properties”:[“Read”,“Indicate”]},{“descriptors”:[{“uuid”:“2902”}],“characteristic”:“0001”,“service”:“fe95”,“properties”:[“Read”,“Write”,“Notify”]},{“characteristic”:“0002”,“service”:“fe95”,“properties”:[“Read”]},{“characteristic”:“0004”,“service”:“fe95”,“properties”:[“Read”,“Notify”]},{“characteristic”:“0007”,“service”:“fe95”,“properties”:[“Write”]},{“characteristic”:“0010”,“service”:“fe95”,“properties”:[“Write”]},{“characteristic”:“0013”,“service”:“fe95”,“properties”:[“Read”,“Write”]},{“characteristic”:“0014”,“service”:“fe95”,“properties”:[“Read”]},{“descriptors”:[{“uuid”:“2902”}],“characteristic”:“1001”,“service”:“fe95”,“properties”:[“Notify”]},{“characteristic”:“8082caa8-41a6-4021-91c6-56f9b954cc34”,“service”:“fef5”,“properties”:[“Read”,“Write”]},{“characteristic”:“724249f0-5ec3-4b5f-8804-42345af08651”,“service”:“fef5”,“properties”:[“Read”,“Write”]},{“characteristic”:“6c53db25-47a1-45fe-a022-7c92fb334fd4”,“service”:“fef5”,“properties”:[“Read”]},{“characteristic”:“9d84b9a3-000c-49d8-9183-855b673fda31”,“service”:“fef5”,“properties”:[“Read”,“Write”]},{“characteristic”:“457871e8-d516-4ca1-9116-57d0b17b9cb2”,“service”:“fef5”,“properties”:[“Read”,“WriteWithoutResponse”,“Write”]},{“descriptors”:[{“uuid”:“2902”}],“characteristic”:“5f78df94-798c-46f5-990a-b3eb6a065c88”,“service”:“fef5”,“properties”:[“Read”,“Notify”]},{“characteristic”:“1a00”,“service”:“1204”,“properties”:[“Read”,“Write”]},{“descriptors”:[{“uuid”:“2902”}],“characteristic”:“1a01”,“service”:“1204”,“properties”:[“Read”,“Write”,“Notify”]},{“descriptors”:[{“uuid”:“1a02”}],“characteristic”:“1a02”,“service”:“1204”,“properties”:[“Read”]},{“characteristic”:“1a11”,“service”:“1206”,“properties”:[“Read”]},{“descriptors”:[{“uuid”:“2902”}],“characteristic”:“1a10”,“service”:“1206”,“properties”:[“Read”,“Write”,“Notify”]},{“descriptors”:[{“uuid”:“1a12”}],“characteristic”:“1a12”,“service”:“1206”,“properties”:[“Read”]}],“advertising”:{},“id”:“C4:7C:8D:63:81:E2”,“services”:[“1800”,“1801”,“fe95”,“fef5”,“1204”,“1206”],“rssi”:-55,“name”:“Flower care”}

tried to read data with

ble.read(
$stateParams.device_id,
$scope.ReadData.service,
$scope.ReadData.char
),
function(response){
//$ionicLoading.hide();
var data = new Uint8Array(response);
beatsPerMinute.innerHTML = data[1];
}



nothing hapens

Try to read the Failure Callback Function and see if you get any errors.

$scope.read = function(){
		ionicToast.show('Reading Data','top', false, 3000);
		beatsPerMinute.innerHTML = 'contacting';
		//alert(JSON.stringify($scope.ReadData));
		//$ionicLoading.show();
		ble.connect($stateParams.device_id,function(res){
				beatsPerMinute.innerHTML = 'connected with'+ res.name;
				ble.read(res.device_id,$scope.ReadData.service,$scope.ReadData.char,function(buffer){
					alert(JSON.stringify(buffer));
					ionicToast.show(JSON.stringify(buffer),'top', false, 3000);//$ionicLoading.hide();
					var data = new Uint8Array(buffer);
					ionicToast.show(JSON.stringify(data),'middle', false, 3000);
					beatsPerMinute.innerHTML = "Data: "+data[1];
				},function(reason) {
					beatsPerMinute.innerHTML = "Data Error "+reason;
		     	ionicToast.show(JSON.stringify(reason),'middle', false, 6000);
		    })
			},function(error){
				beatsPerMinute.innerHTML = "Connection Error"+JSON.stringify(error);
			})

	}

gettingData Error Peripheral null not found

If you see the actual implementation, it checks the second parameter i.e. macaddress and gives that error. Check the value of your macaddress/device_id and ensure that it is passed correctly.
You can also check the isConnected function by passing the device id.

ble.isConnected(
'FFCA0B09-CB1D-4DC0-A1EF-31AFD3EDFB53',
function() {
    console.log("Peripheral is connected");
},
function() {
    console.log("Peripheral is *not* connected");
}

);

ble.connect(id,function(res){
				ionicToast.show(id,'middle', false, 1000);
				beatsPerMinute.innerHTML = 'connected with'+ res.name+' '+id;
				ble.read(res.id,$scope.ReadData.service,$scope.ReadData.char,function(buffer){
					//ionicToast.show(id,'middle', false, 1000);
					deviceId.innerHTML = id;
					beatsPerMinute1.innerHTML = "Buffer: "+JSON.stringify(buffer);
					//alert(JSON.stringify(buffer));
					//ionicToast.show(JSON.stringify(buffer),'top', false, 3000);//$ionicLoading.hide();
					var data = new Uint8Array(buffer);
					//ionicToast.show(JSON.stringify(data),'middle', false, 3000);
					beatsPerMinute.innerHTML = "Data: "+data;
				},function(reason) {
					ionicToast.show(id,'middle', false, 1000);
					beatsPerMinute.innerHTML = "Data Error "+JSON.stringify(reason);
		     	ionicToast.show(JSON.stringify(reason),'middle', false, 1000);
		    })
			},function(error){
				ionicToast.show(id,'middle', false, 1000);
				beatsPerMinute.innerHTML = "Connection Error"+JSON.stringify(error);
			})

can you suggest which service id is for what, as
https://www.open-homeautomation.com/2016/08/23/reverse-engineering-the-mi-plant-sensor/
it shows different response what i am getting show in previous posts. Now trying to get data but its empty.

Can you paste the response of ble.connect and ble.startscan methods

it looks ok. no idea why its not working.

do you know anyone that can help me to do this. Because i need to do this and the timeline getting over.