Connect to Generic Access Service with SDK 17.1.0

From the examples of SDK 17.1.0 (I'm Not using Zephyr), I'm trying to connect to a beacon's Generic Access Service, so I can read the characteristic 0x2A00 and then read it's name. But I'm not able to even connect to it yet.

I scanned the beacon and the service of this access service is: 00001800-0000-1000-8000-00805f9b34fb.

How can I achieve that?

Below is my code. 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
static ble_uuid_t const m_nus_uuid =
{
.uuid = 0x2A00,
.type = BLE_UUID_TYPE_BLE
};
static ble_gap_scan_params_t const m_scan_param =
{
.active = 0x01,
.interval = NRF_BLE_SCAN_SCAN_INTERVAL,
.window = NRF_BLE_SCAN_SCAN_WINDOW,
.filter_policy = BLE_GAP_SCAN_FP_ACCEPT_ALL,
.timeout = SCAN_DURATION,
.scan_phys = BLE_GAP_PHY_1MBPS,
};
static void db_discovery_init(void)
{
ble_db_discovery_init_t db_init;
memset(&db_init, 0, sizeof(ble_db_discovery_init_t));
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Parents
  • Hi!

    But I'm not able to even connect to it yet.

    Fullscreen
    1
    2
    3
    4
    5
    err_code = nrf_ble_scan_filter_set(&m_scan, SCAN_UUID_FILTER, &m_nus_uuid);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_ble_scan_filters_enable(&m_scan, NRF_BLE_SCAN_UUID_FILTER, false);
    APP_ERROR_CHECK(err_code);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    You are filtering on NUS UUID, but the beacon does not have the NUS UUID.

    so I can read the characteristic 0x2A00 and then read it's name.

    See this post on how to do that:  RE: Reading the central device name (smart phone) in nRF52DK(Peripheral) and printing on the terminal 

  • You are filtering on NUS UUID, but the beacon does not have the NUS UUID.

    My beacon do not have an connectable UUID? Sorry I didn't get it.

    I was able to connect to the beacon via it's MAC address, but for my development that is not useful. I should try to connect to any beacon of this type that is around, so I would not know all MAC address to connect to. After I connect to any nearby beacon, than I'd read it's name and so my program logic would start.

  • From the screenshot, the beacon seem to only have the Generic Access Service, and don't have e.g. the NUS service.

    A BLE advertiser, can advertise different kind of data. e.g.  Incomplete/Complete UUID list of available services, Shortened/Complete Local Name, Tx Power Level, Manufacturer Specific Data, etc. If you want to find "your beacon" you need to advertise something that is unique for your beacons.

Reply
  • From the screenshot, the beacon seem to only have the Generic Access Service, and don't have e.g. the NUS service.

    A BLE advertiser, can advertise different kind of data. e.g.  Incomplete/Complete UUID list of available services, Shortened/Complete Local Name, Tx Power Level, Manufacturer Specific Data, etc. If you want to find "your beacon" you need to advertise something that is unique for your beacons.

Children
  • What I mean is, since I know my beacon is connectable, and suppose it has only the Generic Access Service, how can I connect to it and then read the device name in the UUID characteristic 0x2A00?

    I saw the link you attached, but since I'm new to Ble and nordic, it still lacks informations for me.

    What I did here was to set "init_scan.connect_if_match = false", and then in the BLE_GAP_EVT_ADV_REPORT case inside the callback of the event handler, I could see my beacon MAC and other informations, but I don't know how to proceed to connect to it and read that characteristic.

     

  • Could you post a screenshot on how the advertising data looks like for the beacon, e.g. using nRF Connect for mobile ?
    Maybe there is some information apart from the MAC address that you can use to trigger a connect on.

  • Sure. This image is from nRF Connect:

  • That's after you have connected, and done service discovery.

    You can view the advertisement data in the "Scanner" tab (make sure you disconnect from the device)

  • I was able to read the device name as I wanted, but now, when the beacon shuts off the connection or when I try to disconnect by code, my device reboots. I have removed all APP_ERROR_CHECK but it still reboots. 
    Any idea of what can be happening?