This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Glucose Service(Central)

s130, nRF5_SDK_12.1.0_0d23e2a, SoftDevice 8_9_0.

I want to use the Central Glucose Service, how do i modify the "ble_central/ble_app_hrs_c" example code?

int main(void) { bool erase_bonds;

// Initialize.
APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);

uart_init();
buttons_leds_init(&erase_bonds);
ble_stack_init();
peer_manager_init(erase_bonds);
if (erase_bonds == true)
{
    printf("Bonds erased!\r\n");
}    

db_discovery_init();

nus_c_init();
gls_init();

whitelist_load();

scan_start();

for (;;)
{

}

}

In the "static void ble_stack_init(void)", when call "softdevice_ble_evt_handler_set(ble_evt_dispatch)" function, I add ble_gls_on_ble_evt(&m_ble_gls, p_ble_evt) in the ble_evt_dispatch, the ble_gls_on_ble_evt function is in components\ble\ble_services\ble_gls\ble_gls.c

Then, in the db_discovery_init(), call ble_db_discovery_init(db_disc_handler), In db_disc_handler, HRM Service has ble_hrs_on_db_disc_evt in the ble_hrs_c.c, UART Service has ble_nus_c_on_db_disc_evt in the ble_nus_c.c, but Glucose Service don't have similar function in ble_gls.c and ble_gls_db.c, what function have to add?

Last, the gls_init(void) function: static void gls_init(void) { ble_gls_init_t gls_init_t;

gls_init_t.evt_handler = ble_gls_evt_handler;

uint32_t err_code = ble_gls_init(&m_ble_gls, &gls_init_t);
APP_ERROR_CHECK(err_code);

}

static void ble_gls_evt_handler(ble_gls_t * p_ble_gls, ble_gls_evt_t * p_ble_gls_evt) { switch (p_ble_gls_evt->evt_type) { case BLE_GLS_EVT_NOTIFICATION_ENABLED:

        break;

    case BLE_GLS_EVT_NOTIFICATION_DISABLED:

        break;
        
    default:
        break;
        
}

}

how do i modify the p_ble_gls_evt->evt_type case?

This code register UART and Glucose Service with bonds function, UART Service can works, the Glucose Service how to modify? Thanks

  • Unfortunately we do not have a client interface for GLS. The files you are looking at is the service interface for the GLS server. This means you have to look at the GLS profile specification to see how to implement this. But, yes. The first step is to add the discovery module so you can perform a service discovery of the gls services. The discovery procedure can be handled similar to what is done in the HRS client example. This means you have to register the GLS UUID's in the discovery module and handle the discovery events in the gls handler. Note that eventually you should also qualify your implementation using the Bluetooth SIG PTS tool.

Related