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

How to connect to specified host

Hello,I am using SDk14.1.How can I use NRF52832 connect to a specified host?I already know the MAC address of the host but have never connected to it。Can NRF52832 initiate a connection matching request as a peripheral?Is directional broadcasting a viable option?

  • Hi,

    If this is a new project then I highly recommend using the latest version of our SDK (currently nRF5 SDK v16,0,0) and not older versions of the SDK. This is both because of bugfixes, added features, support for new features and support for newer SoftDevices.

    By "host" do you mean a BLE peripheral? In BLE, there are two devices involved in a connection. One is peripheral, and the other is central. The peripheral starts by advertising. The central scans for advertisements, and when receiving advertisements from a peripheral it may initiate a connection.

    There are several mechanisms for getting two devices to connect to each other. The peripheral can do directed advertisement, where it advertises to one specific central only (by using the central's BLE address.) The peripheral can also use a whitelist, in order only to accept incoming connections from a specific BLE address. On the central side, the central can use a whitelist in order to only attempt to connect to a peripheral of a specific BLE address. The central can also choose whether to connect based on the contents of the advertisement.

    For getting familiar with the concepts in BLE and how to advertise/set up a connection, I recommend having a look at our tutorials. Bluetooth low energy Advertising, a beginner's tutorial may be a good starting point for learning about advertisements.

    Regards,
    Terje

  • Many thanks for your adviceI'm really a beginner.I'll take a look at your tutorial in a minute.

    The "host" means a BLE central.I use Android devices as the central and NRF52832 as the peripheral.

    I wonder if it is possible for NRF52832 to initiate a connection or pair request to an unpaired Android devices without a special APP and make the Android devices pop up a pair request window?

    I want to use the NRF52832 to make a Bluetooth scanning device.I hope that the Bluetooth scanning device can actively connect to the Android device after scanning the code to get the Android device's MAC address.Can you give me some advice?

  • Hi,

    In BLE, the central is the one doing the scanning. I guess it could be possible for a peripheral to first act in the observer role (that is, scanning for other devices), and when it sees another device it then starts directed advertising to that specific device. BUT: That requires the other device to advertise, which centrals, generally do not... So for that you would need a special app on the Android phone anyway, which is what you do not want.

    So, no. I do not think what you describe is possible, at least not in the way that you present it. Mainly because in BLE it is the central who initiates the connection, not the peripheral. (This is true for all BLE devices.)

    To recap how BLE connection works:

    • Peripheral advertises.
    • Central scans.
    • When central receives an advertisement, the central may decide to send a connection request to the peripheral that sent the advertisement.
    • When peripheral receives a connection request, the peripheral may decide to accept the connection.

    Directed advertising is typically used to quickly reconnect to a previous connection (typically when a connection times out, directed advertising can be used to quickly reestablish the connection.) Directed advertising can also be used by hard coding or otherwise prime the device with a given BLE address that it should connect to.

    What you can do, is to advertise in general, and when you get a connection request you decide whether you want to accept the connection or not.

    Regards,
    Terje

Related