Bluetooth configuration disabled sensor trigger

Hi Nordic,

when I enable the Bluetooth configuration, the sensor trigger stop to work. when I comment the Bluetooth configuration, the sensor trigger back to work.

I recorded the screen as below:

the expected result is the Bluetooth configuration will not have any negative effect to the function already developed.

Parents
  • Hi Scott, 
    I'm not sure if you need CONFIG_BT_HCI=y. If you simply do:
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y

    Would it work ?

    Also please check if there is any timing issue with your sensor that the trigger stopped working ? Maybe you can check the SPI lines to see if there is any activity ? 

  • Hi Hung,

    It is same if ONLY enable BT and BT_PERIPHERAL, I will ckeck if SPI registers can be read properly after BT enabled in a polling loop.

    How to check if there is any timing issue with the sensor that the trigger stopped working ?

  • I would suggest to use a logic analyzer and hook it on the SPI lines to see if there is any activity. Does the CPU hang or only the SPI triggering function doesn't work ? If you initialize bluetooth would Bluetooth works as expected ? 

  • Hi Hung,

    I did not get a analyzer yet, but it seems not only sensor trigger effected, it seems the whole sensor was effected, because even in the main() while loop the sensor data can not be got. but the other sensor on the other SPI was NOT effected. 

    The CPU did not hang, because console can output log in while loop in main().

    If I initialize bluetooth, Bluetooth works as expected except the a error will raise when send byte more than 24 bytes, but it is ok when send only 20 bytes.

    the eroor log can be seen MTU 27:

    00> [00:01:22.663,757] <wrn> bt_att: No ATT channel for MTU 27
    00> [00:01:22.663,757] <wrn> bt_gatt: No buffer available to send notification
    00> Error, unable to send notification

    For the BLE max length to send and receive I see already defined as 240, but did not seen where used this number, send 24 bytes will get error.

    #define MAX_TRANSMIT_SIZE 240
        uint8_t data_rx[MAX_TRANSMIT_SIZE];
        uint8_t data_tx[MAX_TRANSMIT_SIZE];
    
    
    int my_service_init(void)
    {
        int err = 0;
       
        memset(&data_rx, 0, MAX_TRANSMIT_SIZE);
        memset(&data_tx, 0, MAX_TRANSMIT_SIZE);
        
        return err;
    }
     

    /* LED Button Service Declaration and Registration */
    BT_GATT_SERVICE_DEFINE(my_service,
        BT_GATT_PRIMARY_SERVICE(BT_UUID_MY_SERVICE),
        BT_GATT_CHARACTERISTIC(BT_UUID_MY_SERVICE_RX,
                        BT_GATT_CHRC_WRITE | BT_GATT_CHRC_WRITE_WITHOUT_RESP,
                        BT_GATT_PERM_READ | BT_GATT_PERM_WRITE, 
                        NULL, on_receive, NULL),
        BT_GATT_CHARACTERISTIC(BT_UUID_MY_SERVICE_TX,
                        BT_GATT_CHRC_NOTIFY,
                        BT_GATT_PERM_READ,
                        NULL, NULL, NULL),
        BT_GATT_CCC(on_cccd_changed,
                BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
    );

    The BLE code I written was followed by Bluetooth low energy Services, a beginner's tutorial

  • Hi Scott, 
    The tutorial you quoted was very old and it's for the legacy nRF5 SDK not NRF Connect SDK. 

    I would suggest to follow this or this.

    I suspect a change in timing may cause an issue with your SPI sensor. A logic analyzer would really help to find what could be wrong. 
    My understanding is that the SPI sensor would require some commands before it can provide the trigger/interrupt ? Please double check to see if the command(s) is sent. 

    Regarding your question about the MTU size, you would need to configure CONFIG_BT_CTLR_DATA_LENGTH_MAX, CONFIG_BT_BUF_ACL_RX_SIZE and CONFIG_BT_BUF_ACL_TX_SIZE. I would suggest to have a look at the \nrf\samples\bluetooth\throughput example. 

  • Hi Hung,

    when I hook the logic analyzer on the SPI lines, I can see the SPI send data to sensor are correct whatever the Bluetooth subsystem is enabled or not. the problem is when the Bluetooth configuration added in prj.conf file, the sensor does not response, the data get always 0.

    the SPI activity when Bluetooth config NOT added: 

    the SPI activity when Bluetooth config added:

    for the Bluetooth, the link gave is wrong, the guide I followed is exactly you sugged in last post. for the MTU limitation, I added the  CONFIG_BT_CTLR_DATA_LENGTH_MAX, CONFIG_BT_BUF_ACL_RX_SIZE and CONFIG_BT_BUF_ACL_TX_SIZE. the problem is same.

Reply
  • Hi Hung,

    when I hook the logic analyzer on the SPI lines, I can see the SPI send data to sensor are correct whatever the Bluetooth subsystem is enabled or not. the problem is when the Bluetooth configuration added in prj.conf file, the sensor does not response, the data get always 0.

    the SPI activity when Bluetooth config NOT added: 

    the SPI activity when Bluetooth config added:

    for the Bluetooth, the link gave is wrong, the guide I followed is exactly you sugged in last post. for the MTU limitation, I added the  CONFIG_BT_CTLR_DATA_LENGTH_MAX, CONFIG_BT_BUF_ACL_RX_SIZE and CONFIG_BT_BUF_ACL_TX_SIZE. the problem is same.

Children
Related