batt read
This commit is contained in:
parent
a9064f3e9e
commit
04da54b868
@ -134,10 +134,10 @@ public abstract class BLEDevice {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDescriptorRead(@NonNull BluetoothGatt gatt, @NonNull BluetoothGattDescriptor descriptor, int status, @NonNull byte[] value) {
|
||||
super.onDescriptorRead(gatt, descriptor, status, value);
|
||||
mainClass.onDescriptorRead(gatt, descriptor, status);
|
||||
Log.d("bt", "onDescriptorRead: ");
|
||||
public void onCharacteristicRead(@NonNull BluetoothGatt gatt, @NonNull BluetoothGattCharacteristic characteristic, int status) {
|
||||
super.onCharacteristicRead(gatt, characteristic, status);
|
||||
Log.d("bt", "onCharacteristicRead: ");
|
||||
mainClass.onCharacteristicRead(gatt, characteristic, status);
|
||||
commandLock=false;
|
||||
runNextCommand();
|
||||
}
|
||||
@ -201,6 +201,9 @@ public abstract class BLEDevice {
|
||||
protected void onDescriptorRead(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status){
|
||||
eventCallback.onDescriptorRead(gatt, descriptor, status);
|
||||
}
|
||||
protected void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status){
|
||||
eventCallback.onCharacteristicRead(gatt, characteristic, status);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.S)
|
||||
public void startScan(ScanCallback callback){
|
||||
@ -252,7 +255,7 @@ public abstract class BLEDevice {
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
protected void readCharacteristic(BluetoothGattService service, BluetoothGatt bluetoothGatt, UUID uuid){
|
||||
Log.d("bt", "readCharacteristic: "+uuid);
|
||||
Log.d("bt", "readCharacteristic: "+uuid+":"+bluetoothGatt+":"+service);
|
||||
BluetoothGattCharacteristic charact = service.getCharacteristic(uuid);
|
||||
commandQueue.add(new Runnable() {
|
||||
@Override
|
||||
|
@ -74,14 +74,15 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.TIRAMISU)
|
||||
@Override
|
||||
public void onCharacteristicRead(@NonNull BluetoothGatt gatt, @NonNull BluetoothGattCharacteristic characteristic, @NonNull byte[] value, int status) {
|
||||
super.onCharacteristicRead(gatt, characteristic, value, status);
|
||||
public void onCharacteristicRead(@NonNull BluetoothGatt gatt, @NonNull BluetoothGattCharacteristic characteristic, int status) {
|
||||
super.onCharacteristicRead(gatt, characteristic, status);
|
||||
Log.d("UI_update", "onCharacteristicRead: ");
|
||||
if(characteristic.getUuid().equals(sensor.CHAR_BATT_LEVEL_UUID)){
|
||||
Log.d("UI_update", "onCharacteristicChanged: batt");
|
||||
int val = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, 0);
|
||||
CO2_widget.setValue(val);
|
||||
batt_widget.setValue(val);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user