示例#1
0
/**
* @brief Softdevice event handler 
*/
void SD_EVT_IRQHandler(void)
{
    rbc_mesh_sd_irq_handler();
    
    ble_evt_t ble_evt;
    uint16_t len = sizeof(ble_evt);
    while (sd_ble_evt_get((uint8_t*) &ble_evt, &len) == NRF_SUCCESS)
    {
        nrf_adv_conn_evt_handler(&ble_evt);
    }
}
static void uart_init(void)
{
#ifdef USE_UART_LOGGING
  int status = NRF_SUCCESS;
  const app_uart_comm_params_t uart_params = {
    .rx_pin_no = RX_PIN_NUMBER,
    .tx_pin_no = TX_PIN_NUMBER,
    .rts_pin_no = RTS_PIN_NUMBER,
    .cts_pin_no = CTS_PIN_NUMBER,
    .flow_control = APP_UART_FLOW_CONTROL_ENABLED,
    .use_parity = false,
    .baud_rate = UART_BAUDRATE_BAUDRATE_Baud38400
  };
  APP_UART_FIFO_INIT(&uart_params, UART_RX_BUF_SIZE, UART_TX_BUF_SIZE, uart_event_handler, APP_IRQ_PRIORITY_LOW, status);
  APP_ERROR_CHECK(status);
#endif
}

static void uart_putstring(const uint8_t * string)
{
#ifdef USE_UART_LOGGING
  for(int i = 0; string[i] != 0; ++i)
    app_uart_put(string[i]);
#endif
}

/**
* Interrupt handler for Softdevice events
*/
void SD_EVT_IRQHandler(void)
{
  uint32_t evt;
  ble_evt_t ble_evt;
  uint16_t len;

  while(sd_evt_get(&evt) == NRF_SUCCESS)
  {
    btle_hci_adv_sd_evt_handler(evt);
  }

  while (sd_ble_evt_get((uint8_t *) &evt, &len) == NRF_SUCCESS)
  {
    nrf_adv_conn_evt_handler(&ble_evt);
  }
}
示例#3
0
文件: main.c 项目: 196510921/mesh
/**@brief BLE Stack event interrupt
 *        Triggered whenever an event is ready to be pulled
 */
void SD_EVT_IRQHandler (void)
{
    uint32_t evt;
    ble_evt_t ble_evt;
    uint16_t len;

    while (sd_evt_get(&evt) == NRF_SUCCESS)
    {
        g_evt = evt;

        switch (evt)
        {
        case NRF_EVT_RADIO_SESSION_IDLE:
        case NRF_EVT_RADIO_BLOCKED:
            /* Request a new timeslot */
            ASSERT (btle_scan_enable_set (scan_enable) == BTLE_STATUS_CODE_SUCCESS);
            break;

        case NRF_EVT_RADIO_SESSION_CLOSED:
            break;

        case NRF_EVT_RADIO_SIGNAL_CALLBACK_INVALID_RETURN:
            ASSERT(false);
            break;

        case NRF_EVT_RADIO_CANCELED:
            ASSERT (btle_scan_enable_set (scan_enable) == BTLE_STATUS_CODE_SUCCESS);
            break;

        default:
            /* This should not happen */
            __LOG ("%s: Program failure, undefined event = %d", __FUNCTION__, evt);
            ASSERT(false);
        }
    }

    while (sd_ble_evt_get((uint8_t *) &evt, &len) == NRF_SUCCESS)
    {
        nrf_adv_conn_evt_handler(&ble_evt);
    }
}