This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Communication between master and slave

Hi, i have the below queries:

In our project we are using multiple masters and multiple slaves, in that each slave is dedicated to a single master.

for ex: we are having 4 masters(M1,M2,M3,M4) and 4 slaves(S1,S2,S3,S4), in that S1 will be dedicated to M1 only, S2->M2, S3->M3 and S4->M4.

whenever we run the Master program it will scan for the slaves, which are available within the range and will auto connect to the nearest slave but my question is how can i be able to select the particular slave and discard the others?

for ex: When M1 starts scanning all the 4slaves i.e.. (S1, S2, S3 & S4) will going to be advertise, and connect to the random slave but as per our requirement M1 master has to connect the S1 Slave only and neglect the others.

here we are using ble_central(Master) and ble_app_uart(slave) programs path for the same is as below

MASTER : nRF5_SDK_12.3.0_d7731ad(1)\nRF5_SDK_12.3.0_d7731ad
examples\ble_central\ble_app_uart_c\pca10028\s130\arm5_no_packs

SLAVE : nRF5_SDK_12.3.0_d7731ad(1)\nRF5_SDK_12.3.0_d7731ad
examples\ble_peripheral\ble_app_uart\pca10028\s130\arm5_no_packs

please confirm ASAP!!

Thanks in advance :)

  • The unmodified central example will not connect to the nearest peripheral, it will try to connect to the device that sent out the first advertisement it received.

    If you want M1 to only connect to S1 you need to configure M1 (and S1) so that it can recognize S1 advertisement. Unmodified the example only looks for the NUS UUID in the advertisement. See how BLE_GAP_EVT_ADV_REPORT is handled inside on_ble_evt(). The Bluetooth address of the slave is one way of doing it. Or use different UUIDs. Or add a device name, or some manufacturer specific data.

  • Hi thanks for the information. well lets say if change the Device name of the slave then how will Master detects the particular slave and connect it. do i need to make any changes in the master program?

    How and where to change in master program? . like if master detects particular name the only pair otherwise dont connect how to configure that?

  • Then the master will look at the device name in the advertisement from the slave, recognize it, and send a connection request to it. Yes, you need to make changes, as I said currently it looks for the NUS UUID, not a device name. See how BLE_GAP_EVT_ADV_REPORT is handled inside on_ble_evt().

Related