cheng81 / Android-Bluetooth-Simulator

Simple tcp-based bluetooth simulator for the android emulator
47 stars 5 forks source link

BluetoothChat sample program crashes when trying to use the simulator #1

Closed William2 closed 14 years ago

William2 commented 14 years ago

Seems that the BluetoothChat sample program expects the name returned from the function BluetoothDevice.getName() to be non null and crashes if it is null (which it is in my environment). I can't find anywhere this (name) is set, so as a temporary fix I initialize it to some value such as "local".

William2 commented 14 years ago

A better approach would be to include the device name in the Discovery response (since it's already been sent to the server in the Join msg) and pass it to a new BluetoothDevice ctor (one that also takes name) in Discovery.readResponse(). I have a mock up of this idea working and I think it's better way to do it. Although the name it sends in the Join message currently comes from the default BluetoothAdapter and is called "local". Maybe this name could be constructed from the emulator name which would include the port and therefore be unique.

cheng81 commented 14 years ago

Yes, I remember that that was an issue (and I had no time to fix it). Anyway, I just pushed some changes to the code. Basically, now the names are fixed to "emulator-".