This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Failing to read TX_POWER on Beacon

Hello, this is my first post in here.

I'm trying to read the TX_POWER information of my beacons.
I'm able to read this info using the nRFConnect app on my phone no problem, but when I'm using the board I'm not being able to.

void bleEvtHandler(ble_evt_t const* p_ble_evt, void* p_context) {
  uint16_t conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
  uint16_t role = ble_conn_state_role(conn_handle);

  
  if ((role == BLE_GAP_ROLE_CENTRAL) || (p_ble_evt->header.evt_id == BLE_GAP_EVT_ADV_REPORT)) {
    onBleCentralEvt(p_ble_evt);
  }
}

void onBleCentralEvt(ble_evt_t const* p_ble_evt) {
  ble_gap_evt_t const* p_gap_evt = &p_ble_evt->evt.gap_evt;

  uint8_t uuid[27];
  switch (p_ble_evt->header.evt_id) {
    case BLE_GAP_EVT_ADV_REPORT:

      printf("Advertise received :\r\n");

      memmove(uuid, p_gap_evt->params.adv_report.data.p_data, p_gap_evt->params.adv_report.data.len);

      printf("Data LEnght: %d \r\n",p_gap_evt->params.adv_report.data.len );

      printf("TX_POWER: %d\r\n", p_gap_evt->params.adv_report.tx_power);

      printf("RSSI: %d\r\n\r\n", p_gap_evt->params.adv_report.rssi);

      break;  // BLE_GAP_ADV_REPORT

    default:
      break;
  }
}


so far I'm able to get all the informations but the TX_POWER, its always 127 which I think it means invalid.

Yes I've set the TX_POWER information on the beacons and once again I can read them just fine on nRFConnect.



Thank you for your time!

Parents Reply Children
  • Hi!,
    To use that example it says that I must have DeviceFamilyPack 8.27.0 (to build it, I took a look to the code anyway)and It is deprecated, I cannot change the "Device" Component class to newer version...

    I've come here cause I was facing problems reading tx_power I had the same error, I used the ble_adv_parse but It gives me 0's & sometimes the correct txpower...

    p_ad_tx_power_data = ble_advdata_parse(p_ble_evt->evt.gap_evt.params.adv_report.data.p_data,
                                                               p_ble_evt->evt.gap_evt.params.adv_report.data.len,
                                                               BLE_GAP_AD_TYPE_TX_POWER_LEVEL);                                     
                        if(flag_rssi_start == 1)
                        {
                            if((last_txpow == -20) && (*p_ad_tx_power_data == 4))
                            {
                                flag_rssi_start = 0;
                                memset(max_rssi,-127,sizeof(max_rssi));
                                SEGGER_RTT_WriteString(0,"Started RSSI Testing");
                            }
                            last_txpow = *p_ad_tx_power_data;                               
                                       
                            sprintf(Cadena,"LastTX_PW:%d\n",*last_txpow);
                            SEGGER_RTT_WriteString(0,Cadena);

    That's the code and this is a screenshot of what I got:




Related