All Products
Search
Document Center

Mobile Platform as a Service:Bluetooth API FAQ

Last Updated:Feb 04, 2021

Does the API call of my. WriteBLECharacteristicValue return an empty value?

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.

Why is the error code 10014 returned after calling my. Why writeBLECharacteristicValue?

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.

What is the deviceId format for Android and iOS devices?

  • The Android device gets the MAC address for Bluetooth, for example: 11:22:33:44:55:66.
  • The iOS device gets the UUID of Bluetooth, for example: 00000000-0000-0000-0000-000000000000.

Why no devices are discovered by calling my.startBluetoothDevicesDiscovery?

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.

How to resolve device connection failure?

Please make sure the correct deviceId is transmitted with strong signals. If the signal is weak, a device connection failure may occur.

How to resolve write/read data failure?

  • DeviceId, serviceId, and characteristicId are transmitted in the correct format.
  • DeviceId is connected. You can call the API my.OnBLEConnectionStateChanged to listen to the connection state changes, and call the API my.GetConnectedBluetoothDevices to 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.

How to receive data notifications?

  • Make sure that the API my.notifyBLECharacteristicValueChange has been called with correct parameters.
  • Notify or indicate features are supported in the transmitted characteristicID.
  • Make sure the hardware is notified.
  • Follow the basic flow, i.e. call the API my.notifyBLECharacteristicValueChange once you’re connected.

Why are event callbacks called multiple times?

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.