Languages

Menu
Sites
Language
Can't pair app after reboot (channel mismatch)
 
 

Hi,

I've done a companion app between my Gear S2 and my Samsung S6 phone (running Android 6.01). It's the same implementation as the "Hello Accessory" example and it runs ok. After I install the app on my phone, everything works correctly (I can send a message from the watch and the app receives it).

But, as soon as I reboot the phone, the watch can't find the peer (of course, other apps like the Samsung Gear app work fine with the watch). If then I reinstall the app, everything works ok until next reboot.

I've checked the logcat and I see this after the reboot (when the pairing doesn't work). Look specially at the "Remote and Local channel Ids mismatch" (because I'm sure they match):

I/SABtRfConnection: BT Read protocol frame of length: 38
D/SATransportManager: Received a message from accessory ID: 52841
V/SANoAcknowledger: Processing Data Frame for accessory 52841
D/SASessionManager: >> ReceiverDequeTask : processing session id : 1023 priority : 3
V/SAFrameUtils: Application service profile ID: /example/myapp
I/SASessionManager: Received SC req from REMOTE - initiator: 33685 acceptor: 39635 profileId: /example/myapp
W/SACapabilityManager: Channel Size does not match!!
W/SASessionManager: Remote and Local channel Ids mismatch!!
W/SASessionManager: Rejecting service connection from initiator ID: 33685 Acceptor: 39635 profile /example/myapp accessoryId 52841
W/SASessionManager: ConnectionLimit : No entry found for ComponentId: 39635 in the map!
V/SATransportManager: Attempt to enqueue message sessionId: 1023
D/SATransportManager: >> DequeTask : processing session id : 1023 priority : 3
D/SAConnectivityManager: Sending Message - accessoryId: 52841 sessionId: 1023
I/SABtRfConnection: BT Wrote protocol frame of length: 39
D/SATransportManager: onMessageDispatched from accessory ID: 52841 for session :1023
D/SATransportManager: notifying deque task 
I/SATransportManager: Setting PQ to unpaused! Current Size : 0 Current State : 1

Also, it looks that everything starts to work again after reinstall because (not sure about this) my app re-register the service in the Samsung Accessory Framework. Specifically, after reinstalling, everything works after this (logcat):

D/RegisterUponInstallReceiver: Received Resgister after install:com.example.myapp
I/SASdkConfig: Accessory Framework:2.16.125 Accessory SDK:2.3.0
I/ServiceXmlReader: Service description(s) file Location:/res/xml/accessoryservices.xml
D/ServiceXmlReader: Fetching xml from /res/xml
V/ServiceXmlReader: Start document
V/ServiceXmlReader: Start document
I/SAAgent: Agent ID retrieved successfully for com.example.myapp.ProviderServiceAgent ID:58502
I/SARegistrationTask: Services Registered successfully!

Those lines don't appear when booting.

Where is the problem? As a workaround, could I broadcast a "RegisterUponInstallReceiver" intent or something to force the framework to re-register my app?

Any help is very much welcome!

P.S. I've tried to format the post, but I don't know if it made it more readable or not :/

 
View Selected Answer

Responses

2 Replies
Mark as answer
Nafisul Islam Kiron

It appears that the connection between the devices are not properly closed. Try to close the connection before the app closes on either side.

Duzca

You were right! I think the main problem was I hadn't set the callback on the watch using sap_peer_agent_set_service_connection_terminated_cb(). I've started from scratch, following closely the source files from the Samsung tutorial and now it works.

Thank you very much!