Connecting nRF52832 to OBDII using NUS (Issue: Receiving a response from OBDII)

Hi everyone, I'm trying to communicate with OBDII through NUS using nRF52832. I was able to initiate the connection, send commands to OBDII, and get responses on the ECUsim 2000. However, I wasn't able to get the responses sent back to nRF52832 through bluetooth.

I used the centeral ble_app_uart_c example from the SDK.

The OBDII NUS UUID is 0x0000FFF0-0000-1000-8000-00805F9B34FB

#define NUS_BASE_UUID {{0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0xEF, 0xFF, 0x00, 0x00}}
#define BLE_UUID_NUS_SERVICE 0xFFF0
#define BLE_UUID_NUS_RX_CHARACTERISTIC 0XFFF2 
#define BLE_UUID_NUS_TX_CHARACTERISTIC 0xFFF1 

For the UUID Type I used:

#define NUS_SERVICE_UUID_TYPE   BLE_UUID_TYPE_BLE

After I send commands from nRF32 to OBDII, I get the expected results on ECUsim 2000. However, these results are not sent back to nRF32!

while debugging the code, I found that IF statement of the on_hvx function (ble_nus_c.c)  is never met (always treated as FALSE), and I'm not sure why is this happening.

static void on_hvx(ble_nus_c_t * p_ble_nus_c, ble_evt_t const * p_ble_evt)
{
      // HVX can only occur from client sending.
      if ( (p_ble_nus_c->handles.nus_tx_handle != BLE_GATT_HANDLE_INVALID)
      && (p_ble_evt->evt.gattc_evt.params.hvx.handle != p_ble_nus_c->handles.nus_tx_handle)
      && (p_ble_nus_c->evt_handler != NULL))
      {
              ble_nus_c_evt_t ble_nus_c_evt;

              ble_nus_c_evt.evt_type = BLE_NUS_C_EVT_NUS_TX_EVT;
              ble_nus_c_evt.p_data = (uint8_t *)p_ble_evt->evt.gattc_evt.params.hvx.data;
              ble_nus_c_evt.data_len = p_ble_evt->evt.gattc_evt.params.hvx.len;

              p_ble_nus_c->evt_handler(p_ble_nus_c, &ble_nus_c_evt);
              printf("Client sending data.");
      }
}

Could you please help me solve this issue to get the results sent back to nRF32 through bluetooth?

Related