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
Hello Aryan i have do it with nrf_gpio.. like this:
#define CENTRAL_CONNECTED_LED 22
static void leds_init(void)
{
nrf_gpio_cfg_output(CENTRAL_CONNECTED_LED);
nrf_gpio_pin_clear(CENTRAL_CONNECTED_LED);
while(1)
{
nrf_gpio_pin_toggle(CENTRAL_CONNECTED_LED);
nrf_delay_ms(1000);
}
}
The led now blink evry time, but i need that the led blink only when the periheral is connected.
Sorry about my english. is possible that you send me a exemple for BSP und exemple for nrf_gpio. please with exactly where i must write the code.
thank you very much mc
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;
Thank you
Maybe i have not good declare my question. It is for the exemple "ble-app Multilink central" I need that the CENTRAL-CONNECTED-LED BSP_BOARD_LED_1, toggle on "ble-app Multilink central" when case BLE_GAP_EVT_CONNECTED. And not toggle when case BLE_GAP_EVT_DISCONNECTED
When possible please as exemple for BSP und exemple for nrf_gpio Thnak you very much! MC