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

nRF8001 SetTxPower ends with DEVICE_STATE_INVALID

Hi, I've started developing some test applications for the nRF8001 to better understand all the ACI libraries and improve my knowledge of the chip.

I'm experiencing some problems with the SetTxPower command.

Basically I would like to build a program that lets me change the TX Power on the nRF8001 from my iPad (on iPad I use LightBlue app to interact with the peripheral services/characteristics).

I've configured the nRF8001 with the TX Power Service using nRFgo Studio.

The program starts and the nRF8001 starts advertising, then I'm able to connect to it and write the TX Power characteristic

On the MCU connected with the nRF8001 I received the correct value written from the iPad, but when I try to execute the lib_aci_set_tx_power(received_power_value), I get the error ACI_STATUS_ERROR_DEVICE_STATE_INVALID.

I post a little piece of code to better understand the problem:



case ACI_EVT_DATA_RECEIVED:
  switch(aci_evt->params.data_received.rx_data.pipe_number) {
  case PIPE_TX_POWER_TX_POWER_LEVEL_RX:
    // data_len = aci_evt->len - 2;
    serial.printf("TX Power received: ");
    for(i = 0; i < (aci_evt->len - 2); i++) {
      serial.printf("%.2X ", aci_evt->params.data_received.rx_data.aci_data[i]);
    }
    serial.printf("\r\n");
                                
    switch(aci_evt->params.data_received.rx_data.aci_data[0]) {
    case ACI_DEVICE_OUTPUT_POWER_MINUS_18DBM:
      lib_aci_set_tx_power(ACI_DEVICE_OUTPUT_POWER_MINUS_18DBM);
      break;
    case ACI_DEVICE_OUTPUT_POWER_MINUS_12DBM:
      lib_aci_set_tx_power(ACI_DEVICE_OUTPUT_POWER_MINUS_12DBM);
      break;
    case ACI_DEVICE_OUTPUT_POWER_MINUS_6DBM:
      lib_aci_set_tx_power(ACI_DEVICE_OUTPUT_POWER_MINUS_6DBM);
      break;
    case ACI_DEVICE_OUTPUT_POWER_0DBM:
      lib_aci_set_tx_power(ACI_DEVICE_OUTPUT_POWER_0DBM);
      break;
    }
  break;
  }
break;

case ACI_EVT_CMD_RSP:
  //If an ACI command response event comes with an error -> stop
  if (ACI_STATUS_SUCCESS != aci_evt->params.cmd_rsp.cmd_status) {
    serial.printf("ACI Error %.2X for Command: %.2X\r\n", aci_evt->params.cmd_rsp.cmd_status, aci_evt->params.cmd_rsp.cmd_opcode);
    serial.printf("System halted.\r\n");
    while (1);
  }
break;


And on the debug serial I get:


***** PROGRAM STARTED *****
lib_aci_init.. 
Evt Device Started: Setup
do_aci_setup.. 
Evt Device Started: Standby
Advertising started
Evt Connected
TX Power received: 03
ACI Status Error 83 for Command: 12
System halted.

I have seen the table 31, pag. 91 of nRF8001 Product Sheet, but I can't understand the meanings of the X on the table (the operating modes marked with the 'X' are those available or unavailable?)

Thanks for any help/suggestions.

Regards, Samuele.

Parents Reply Children
No Data
Related