From baa15ceda3e4b63fef176561faace8ea290ce51f Mon Sep 17 00:00:00 2001 From: Louis-Guillaume DUBOIS Date: Fri, 2 Jun 2017 16:40:37 +0200 Subject: [PATCH] =?UTF-8?q?V=C3=A9rification=20de=20la=20taille=20des=20do?= =?UTF-8?q?nn=C3=A9es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../students/clientble/BluetoothLeService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Application/src/main/java/fr/centralesupelec/students/clientble/BluetoothLeService.java b/Application/src/main/java/fr/centralesupelec/students/clientble/BluetoothLeService.java index 1cddf6a..37397bb 100644 --- a/Application/src/main/java/fr/centralesupelec/students/clientble/BluetoothLeService.java +++ b/Application/src/main/java/fr/centralesupelec/students/clientble/BluetoothLeService.java @@ -147,9 +147,10 @@ public class BluetoothLeService extends Service { // For all other profiles, writes the data formatted in HEX. final byte[] data = characteristic.getValue(); if (data != null && data.length > 0) { - if (SampleGattAttributes.SENSOR_CHARACTERISTIC_UUID.equals(characteristic.getUuid())) { + if (SampleGattAttributes.SENSOR_CHARACTERISTIC_UUID.equals(characteristic.getUuid()) + && data.length >= 1) { int value = (data[0]<<8)&0x0000ff00 | (data[1]<<0)&0x000000ff; - intent.putExtra(EXTRA_DATA, String.format("%d", value)); + intent.putExtra(EXTRA_DATA, String.format("décimal: %d", value)); } else { final StringBuilder stringBuilder = new StringBuilder(data.length); //stringBuilder.append(String.format("%d", data));/