Ejemplo n.º 1
0
 private void displayData(final BluetoothGattCharacteristic characteristic, Characteristiques ch) {
   switch (characteristic.getUuid().toString()) {
     case FlowerPowerConstants.CHARACTERISTIC_UUID_TEMPERATURE:
       int temperature =
           valueMapper.mapTemperature(
               characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, 0));
       ch.setValue(temperature + "");
       System.err.println("Temp " + ch.getValue());
       break;
     case FlowerPowerConstants.CHARACTERISTIC_UUID_SUNLIGHT:
       double luminosite =
           valueMapper.mapSunlight(
               characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, 0));
       ch.setValue(luminosite + "");
       System.err.println("Display Sunlight" + ch.getValue());
       break;
     case FlowerPowerConstants.CHARACTERISTIC_UUID_SOIL_MOISTURE:
       double humidite =
           valueMapper.mapSoilMoisture(
               characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, 0));
       ch.setValue(humidite + "");
       System.err.println("Display Soil Moisture " + ch.getValue());
       break;
     default:
       break;
   }
   MainActivity.adapter.notifyDataSetChanged();
   myView.invalidate();
 }
Ejemplo n.º 2
0
 public UpdateDeviceData(
     Context context, BluetoothGattService service, BluetoothGatt gatt, ListView myView) {
   this.context = context;
   this.service = service;
   this.gatt = gatt;
   this.myView = myView;
   this.valueMapper = ValueMapper.getInstance(context);
 }