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

Android Emulator issue - #401

Open
matthewbartos opened this issue Jan 17, 2024 · 5 comments
Open

Android Emulator issue - #401

matthewbartos opened this issue Jan 17, 2024 · 5 comments

Comments

@matthewbartos
Copy link

Hello! I'd like to emulate a Bluetooth device that connects to my Pixel 4 emulator.

I'm starting my Pixel 4 emulator with:

./emulator -packet-streamer-endpoint default -avd Pixel_4_API_30 -grpc 8877 -no-snapshot-load

and then trying any example or app from Bumble:

BUMBLE_LOGLEVEL=debug python3 apps/pair.py examples/device1.json android-netsim:localhost:8877 --request

with a result of:

WARNING:bumble.transport.common:exception while waiting for packet: <AioRpcError of RPC that terminated with:
	status = StatusCode.UNIMPLEMENTED
	details = ""
	debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2024-01-17T02:40:34.172341+01:00", grpc_status:12, grpc_message:""}"

What am I doing wrong?

@matthewbartos
Copy link
Author

Full Bumble logs:

BUMBLE_LOGLEVEL=debug python3 apps/pair.py examples/device1.json android-netsim:localhost:8877 --request
DEBUG:asyncio:Using selector: KqueueSelector
<<< connecting to HCI...
DEBUG:bumble.transport.android_netsim:Connecting to gRPC server at localhost:8877
DEBUG:grpc._cython.cygrpc:Using AsyncIOEngine.POLLER as I/O engine
DEBUG:bumble.transport.android_netsim:Sending chip info to netsim: name: "bumble0"
chip {
  kind: BLUETOOTH
  manufacturer: "Bumble"
}

<<< connected
DEBUG:bumble.drivers:Probing driver class: rtk
DEBUG:bumble.drivers.rtk:USB metadata not found
DEBUG:bumble.host:### HOST -> CONTROLLER: HCI_RESET_COMMAND
WARNING:bumble.transport.common:exception while waiting for packet: <AioRpcError of RPC that terminated with:
	status = StatusCode.UNIMPLEMENTED
	details = ""
	debug_error_string = "UNKNOWN:Error received from peer  {grpc_message:"", grpc_status:12, created_time:"2024-01-17T02:43:48.702412+01:00"}"
	```

@barbibulle
Copy link
Collaborator

Hello! I'd like to emulate a Bluetooth device that connects to my Pixel 4 emulator.

I'm starting my Pixel 4 emulator with:

./emulator -packet-streamer-endpoint default -avd Pixel_4_API_30 -grpc 8877 -no-snapshot-load

and then trying any example or app from Bumble:

BUMBLE_LOGLEVEL=debug python3 apps/pair.py examples/device1.json android-netsim:localhost:8877 --request

with a result of:

WARNING:bumble.transport.common:exception while waiting for packet: <AioRpcError of RPC that terminated with:
	status = StatusCode.UNIMPLEMENTED
	details = ""
	debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2024-01-17T02:40:34.172341+01:00", grpc_status:12, grpc_message:""}"

What am I doing wrong?

the --grpc command line option for the emulator does not refer to the Bluetooth gRPC endpoint (it is used for some other services by the emulator).
If you use a recent version of the emulator, you can simply use android-netsim as the transport name with Bumble, it will figure out the gRPC port automatically from a file that gets created by the emulator when it start the Bluetooth virtualization (netsimd).

@matthewbartos
Copy link
Author

Thank you, @barbibulle!
I still need to specify the gRPC port as I'm getting the RuntimeError: gRPC server port not found error, but I was easily able to find the correct gRPC port in the emulator logs 🙂

Right now, I seem to have an authorization error - do you know how to fix it?

grpc.aio._call.AioRpcError: <AioRpcError of RPC that terminated with:
	status = StatusCode.UNAUTHENTICATED
	details = "Missing the 'authorization' header with security credentials."
	debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2024-01-17T21:43:42.391381+01:00", grpc_status:16, grpc_message:"Missing the \'authorization\' header with security credentials."}"

@matthewbartos
Copy link
Author

I seem to have the newest possible emulator: version 34.2.4

@barbibulle
Copy link
Collaborator

The gRPC port you're seeing on the emulator log output is not the right one. The gRPC port that's needed here is the one from the netsimd process that is started by the emulator. The bumble transport obtains that automatically by parsing the netsim.ini file that is created by netsimd when it starts. The location of that file is platform-dependent, and Bumble supports finding it where it belongs, on Windows, macOS and Linux.
Can you try this:
1/ Start your emulator (either from the command line, with no command line arguments other than -avd XYZ (and possibly -no-snapshot-load if you need, but no -packet-streamer-endpoint nor -grpc arguments)
2/ Start a bumble app, with android-netsim as the transport name (make sure you have the latest version of Bumble so that we know we're looking at the same thing). For example, BUMBLE_LOGLEVEL=DEBUG python3 apps/controller_info.py android-netsim
You should see at the start of the log that Bumble finds the netsim.ini file and obtains the gRPC port from it.
For example, on my mac, I get this:

DEBUG:bumble.transport.android_netsim:Looking for .ini file at /var/folders/_3/94jb6f1d0734fq8_xqv46nmr00b8q2/T/netsim.ini
DEBUG:bumble.transport.android_netsim:gRPC port = 50969

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

2 participants