sd_ble_gap_tx_power_set() failed with errCode 0x3004

What is meaning of error code 0x3004?

The following is source code of calling sd_ble_gap_tx_power_set().

int _gapTxPowerSet(const int8_t txPwr) {
    ret_code_t errCode;
    errCode = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, 0, txPwr);
    if (errCode != NRF_SUCCESS) {
        NRF_LOG_WARNING("sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, 0, %d) failed, errCode=0x%x", txPwr, errCode);
        return ERROR_GAP_TX_POWER_FAIL;
    }

    errCode = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_CONN, 0, txPwr);
    if (errCode != NRF_SUCCESS) {
        NRF_LOG_WARNING("sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_CONN, 0, %d) failed, errCode=0x%x", txPwr, errCode);
        return ERROR_GAP_TX_POWER_FAIL;
    }

    return 0;
}

The following is log messages of nRF52832 device.

<warning> app: sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, 0, -20) failed, errCode=0x3004

Parents
  • Hi,

    0x3004 here is BLE_ERROR_INVALID_ADV_HANDLE, so this means that you have provided an invalid handle value to sd_ble_gap_tx_power_set(). You call this function twice, both for a connection, and for the advertising role. For a connection, you need to pass the connection handle of an active connection. And for advertising, you need to pass the advertising set handle that you got from the call to sd_ble_gap_adv_set_configure(). From the code you have posted it does not seem like you have any of these yet, and in that case this cannot be set (it is premature).

Reply
  • Hi,

    0x3004 here is BLE_ERROR_INVALID_ADV_HANDLE, so this means that you have provided an invalid handle value to sd_ble_gap_tx_power_set(). You call this function twice, both for a connection, and for the advertising role. For a connection, you need to pass the connection handle of an active connection. And for advertising, you need to pass the advertising set handle that you got from the call to sd_ble_gap_adv_set_configure(). From the code you have posted it does not seem like you have any of these yet, and in that case this cannot be set (it is premature).

Children
Related