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

Add attachClientConnection method as a server only alternative to connect #450

Merged
merged 1 commit into from Jan 9, 2023

Conversation

CyDragon80
Copy link
Contributor

@CyDragon80 CyDragon80 commented Dec 22, 2022

This is based in part on work from this PR #231 which references this issue #229
I have endeavored to cover this use case with the minimum possible code disruption.
The current behavior should be exactly the same for code using the connection back to the client. I have only added one method "attachClientConnection" which can be used as a server-only alternative to using "connect" in "onDeviceConnectedToServer". Example use shown below based on a Java version of the server example in this repo (ServerConnection extends BleManager).

@Override
public void onDeviceConnectedToServer(BluetoothDevice device) {
    String address = device.getAddress();
    Log.d(TAG, "Device connected " + address);
    ServerConnection newConnection = new ServerConnection(context);
    serverConnections.put(address, newConnection);
    newConnection.useServer(this);
    // either setup as server only or dual connection
    newConnection.attachClientConnection(device); // sets up connection server only
    //newConnection.connect(device).enqueue(); // queues connection back to client for dual connection
}

@CLAassistant
Copy link

CLAassistant commented Dec 22, 2022

CLA assistant check
All committers have signed the CLA.

@CyDragon80 CyDragon80 force-pushed the serveronly branch 3 times, most recently from 57c5655 to 541ca4d Compare December 23, 2022 02:28
@philips77
Copy link
Member

Hello,
That's a quite good idea. Thank you for the PR. I'm starting my holidays today, but will come back to you next year.
Merry Christmas!

@philips77 philips77 merged commit 34b4d70 into NordicSemiconductor:main Jan 9, 2023
@CyDragon80
Copy link
Contributor Author

Thanks for taking the PR. Any chance of this making it into a 2.6.0 alpha build in the near future? I have a scenario where a particular third party app I need to support simply refuses to work with me if I attempt a back connection to it. So far I've had to run tests with my temporary local copy of the library to get anywhere with it.

@philips77
Copy link
Member

I'm releasing it now. Just need to write some documentation here and there.

@philips77
Copy link
Member

2.6.0 final should be available soon. I just pushed it.

@CyDragon80 CyDragon80 deleted the serveronly branch March 31, 2024 14:21
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

Successfully merging this pull request may close these issues.

None yet

3 participants