Error Codes in Near Connections 2.0

I experimented with the new Android Near Connections v2.0 API . Most of my devices can now talk to each other most of the time, but I also get a lot of error codes back when trying to connect. When checking status.getStatusCode()inside my program, I see the following return codes:

  • STATUS_ALREADY_CONNECTED_TO_ENDPOINT (8003)
  • STATUS_BLUETOOTH_ERROR (8007)
  • STATUS_ENDPOINT_IO_ERROR (8012)
  • STATUS_ERROR (13)

It’s hard for me to understand this. The first error code seems to be taken for granted, except that I see it in cases where I did not hit the onConnectionResult callback with the “SUCCESS” return code on both sides of the intended connection. My current code is populated with trace statements, and I will see the log entries if these callbacks were reached. So, perhaps, the devices are connected at some lower level, but if so, the higher level code does not always hear about it.

I assume that STATUS_BLUETOOTH_ERROR indicates a Bluetooth error on the side that logs it, and STATUS_ENDPOINT_IO_ERROR indicates an error (possibly Bluetooth related) on the other end? Can I get more detailed information? The STATUS_ERROR (13) state, which I see from time to time, looks like an error code that the programmer would use for those “WTF, we should never be here”, but without access to the source code, I can only guess.

, , , . , , . . (STATUS_BLUETOOTH_ERROR / STATUS_ENDPOINT_IO_ERROR).

Near Connections P2P_CLUSTER. , , , , . , , , , ( ).

"", :

09-04 22:54:40.070 3866-3924/? W/NearbyConnections: Cannot deserialize BluetoothDeviceName: expecting min 16 raw bytes, got 6

, , Near Connections (, ZGbx) Bluetooth ? . -, " ", ?

+4
2

[ : " " ). .

STATUS_ALREADY_CONNECTED_TO_ENDPOINT: , 'requestConnection', - (onConnectionInitiated) (onConnectionResult) . , onConnectionInitiated, , .

STATUS_BLUETOOTH_ERROR: - Bluetooth. , . () . , connectConnection. Connections Bluetooth, , .

STATUS_ENDPOINT_IO_ERROR: . ( , Bluetooth , ..). , , . , , , .

STATUS_ERROR: - , . . onConnectionResult (FAILED), , - onConnectionInitiated , .

" BluetoothDeviceName" , . ; , .

, , , .

+3

, API .

, Nearby.Connections.requestConnection(googleApiClient, shortNameHere,....)

UUID.randomUUID(). toString(), , , STATUS_BLUETOOTH_ERROR. , , , UUID P2P_CLUSTER, .

STATUS_BLUETOOTH_ERROR.

0

Source: https://habr.com/ru/post/1685021/


All Articles