This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2340R5: How to properly use HCI Commands and BLE in the same project ?

Part Number: CC2340R5

Hello,

I’m using the Basic_ble project as a start project and I’m using also the HCI command to detect a Carrier wave.
the problem when I use the HCI command It mess up with ble API, which mean when I use the HCI command and then later try to advertise the system lockup …. I was able to find a workaround for some issue but there still more issues coming.

Not sure is it possible to use properly HCI and BLE together ?

this is how I implemented the CW detection (note that the HCI command and BLE advertising not working at the same time):

 

  • Start cw sampling by calling function start_CW()
  • Once the event BLEAPPUTIL_HCI_VE_EVENT_CODE is triggered we read the RSSI value of signal
  • Once BLEAPPUTIL_HCI_COMMAND_COMPLETE_EVENT_CODE triggered we close the HCI HCI_EXT_EndModemTestCmd()
  • Once HCI_EXT_END_MODEM_TEST is triggered we re init the ble handler in order to be able to advertise next time. Because somehow the HCI will mess with the BLE stack

Is what I’ve done is correct? because I still have a lot of issue, for example not able to connect to the sensor ……
is the function HCI_EXT_EndModemTestCmd enough to stop the HCI ?
do I need to re init the BLE stack again because it was corrupted by the HCI ?



void start_CW()
{
    cw_detected_flag = false;
    retval = HCI_EXT_ModemTestRxCmd(35);
}  


void CWEventHandler(uint32 event, BLEAppUtil_msgHdr_t *pMsgData)
{

    switch(event)
    {
        // Process HCI Command Complete Event case.
        case BLEAPPUTIL_HCI_COMMAND_COMPLETE_EVENT_CODE:
        {
          // Parse Command Complete Event for opcode and status.

          command_complete = (hciEvt_CmdComplete_t*) pMsgData;
          uint8_t status = command_complete->pReturnParam[0];

          // Find which command this command complete is for
          switch (command_complete->cmdOpcode)
          {
             case HCI_READ_RSSI:
             {
                if (status == SUCCESS)
                {
			
cw_detected_flag = true;


                }

                hci_status = HCI_EXT_EndModemTestCmd();

             } break; // case HCI_READ_RSSI
          }
        } break;

        case BLEAPPUTIL_HCI_VE_EVENT_CODE:
        {
          hciEvt_VSCmdComplete_t *vsdat = (hciEvt_VSCmdComplete_t *)pMsgData;

          switch(vsdat->cmdOpcode) {

              case HCI_EXT_MODEM_TEST_RX:
              {

                  // Send HCI command to read RSSI (Emits HCI_READ_RSSI event)
                  rssi_val = HCI_ReadRssiCmd(0xFFFE);

              } break;

              case HCI_EXT_END_MODEM_TEST:
              {

                  // Allow advertising to work after modem test
                status_ble_adv_init = BLEAppUtil_initAdvSet(&peripheralAdvHandle_1, &advSetInitParamsSet_1);

              } break;
          }

        } break;

    }
}