> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rebellapp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# my.onBLECharacteristicValueChange

> Listen for BLE characteristic value changes.

Use this API to listen for changes in the value of a BLE device characteristic. It is triggered when you call `my.readBLECharacteristicValue` or when a characteristic with `notify` or `indicate` enabled pushes a new value.

## Parameters

| Property | Type     | Required | Description                                  |
| -------- | -------- | -------- | -------------------------------------------- |
| success  | Function | No       | Callback when a characteristic value changes |
| fail     | Function | No       | Callback on failure                          |
| complete | Function | No       | Callback that always executes                |

## Success Callback Parameters

| Property         | Type       | Description                              |
| ---------------- | ---------- | ---------------------------------------- |
| deviceId         | String     | Device identifier                        |
| serviceId        | String     | Service UUID                             |
| characteristicId | String     | Characteristic UUID                      |
| value            | Hex String | The new hexadecimal characteristic value |

## Code Example

### Basic Usage

```javascript theme={null}
my.onBLECharacteristicValueChange({
  success: (res) => {
    console.log('Device:', res.deviceId);
    console.log('Characteristic:', res.characteristicId);
    console.log('Value:', res.value);
  }
});
```

### Read and Handle Value

```javascript theme={null}
Page({
  onLoad() {
    my.onBLECharacteristicValueChange({
      success: this.handleValueChange
    });
  },

  handleValueChange(res) {
    console.log('Received hex value:', res.value);
    this.setData({ latestValue: res.value });
  },

  readValue() {
    my.readBLECharacteristicValue({
      deviceId: this.data.deviceId,
      serviceId: this.data.serviceId,
      characteristicId: this.data.characteristicId,
    });
  },

  onUnload() {
    my.offBLECharacteristicValueChange();
  }
});
```

### Notify-Based Updates

```javascript theme={null}
// When characteristic has notify enabled, updates arrive automatically
my.onBLECharacteristicValueChange({
  success: (res) => {
    if (res.characteristicId === '0000FFF1-0000-1000-8000-00805F9B34FB') {
      console.log('Sensor data (hex):', res.value);
    }
  }
});
```

<Info>
  The value is delivered as a hexadecimal string. Parse it according to the characteristic's GATT profile.
</Info>

## Related APIs

<CardGroup cols={2}>
  <Card title="my.offBLECharacteristicValueChange" icon="xmark" href="/jsapi/device/bluetooth/my.offBLECharacteristicValueChange">
    Stop listening for value changes
  </Card>

  <Card title="my.readBLECharacteristicValue" icon="arrow-down" href="/jsapi/device/bluetooth/my.readBLECharacteristicValue">
    Trigger a read on a characteristic
  </Card>

  <Card title="my.getBLEDeviceCharacteristics" icon="list" href="/jsapi/device/bluetooth/my.getBLEDeviceCharacteristics">
    Get device characteristics
  </Card>
</CardGroup>
