Hi. I have several NRF52840's and I would like to know how I can set one up as a sort of 'server' and then all other NRF52840's (IE: 'clients') can connect to it and send data to/from the 'server'. Any advice, examples or tips would be appreciated as I've never worked with BLE before and the terminology has confused me.
As a reference, I've been looking at these examples here, but I'm confused what I should be using as a basis or starting point.
Thanks.
FEATHER NRF52840: BLUETOOTH SERVER AND CLIENTS
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- matead
- Posts: 9
- Joined: Tue Oct 26, 2021 12:31 am
- adafruit_support_mike
- Posts: 67454
- Joined: Thu Feb 11, 2010 2:51 pm
Re: FEATHER NRF52840: BLUETOOTH SERVER AND CLIENTS
The general idea will work, but there are some details that might not fit your application.
Officially, BLE splits devices into 'central' and 'peripheral' categories. The central, which corresponds to what you've called a 'server', initiates and controls all data connections. Peripherals advertise their presence, but otherwise wait for a central to connect and tell them what to do.
That makes it impossible for peripherals to open a connection to the central any time they want. They have to wait for the central to connect to them and ask for new information.
You could flip the relationships around and make the 'server' a peripheral and all the 'client' devices centrals, but then you'd deal with synchronization issues. A peripheral can only talk to one central at a time, so there's a chance one remote device would want to connect while another is already connected. Those problems can be solved statistically (for an arbitrarily low chance that a message will fail), usually at the cost of more and more delay between the time of the original message and the time the message actually gets through.
Officially, BLE splits devices into 'central' and 'peripheral' categories. The central, which corresponds to what you've called a 'server', initiates and controls all data connections. Peripherals advertise their presence, but otherwise wait for a central to connect and tell them what to do.
That makes it impossible for peripherals to open a connection to the central any time they want. They have to wait for the central to connect to them and ask for new information.
You could flip the relationships around and make the 'server' a peripheral and all the 'client' devices centrals, but then you'd deal with synchronization issues. A peripheral can only talk to one central at a time, so there's a chance one remote device would want to connect while another is already connected. Those problems can be solved statistically (for an arbitrarily low chance that a message will fail), usually at the cost of more and more delay between the time of the original message and the time the message actually gets through.
Please be positive and constructive with your questions and comments.