Good Morning,
I started with example ble_app_hids_keyboard for nrf52840 with nRF5_SDK_17.1.0 and I added uart_init() function to use UARTE0 and I modified uart_event_handle() for received a message "UART_OK" when I received on the rx pin an character, this works quite. My issue I want to connect 2 smartphones with HID Keyboard.
When I connect me to smarphone 1 the example HID keyboard is OK. But when I disconnect to smartphone "1" and I want to connect to smartphone "2" the nrf52840 is not discoveable and I can't to connect to smartphone "2". The nrf52840 indicates BSP_INDICATE_ADVERTISING_WHITELIST (LED 1 is blinking fast for period 1 sec). For our product in development with nrf52840 I can to use only UART signals RX(pin 8) / TX (pin 6), I don't have signals buttons 1 and buttons 2 as example:
During advertising or scanning:
- Button 1: Sleep (if not also in a connection)
- Button 2 long push: Turn off whitelist.
During sleep:
- Button 1: Wake up.
- Button 2: Wake up and delete bond information.
During connection:
- Button 1 long push: Disconnect.
- Push and release on all buttons: Application-specific.
the only solution found is after disconnecting from the phone 1 I must during advertising "LED 1 is blinking fast for period 1 sec" push Button 1 for sleep and during sleep push Button 2 for delete bond information ! I would like to know to make to connect 2 smartphones or other host peripheral (tablet, computer..) witthout clear bond information ?
Can we have a list of multiple hosts in nrf52840 and each host can to connect to nrf52840 ?
To make simple smartphone "1" connected HID Keyboard and I disconnect me and I connect me to the next smartphone in HID Keyboard.
Thank you help
Alexandre
/**@brief Function for handling app_uart events. * * @details This function will receive a single character from the app_uart module and append it to * a string. */ /**@snippet [Handling the data received over UART] */ void uart_event_handle(app_uart_evt_t * p_event) //$at_06_04_22 { uint8_t message[UARTE_MAX_DATA_LEN] = "UART OK"; uint8_t i; static uint8_t data_array[UARTE_MAX_DATA_LEN]; static uint8_t index = 0; uint32_t err_code; switch (p_event->evt_type) { case APP_UART_DATA_READY: UNUSED_VARIABLE(app_uart_get(&data_array[index])); for (i = 0; i < strlen((const char*)message); i++) { app_uart_put(message[i]); } break; case APP_UART_COMMUNICATION_ERROR: APP_ERROR_HANDLER(p_event->data.error_communication); break; case APP_UART_FIFO_ERROR: APP_ERROR_HANDLER(p_event->data.error_code); break; default: break; } } /**@snippet [Handling the data received over UART] */ /**@brief Function for initializing the UART module. */ /**@snippet [UART Initialization] */ static void uart_init(void) { uint32_t err_code; app_uart_comm_params_t const comm_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_DISABLED, .use_parity = false, #if defined (UART_PRESENT) .baud_rate = NRF_UART_BAUDRATE_115200 #else .baud_rate = NRF_UARTE_BAUDRATE_115200 #endif }; APP_UART_FIFO_INIT(&comm_params, UART_RX_BUF_SIZE, UART_TX_BUF_SIZE, uart_event_handle, APP_IRQ_PRIORITY_LOWEST, err_code); APP_ERROR_CHECK(err_code); } /**@snippet [UART Initialization] */ /**@brief Function for application main entry. */ int main(void) { bool erase_bonds; // Initialize. uart_init(); log_init(); timers_init(); buttons_leds_init(&erase_bonds); power_management_init(); ble_stack_init(); scheduler_init(); gap_params_init(); gatt_init(); advertising_init(); services_init(); sensor_simulator_init(); conn_params_init(); buffer_init(); peer_manager_init(); // Start execution. NRF_LOG_INFO("HID Keyboard example started."); timers_start(); advertising_start(erase_bonds); // Enter main loop. for (;;) { idle_state_handle(); } }