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

how to peripheral get the services of the central #121

Open
arif-ozcan opened this issue May 28, 2023 · 4 comments
Open

how to peripheral get the services of the central #121

arif-ozcan opened this issue May 28, 2023 · 4 comments

Comments

@arif-ozcan
Copy link

my use scenario is:

1- start advertising
2- connect to advertising device through nRF Connect from mobile
3- get custom client services of the central device (mobile)

I cannot access the services of the central devices from my advertising-peripheral device. A Client instance always wants to connect to the advertised device.

Please let me know, Am i missing any point ? If not, is there any example to cover my scenario ?

Thanks in Advance !

@h2zero
Copy link
Owner

h2zero commented May 28, 2023

Hello, I can't think of any way to do this currently. It could be done with some significant changes to the code, I do not have time for doing that however. If you'd like to explore this and submit a PR I'd be more than happy to accept it.

@arif-ozcan
Copy link
Author

Hi, thanks for the quick reply.

Actually, i have started some modification on the code yesterday and could get service and characteristics by uuid. I hope i submit a PR on next days after a few test.

int NimBLEServer::handleGapEvent(struct ble_gap_event *event, void *arg)
{
    NIMBLE_LOGD(LOG_TAG, ">> handleGapEvent: %s", NimBLEUtils::gapEventToString(event->type));

    int rc = 0;
    NimBLEConnInfo peerInfo;
    NimBLEServer *pServer = NimBLEDevice::getServer();
    NimBLEClient *pClient = (NimBLEClient *)arg; // arg pointer is not used before in this callback. 
...

...

pClient->setConnID(event->connect.conn_handle); // should be set connID for retrieveServices()
pServer->m_pServerCallbacks->onConnect(pServer, pClient, peerInfo); // a pointer of client instance in addition to server instance
}

@h2zero
Copy link
Owner

h2zero commented May 30, 2023

Interesting approach, glad to see you're making progress. Happy to review when you're ready.

@finger563
Copy link

@arif-ozcan Did you end up making a fork with the changes needed for this?

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

3 participants