I have the devlopment kit pca 10028 with nrf51422
Thank you very much for the answer. MC
I have the devlopment kit pca 10028 with nrf51422
Thank you very much for the answer. MC
do you want to use BSP library for this? or is it ok if you can just use the nrf_gpio_pin_write API and control the LED_1 which is connected to pin number 21
you should initialize your LED like below
static void leds_init(void)
{
nrf_gpio_cfg_output(CENTRAL_CONNECTED_LED);
nrf_gpio_pin_set(CENTRAL_CONNECTED_LED); // this will switch OFF led on pca10028
}
Then when you get connected and disconnected events then you should set the LED state again in the on_ble_evt() function in the SDK ble_peripheral examples (assuming that your device is peripheral)
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
NRF_LOG_INFO("Connected\r\n");
// err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
// APP_ERROR_CHECK(err_code);
nrf_gpio_pin_clear(CENTRAL_CONNECTED_LED); // this will turn on the LED on pca10028
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
break; // BLE_GAP_EVT_CONNECTED
case BLE_GAP_EVT_DISCONNECTED:
NRF_LOG_INFO("Disconnected\r\n");
// err_code = bsp_indication_set(BSP_INDICATE_ALERT_OFF);
// APP_ERROR_CHECK(err_code);
nrf_gpio_pin_set(CENTRAL_CONNECTED_LED); // this will turn OFF the LED on pca10028
m_conn_handle = BLE_CONN_HANDLE_INVALID;
you should initialize your LED like below
static void leds_init(void)
{
nrf_gpio_cfg_output(CENTRAL_CONNECTED_LED);
nrf_gpio_pin_set(CENTRAL_CONNECTED_LED); // this will switch OFF led on pca10028
}
Then when you get connected and disconnected events then you should set the LED state again in the on_ble_evt() function in the SDK ble_peripheral examples (assuming that your device is peripheral)
static void on_ble_evt(ble_evt_t * p_ble_evt)
{
uint32_t err_code;
switch (p_ble_evt->header.evt_id)
{
case BLE_GAP_EVT_CONNECTED:
NRF_LOG_INFO("Connected\r\n");
// err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
// APP_ERROR_CHECK(err_code);
nrf_gpio_pin_clear(CENTRAL_CONNECTED_LED); // this will turn on the LED on pca10028
m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
break; // BLE_GAP_EVT_CONNECTED
case BLE_GAP_EVT_DISCONNECTED:
NRF_LOG_INFO("Disconnected\r\n");
// err_code = bsp_indication_set(BSP_INDICATE_ALERT_OFF);
// APP_ERROR_CHECK(err_code);
nrf_gpio_pin_set(CENTRAL_CONNECTED_LED); // this will turn OFF the LED on pca10028
m_conn_handle = BLE_CONN_HANDLE_INVALID;