Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting "Attempt to invoke virtual method 'boolean android.bluetooth.BluetoothGattServer.addService(android.bluetooth.BluetoothGattService)' on a null object reference" on Android #9

Open
huseyincandan opened this issue Aug 20, 2018 · 6 comments

Comments

@huseyincandan
Copy link

huseyincandan commented Aug 20, 2018

Hi,

I'm trying the sample code and
blePeripheral.startAdvertising(SERVICE_UUID, 'UART')
line gives error on Android. On iOS everything is working without any error.

I've installed "Adafruit Bluefruit LE Connect" app. When I tap Peripheral Mode getting "Error starting advertising" error.

I've tried on both a tablet and a Samsung mobile phone and got same result.

Can you help me about the point I am missing?

Thanks,

@curious-monggo
Copy link

Hi Sir huserincadan. I too am trying to use cordova-plugin-ble-peripheral and was not able to create it on ionic. It would be of great help if you hit me up if you are able to create and start advertising :)
-A fellow and new ble enthusiast

@curious-monggo
Copy link

Also, for some reason, the blePeripheral.onBluetoothStateChange(app.onBluetoothStateChange); gets triggered even if there was no change in bluetooth state. I wonder if you came across that behavior too?

@huseyincandan
Copy link
Author

Hi laaaaanceeee,
I am also using ionic. You can access blePeripheral object by following code. I hope it helps. If you need I may share whole code.

let blePeripheral = (window).blePeripheral;

I could not try onBluetoothStateChange because I could not start advertising.

Actullay, using mobile phone as ble peripheral is very important part of my project. I'll control my web app (nodejs) by mobile app.
Everything was fine on iOS and I'am developing on mac and iPhone, so I've almost completed the code.

I hope Don will help !

@curious-monggo
Copy link

For the meantime, you can use this : )
https://github.com/somq/ionic-plugin-bluetoothle
This is an ionic native plugin(wrapper for a cordova plugin) that supports central and peripheral.

Happy coding!
(Don seems to be busy with other things and may not reply to you for the time being)

@adrian-fratila
Copy link

Hi guys,

I am a newbie in Ionic, and I try to get working a BLE peripheral in Ionic 3. For some reason the cordova bluetoothle plugin returns as not found when I try to build, although it appears as installed correctly when I try to reinstall it. Nevertheless somehow I got the @ionic-native/bluetooth-le to build the code.

I followed the steps of initialise, initializePeripheral, addService, startAdvertising and they return like everything as expected (ending up with AdvertisingStarted), but for some reason the device doesn't appear when I scan from another smartphone.

Also I could not figure out how to assign the callback function which is called when the device gets connected to, or receives something from the other side / the client.

I would highly appreciate if you could point me to an example code which implements the peripheral functionality in Ionic 3, as I have been struggling already a couple of days on this issue..

Thank you,
Adrian

@caseylai
Copy link

same problem. Finally I found out that the phone hardware does not support the peripheral mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants