BLE Uart,how to sent out faster after connected()

hello

NCS2.0.2/2.3.0, vscode

i add a fun as follow:
void PutToBleSend()
{
    struct uart_data_t *buf = k_malloc(sizeof(struct uart_data_t));
    if (buf) {
        sprintf(buf->data, "KEY-003");
        buf->len = strlen(buf->data);
         k_fifo_put(&fifo_uart_rx_data, buf);
    } else {
        printk("[log] No buffer\n");
        return;
    }
}
 
and call it in 
static void connected(struct bt_conn *conn, uint8_t err);
but bt_nus_send()  will return -128 in void ble_write_thread(void);
log:
No ATT channel for MTU 24
No buffer available to send notification
wait 2 second,  bt_nus_send() will send ok.
  
1.How can data be sent out faster after connected()? had Paired;
2.How to active creat a bounds.(slave send pairing to android nrf_ToolBox app)
3.How to know has paired? after bt_conn_auth_passkey_confirm()
  
 Best regards
  • Hi!

    Take a look at how the throughput sample is configured. That sample is configured for optimizing BLE throughput.

    https://github.com/nrfconnect/sdk-nrf/blob/v2.3.0/samples/bluetooth/throughput/prj.conf

  • thanks for reply,

    tow questions:

    1.is there a function for know has paired? 

    2.nrf52820 system off take 36uA, how to reduce power consumption? see SCH as follow:

    static int disable_ds_1(const struct device *dev)
    {
        ARG_UNUSED(dev);
        pm_policy_state_lock_get(PM_STATE_SOFT_OFF);// NCS2.0.0+
        return 0;
    }
    SYS_INIT(disable_ds_1, PRE_KERNEL_2, 0);

    void go_system_off(char n)
    {
        printk("%s system off (%d)\n", CONFIG_BOARD,n);
        // Configure to generate PORT event (wakeup) on button 1 press.
        nrf_gpio_cfg_input(NRF_DT_GPIOS_TO_PSEL(DT_NODELABEL(button0), gpios),NRF_GPIO_PIN_NOPULL);
        nrf_gpio_cfg_sense_set(NRF_DT_GPIOS_TO_PSEL(DT_NODELABEL(button0), gpios),NRF_GPIO_PIN_SENSE_LOW);

        const struct pm_state_info si = {PM_STATE_SOFT_OFF, 0, 0};
        pm_state_force(0, &si);//1.9.99+
        k_msleep(100);
    }

      

    Best regards

  • yoyou said:
    1.is there a function for know has paired? 

    If you want to know if a pairing procedure was completed, you can register authentication information callbacks

    Snippet:

    static void pairing_complete(struct bt_conn *conn, bool bonded)
    {
    LOG_INF("Pairing completed: %s, bonded: %d", log_addr(conn), bonded);
    }
    
    static void pairing_failed(struct bt_conn *conn, enum bt_security_err reason)
    {
    LOG_INF("Pairing failed conn: %s, reason %d %s", log_addr(conn), reason,
    bt_security_err_to_str(reason));
    }
    
    
    
    
    
    static struct bt_conn_auth_info_cb conn_auth_info_callbacks = {
    .pairing_complete = pairing_complete,
    .pairing_failed = pairing_failed
    };
    
    
    
    
    
    err = bt_conn_auth_info_cb_register(&conn_auth_info_callbacks);
    if (err) {
    printk("Failed to register authorization info callbacks.\n");

    yoyou said:

    2.nrf52820 system off take 36uA, how to reduce power consumption? see SCH as follow:

    This seems like a new unrelated question. Please open a new case for the power consumption question.

Related