No. Calling this API returns the value of what you write.
Why is listening not supported with the API call of my.onBLECharacteristicValueChange? Is it required to write before listening?
Yes. To call this API, you first need to write before you can listen. In order to prevent multiple callbacks of an event caused by multiple registered event listeners, it is recommended to call off method to listen to an event and close the previous event listener, before you call on method.
The error code 10014 means the data you send are either empty or incorrectly formatted. It is suggested to check for errors in the written data or HEX conversion.
Can the hexadecimal array be used in the process of calling my.writeBLECharacteristicValue to write characteristic value?
No. The characteristic values you write are hexadecimal strings, which are limited to 20 bytes.
- The Android device gets the MAC address for Bluetooth, for example:
- The iOS device gets the UUID of Bluetooth, for example:
Please make sure that the device is discoverable. If the API is passed to services, make sure that the discoverable content of the device contains the UUID of the service.
Please make sure the correct
deviceId is transmitted with strong signals. If the signal is weak, a device connection failure may occur.
characteristicIdare transmitted in the correct format.
DeviceIdis connected. You can call the API
my.OnBLEConnectionStateChangedto listen to the connection state changes, and call the API
my.GetConnectedBluetoothDevicesto check for devices that are connected.
- Write a method in the connected state.
- Check and make sure characteristicId belongs to this Service.
- The characteristic supports write/read.
- Make sure that the API
my.notifyBLECharacteristicValueChangehas been called with correct parameters.
- Notify or indicate features are supported in the transmitted
- Make sure the hardware is notified.
- Follow the basic flow, i.e. call the API
my.notifyBLECharacteristicValueChangeonce you’re connected.
The same event was listened due to multiple anonymous function registrations. It is suggested to call
off method to disable the previous event listener before you call the
on method to listen to event.