nativescript-community / nativescript-community/ble

error_function_call

Open
#264 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
202
Forks
79
PR merge metrics
No merged PRs in 30d

Description

Hi,
I'm trying to write data to a characteristic of a BLE device (following the doc I have for this) but I always get an error :

ERROR Error: Uncaught (in promise): [BluetoothError]:error_function_call, writeCharacteristic, undefined, {"peripheralUUID":"A4:C1:38:C4:28:8A","serviceUUID":"1000","characteristicUUID":"1001","value":{}}
JS: BluetoothError: error_function_call
JS:     at file: src\webpack:\myapp\node_modules\@nativescript-community\ble\index.android.js:1934:32
JS:     at Bluetooth.attachSubDelegate (file: src\webpack:\myapp\node_modules\@nativescript-community\ble\index.android.js:2388:12)
JS:     at file: src\webpack:\myapp\node_modules\@nativescript-community\ble\index.android.js:1897:17
JS:     at new ZoneAwarePromise (file: src\webpack:\myapp\node_modules\zone.js\fesm2015\zone.js:1429:0)
JS:     at file: src\webpack:\myapp\node_modules\@nativescript-community\ble\index.android.js:1874:50
JS:     at file: src\webpack:\myapp\node_modules\@nativescript-community\ble\index.android.js:1633:82
JS:     at _ZoneDelegate.invoke (file: src\webpack:\myapp\node_modules\zone.js\fesm2015\zone.js:372:0)
JS:     at Object.onInvoke (file: src\webpack:\myapp\node_modules\@angular\core\fesm2015\core.mjs:25548:0)
JS:     at _ZoneDelegate.invoke (file: src\webpack:\myapp\node_modules\zone.js\fesm2015\zone.js:371:0)
JS:     at Zone.run (file:///data/data/be....

Here is what I try to do in the onConnected method :

let data = new Uint8Array([0x07, 0x04, 0x03, 0x00, 0x1e]);
self.bluetooth.writeWithoutResponse({
    peripheralUUID: peripheral2.UUID,
    serviceUUID: "00001000-0000-1000-8000-00805f9b34fb",
    characteristicUUID: "00001001-0000-1000-8000-00805f9b34fb",
    value: data.buffer
}).then(() => {
...
});

I'm having a similar issue with the read function
JS: read error: [BluetoothError]:error_function_call, readCharacteristic, undefined, {"peripheralUUID":"A4:C1:38:FD:D2:38","serviceUUID":"1000","characteristicUUID":"1002"}

Here is my code for that

self.bluetooth.read({
  peripheralUUID: peripheral2.UUID,
  serviceUUID: '00001000-0000-1000-8000-00805f9b34fb',
  characteristicUUID: '00001002-0000-1000-8000-00805f9b34fb',
}).then(function(result) {
...
});

I tried to read/write to those characteristics with a Java application and it's working so I guess this is a plugin issue ? Can you help me with that if it is ?
I use Nativescript with Angular and the phone that connects to the device is on Android 12.

Thanks in advance !

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the read and writeWithoutResponse calls on Android 12 using the UUIDs and Uint8Array shown in the report. Then inspect the Android implementation around index.android.js lines 1934 and 2388, including the readCharacteristic and writeCharacteristic paths. Done means identifying the cause of error_function_call and confirming a working read/write behavior or a narrowly documented plugin limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, angular, typescript
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.