angular-web-bluetooth-starter icon indicating copy to clipboard operation
angular-web-bluetooth-starter copied to clipboard

acceptAllDevices not working

Open aircable opened this issue 8 years ago • 14 comments

using the library to scan for all devices throws a Typescript error. Filter work, though.

let scanfilter1 = { options: { acceptAllDevices: true } };

  this.webble
      // 1: discover devices
      .discover$( scanfilter1 );

ERROR: Typescript Error Argument of type '{ options: { acceptAllDevices: boolean; }; }' is not assignable to parameter of type 'RequestDeviceOptions'. Property 'filters' is missing in type '{ options: { acceptAllDevices: boolean; }; }'.

ON; Ionic Framework: 3.0.1 Ionic App Scripts: 1.3.0 Angular Core: 4.0.0 Angular Compiler CLI: 4.0.0 Node: 7.8.0 OS Platform: macOS Sierra Navigator Platform: MacIntel User Agent: Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LYZ28E) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Mobile Safari/537.36

aircable avatar Apr 12 '17 17:04 aircable

Thanks @aircable I'll fix this asap.

Here is a temporary fix:

let scanfilter1 = {
        acceptAllDevices: true,
 } as any;

this.webble
      // 1: discover devices
      .discover$( scanfilter1);

manekinekko avatar Apr 12 '17 18:04 manekinekko

Thanks, looking forward to finding those fixes. It was probably wrong to post that in the starter repo, should have been posted in the main. Sorry,

I've been trying to work with your lib in an Ionic 3 environment. Would you mind looking over my source?

On Wed, Apr 12, 2017 at 11:13 AM, Wassim Chegham [email protected] wrote:

Thanks @aircable https://github.com/aircable I'll fix this asap.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/manekinekko/angular-web-bluetooth-starter/issues/2#issuecomment-293662850, or mute the thread https://github.com/notifications/unsubscribe-auth/AAyuhgz7khxHHaFxoZNZLOeRr97ZhkSrks5rvRRcgaJpZM4M7u0B .

aircable avatar Apr 12 '17 23:04 aircable

sure. What's the link?

manekinekko avatar Apr 12 '17 23:04 manekinekko

oh, thanks, this is still the first steps for me to do Ionic 3. Lots of trial/error here. I'm porting the Ionic 1 app over. It's quite different.

new: https://github.com/aircable/SmartMesh2 old: https://github.com/aircable/SmartMesh

My goal in the first step is to integrate the WebBluetooth with the native Bluetooth in one app so, depending on where it runs, it uses whatever Bluetooth available.

Any help is appreciated. I'd value any suggestions you may have. The first steps are always difficult. Cheers Juergen

On Wed, Apr 12, 2017 at 4:21 PM, Wassim Chegham [email protected] wrote:

sure. What's the link?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/manekinekko/angular-web-bluetooth-starter/issues/2#issuecomment-293734336, or mute the thread https://github.com/notifications/unsubscribe-auth/AAyuhuov93JVNSpm8pO1WyNdHRe5z6xpks5rvVx4gaJpZM4M7u0B .

aircable avatar Apr 13 '17 00:04 aircable

just pushed a few changes, it now does actually connect to BLE and shows some results.

If you have an idea how to unify ble native and web bluetooth into one service, let me know. Cheers Juergen

On Wed, Apr 12, 2017 at 5:20 PM, Juergen Kienhoefer [email protected] wrote:

oh, thanks, this is still the first steps for me to do Ionic 3. Lots of trial/error here. I'm porting the Ionic 1 app over. It's quite different.

new: https://github.com/aircable/SmartMesh2 old: https://github.com/aircable/SmartMesh

My goal in the first step is to integrate the WebBluetooth with the native Bluetooth in one app so, depending on where it runs, it uses whatever Bluetooth available.

Any help is appreciated. I'd value any suggestions you may have. The first steps are always difficult. Cheers Juergen

On Wed, Apr 12, 2017 at 4:21 PM, Wassim Chegham [email protected] wrote:

sure. What's the link?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/manekinekko/angular-web-bluetooth-starter/issues/2#issuecomment-293734336, or mute the thread https://github.com/notifications/unsubscribe-auth/AAyuhuov93JVNSpm8pO1WyNdHRe5z6xpks5rvVx4gaJpZM4M7u0B .

aircable avatar Apr 13 '17 23:04 aircable

Hi Wassim,

I'm struggling to write to a characteristic with your api interface. Can you please point me to an example?

Also how do you do debugging with promises? I tried all ways, nothing seems to do that.

writeCompleteMTL( value: any ) { console.log('Write Mesh Service: %s', MeshService.GATT_CHARACTERISCTICS[1]); try { this._core.getGATT$() .mergeMap((gatt:BluetoothRemoteGATTServer) => { console.log("gatt: %s", JSON.stringify(gatt)); return this._core.getPrimaryService$(gatt, MeshService.GATT_PRIMARY_SERVICE); }) .mergeMap((primaryService:BluetoothRemoteGATTService) => this._core.getCharacteristic$(primaryService, MeshService.GATT_CHARACTERISCTICS[1])) .mergeMap((characteristic:BluetoothRemoteGATTCharacteristic) => this._core.writeValue$(characteristic, value)); } catch( e ) { console.error('write value: %s', e); } }

On Thu, Apr 13, 2017 at 4:43 PM, Juergen Kienhoefer [email protected] wrote:

just pushed a few changes, it now does actually connect to BLE and shows some results.

If you have an idea how to unify ble native and web bluetooth into one service, let me know. Cheers Juergen

On Wed, Apr 12, 2017 at 5:20 PM, Juergen Kienhoefer [email protected] wrote:

oh, thanks, this is still the first steps for me to do Ionic 3. Lots of trial/error here. I'm porting the Ionic 1 app over. It's quite different.

new: https://github.com/aircable/SmartMesh2 old: https://github.com/aircable/SmartMesh

My goal in the first step is to integrate the WebBluetooth with the native Bluetooth in one app so, depending on where it runs, it uses whatever Bluetooth available.

Any help is appreciated. I'd value any suggestions you may have. The first steps are always difficult. Cheers Juergen

On Wed, Apr 12, 2017 at 4:21 PM, Wassim Chegham <[email protected]

wrote:

sure. What's the link?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/manekinekko/angular-web-bluetooth-starter/issues/2#issuecomment-293734336, or mute the thread https://github.com/notifications/unsubscribe-auth/AAyuhuov93JVNSpm8pO1WyNdHRe5z6xpks5rvVx4gaJpZM4M7u0B .

aircable avatar Apr 20 '17 23:04 aircable

Hi Juergen, Can you describe more your use case? I don't know which device you're connecting to. Here is an example from Uri's repo: https://github.com/urish/ng-beacon-app/blob/master/src/app/ble-uart.service.ts#L57

But, please know that each vendor deals differently with services and characteristics.

manekinekko avatar Apr 22 '17 14:04 manekinekko

Can you also share more details about your error (knowing that I can't debug since I don't have the BLE device).

manekinekko avatar Apr 22 '17 14:04 manekinekko

I would, but I don't get any errors. It just doesn't do write to the Characteristic. The call is just ignored and none of the promises are filled or fail. Just nothing. That is my problem.

I'll keep testing.

On Sat, Apr 22, 2017 at 7:12 AM, Wassim Chegham [email protected] wrote:

Can you also share more details about your error (knowing that I can't debug since I don't have the BLE device).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/manekinekko/angular-web-bluetooth-starter/issues/2#issuecomment-296375856, or mute the thread https://github.com/notifications/unsubscribe-auth/AAyuhl84ag5XjHpCejN_nVrsOHfbSAMmks5rygrHgaJpZM4M7u0B .

aircable avatar Apr 22 '17 18:04 aircable

did you enable the logs?

WebBluetoothModule.forRoot({
      enableTracing: true
})

manekinekko avatar Apr 22 '17 18:04 manekinekko

Thanks for the link to the example app. That helped a lot. I rewrote the whole service and copied the way @urish did the write, with sequence and such.

It does connect again, I see notifications, but when I click on WRITE, the Chrome browser on OSX crashes.

It did happen before with my Ionic-1 app, writing to a char crashes the browser.

What environment are you testing on? I'll test on Android next.

On Sat, Apr 22, 2017 at 11:48 AM, Wassim Chegham [email protected] wrote:

did you enable the logs?

WebBluetoothModule.forRoot({ enableTracing: true })

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/manekinekko/angular-web-bluetooth-starter/issues/2#issuecomment-296393583, or mute the thread https://github.com/notifications/unsubscribe-auth/AAyuhreTvJwd12Y3D1QwttdVeByzV1-kks5rykuGgaJpZM4M7u0B .

aircable avatar Apr 23 '17 22:04 aircable

different problem, gets an error on GATT: error unknown.

I'm trying to figure out how I can do error handling. Ideas? This is the connect to char phase. The one of the car1 gets an unknown error, but it seems like, the connection actually succeeded. That's on Chrome DEV on Android. Succeeds on Chrome on OSX.

How can I use that: https://xgrommx.github.io/rx-book/content/getting_started_with_rxjs/creating_and_querying_observable_sequences/error_handling.html to skip over any char1 or char2 errors?

// connect to the CHARACTERISTICS
private _connectChars( primaryService: BluetoothRemoteGATTService ) {

    const MTL_short    = this._core.getCharacteristic$(
primaryService, MeshService.MTL_SHORT_CP ).share();

    this.receive$ = MTL_short.mergeMap( characteristic =>
this._core.observeValue$( characteristic ))
        .map( value => String.fromCharCode.apply( null, new
Uint8Array(value.buffer)) as string );

    //const chars = this.receive$.concatMap(chunk => chunk.split(''));
    //this.lines$ = chars.scan((acc, curr) => acc[acc.length - 1] ===
'\n' ? curr : acc + curr)
    // .filter(item => item.indexOf('\n') >= 0);

    var char1 = this._core
        .getCharacteristic$( primaryService, MeshService.MTL_COMPLETE_CP )
        .map(( characteristic: BluetoothRemoteGATTCharacteristic ) => {
            this.completeChar = characteristic;
        });

    var char2 = this._core
        .getCharacteristic$( primaryService, MeshService.MTL_CONTINUATION_CP )
        .map(( characteristic: BluetoothRemoteGATTCharacteristic ) => {
            this.continueChar = characteristic;
        });

    return Observable.zip(
        // write characteristic setup
        char1,
        // second one
        char2,
        // read from characteristic
        MTL_short,
    ).do(([ _short, _complete, _continue ]) => {
        setTimeout(() => this.writableSubject.next( true ), 0);
    });
}

On Sun, Apr 23, 2017 at 3:57 PM, Juergen Kienhoefer [email protected] wrote:

Thanks for the link to the example app. That helped a lot. I rewrote the whole service and copied the way @urish did the write, with sequence and such.

It does connect again, I see notifications, but when I click on WRITE, the Chrome browser on OSX crashes.

It did happen before with my Ionic-1 app, writing to a char crashes the browser.

What environment are you testing on? I'll test on Android next.

On Sat, Apr 22, 2017 at 11:48 AM, Wassim Chegham <[email protected]

wrote:

did you enable the logs?

WebBluetoothModule.forRoot({ enableTracing: true })

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/manekinekko/angular-web-bluetooth-starter/issues/2#issuecomment-296393583, or mute the thread https://github.com/notifications/unsubscribe-auth/AAyuhreTvJwd12Y3D1QwttdVeByzV1-kks5rykuGgaJpZM4M7u0B .

aircable avatar Apr 24 '17 00:04 aircable

@aircable I usually work on my mac os x too.

@beaufortfrancois do you anything about this behavior?

I'm trying to figure out how I can do error handling. Ideas? This is the
connect to char phase.
The one of the car1 gets an unknown error, but it seems like, the
connection actually succeeded.
That's on Chrome DEV on Android. Succeeds on Chrome on OSX.

manekinekko avatar Apr 24 '17 23:04 manekinekko

This is the version I use: Chrome Version 57.0.2987.133 (64-bit)

I tried Chrome Canary on OSX too, still, when I write to a CHAR it crashes. Here is the bug report. One click on SEND and it crashes. Inspect shows the console log, then it happens.

Send is implemented:

// write to CHAR writeCompleteMTL( text: string ) { const bytes = text.split('').map(c => c.charCodeAt(0)); const chunks = []; while (bytes.length > 0) { chunks.push(new Uint8Array(bytes.splice(0, 20))); } const result = Observable.zip( Observable.from(chunks), this.writableSubject.filter(value => value)) .mergeMap(([ chunk, writable ]) => { this.writableSubject.next( false ); console.log( "writing: %s", chunk ); return this._core.writeValue$( this.completeChar, chunk); }) .map(() => setTimeout(() => this.writableSubject.next(true), 10)) .publish();

result.connect();
return result;

}

Process: Google Chrome Canary [35750] Path: /Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary Identifier: com.google.Chrome.canary Version: 60.0.3079.0 (3079.0) Code Type: X86-64 (Native) Parent Process: ??? [1] Responsible: Google Chrome Canary [35750] User ID: 501

Date/Time: 2017-04-24 16:48:45.692 -0700 OS Version: Mac OS X 10.12.4 (16E195) Report Version: 12 Anonymous UUID: 25FD8EB4-C36E-1D52-5C1B-FCEA2ED3C583

Time Awake Since Boot: 90000 seconds

System Integrity Protection: disabled

Crashed Thread: 0 CrBrowserMain Dispatch queue: com.apple.main-thread

Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000008

VM Regions Near 0x8: --> __TEXT 0000000108134000-0000000108135000 [ 4K] r-x/rwx SM=COW /Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary

On Mon, Apr 24, 2017 at 4:16 PM, Wassim Chegham [email protected] wrote:

I usually work on my mac os x too.

@beaufortfrancois https://github.com/beaufortfrancois do you anything about this behavior?

I'm trying to figure out how I can do error handling. Ideas? This is the connect to char phase. The one of the car1 gets an unknown error, but it seems like, the connection actually succeeded. That's on Chrome DEV on Android. Succeeds on Chrome on OSX.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/manekinekko/angular-web-bluetooth-starter/issues/2#issuecomment-296847854, or mute the thread https://github.com/notifications/unsubscribe-auth/AAyuhojwhk3IBCMFq5QAHWcDU_KJ2v5sks5rzS0_gaJpZM4M7u0B .

aircable avatar Apr 24 '17 23:04 aircable