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

Question - Can a device be a BLE SERVER and a BLE CLIENT at same time #103

Open
mitchjs opened this issue Oct 3, 2022 · 5 comments
Open

Comments

@mitchjs
Copy link

mitchjs commented Oct 3, 2022

@h2zero , my existing project working great, then the user asked me if they could add a BLE remote(physical device)
to it, i dont got the remote YET, but im guessing its a server probably even BLE HID. i always see "Client or Server" never both options

thanks
mitch

@h2zero
Copy link
Owner

h2zero commented Oct 3, 2022

Sure you can do that. Works just as you would expect, create a client instance and a server instance and give it a go.

@mitchjs
Copy link
Author

mitchjs commented Oct 3, 2022

ok, when i get this remote deally in my hand, ill scan it and see what services it offers...

thanks!!!

@arif-ozcan
Copy link

Is there any example for this operation ? I cannot access to the client services of the central through peripheral.

@michaelboeding
Copy link

I'm also trying to get this to work and I'm encountering a crash. My operation is the client starts scanning and then I try to setup the server after. And I immediately get a crash.

`
static inline ble_npl_error_t
ble_npl_mutex_pend(struct ble_npl_mutex *mu, ble_npl_time_t timeout)
{
return npl_freertos_mutex_pend(mu, timeout);
}

rc = ble_npl_mutex_pend(&ble_hs_mutex, 0xffffffff);

ble_hs_lock_nested();

#if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
/* STATIC / NimBLEServer NimBLEDevice::createServer() {
if(NimBLEDevice::m_pServer == nullptr) {
NimBLEDevice::m_pServer = new NimBLEServer();
ble_gatts_reset();
ble_svc_gap_init();
ble_svc_gatt_init();
}

return m_pServer;

} // createServer

ble_gatts_reset();

`

That's the backtrace. Seems to fail on the createServer call. Any advice? @h2zero

@michaelboeding
Copy link

Update on this - I think I got this working. You need to create the server first before trying to create the client. I was doing it the other way around.

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

4 participants