Parameters
Code Example
Error Codes
Related APIs
my.readBLECharacteristicValue
Read a characteristic value
my.onBLECharacteristicValueChange
Listen for value changes
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Write a value to a BLE device characteristic.
| Property | Type | Required | Description |
|---|---|---|---|
| deviceId | String | Yes | Device identifier |
| serviceId | String | Yes | Service UUID |
| characteristicId | String | Yes | Characteristic UUID |
| value | Hex String | Yes | Hexadecimal string value to write, limited to 20 bytes |
| success | Function | No | Callback on success |
| fail | Function | No | Callback on failure |
| complete | Function | No | Callback that always executes |
my.writeBLECharacteristicValue({
deviceId: 'XX:XX:XX:XX:XX:XX',
serviceId: '0000FFF0-0000-1000-8000-00805F9B34FB',
characteristicId: '0000FFF1-0000-1000-8000-00805F9B34FB',
value: 'fffe',
success: (res) => {
console.log('Write succeeded:', res);
},
fail: (err) => {
console.error('Write failed:', err);
}
});
| Code | Description |
|---|---|
| 10000 | The Bluetooth adapter is not initialized |
| 10001 | The Bluetooth adapter is not available |
| 10002 | Device not found |
| 10003 | Connection failed |
| 10004 | Service not found |
| 10005 | Characteristic not found |
| 10006 | Connection lost |
| 10007 | Characteristic not supported |
| 10008 | System error |
| 10009 | BLE is not supported for Android systems with versions lower than 4.3 |
| 10011 | Invalid device ID |
| 10012 | Invalid service ID |
| 10013 | Invalid characteristic ID |
| 10014 | Invalid data |
| 10015 | Timeout |
| 10016 | Parameters not enough |
| 10017 | Failed to write characteristic |