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

nRF8001 WriteDynamicData Internal Error

I am currently using version 'NRF D 8001 1429SH' as printed on the nrf8001 IC

I have already managed to successfully bond with an android phone and completed the ReadDynamicData cycle, with correct event status of ACI_STATUS_TRANSACTION_CONTINUE for sequence 1-7 and ACI_STATUS_TRANSACTION_COMPLETE where I read sequence 8. Sequences 1-7 have lengths of 27 and sequence 8 has a length of 12. I read the dynamic data and then save it on my embedded file system in a .txt file. Upon power cycle, I read from the .txt file the 8 sequences of dynamic data and attempt to start the WriteDynamicData cycle from standby mode to restore dynamic data. I can successfully call acil_encode_command_write_dynamic_data(writebuffer, 1, dyanmicdata1, 27) //seq# 1, len 27 and receive the expected CommandResponseEvent with correct Opcode for WriteDynamicData and correct Status of ACI_STATUS_TRANSACTION_CONTINUE. However, when I call acil_encode_command_write_dynamic_data(writebuffer, 2, dyanmicdata2, 27) //seq#2, len 27, I get a CommandResponseEvent with Correct Opcode for WriteDynamicData but Status of ACI_STATUS_ERROR_INTERNAL.

Why does it generate an internal error, any solutions?

Write Buffer - for data sent via SPI to nrf8001

Read Buffer - for data received via SPI from nrf8001

Here is the SPI data, debug, and the 8 dyanmic data sequenecs:

Read buffer: 04 81 03 00 02 00 00 00

BLEP Received ACI_EVT_DEVICE_STARTED event as expected

BLEP Entering standby mode

//dynamic data read from file in filesystem into which ReadDyanmicData was saved

Dyanmic Data Seq 1:04 02 03 00 08 11 00 03 06 4E 6F 50 61 69 6E 00 0A 04 00 00 00 00 00 0B 02 00 00

Dyanmic Data Seq 2:00 00 0E 01 0A 00 10 02 30 31 00 12 02 31 32 00 14 02 33 34 00 16 07 02 00 00 00

Dyanmic Data Seq 3:AA AA CC CC 00 19 00 00 1B 00 00 1C 02 00 00 00 1F 00 00 21 00 00 22 02 01 00 00

Dyanmic Data Seq 4:00 24 00 00 25 02 00 00 00 27 06 FF FF FF FF FF FF 0C 00 10 5A A4 20 38 A4 E8 00

Dyanmic Data Seq 5:E2 01 01 1D CC 5D 16 2C 4D B7 64 3D F0 10 9A 15 46 95 B6 71 0C 5B 8D 59 B1 0E 00

Dyanmic Data Seq 6:B4 F5 DC 64 00 F8 22 3E 54 3F 58 16 60 10 D9 17 86 BB 1E 23 1F C0 7E 20 1B 0D 00

Dyanmic Data Seq 7:F1 00 00 00 00 00 00 00 00 FA DD 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Dyanmic Data Seq 8:00 00 00 00 00 00 00 14 02 3A 36 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

// encoding frist WriteDyanmicData command

WriteDyanmicData sequence 1

First 27 bytes of write Buffer for Sequence1:1D 08 01 04 02 03 00 08 11 00 03 06 4E 6F 50 61 69 6E 00 0A 04 00 00 00 00 00 0B

Read buffer: 03 84 08 01 00 00 00 00

Event: ACI Event Command Response

Event Opcode: ACI_CMD WriteDyanmicData

Event Status: WriteDyanmicData Continue

// encoding second WriteDyanmicData command

WriteDyanmicData sequence 2

First 27 bytes of write Buffer for sequence 2:1D 08 02 00 00 0E 01 0A 00 10 02 30 31 00 12 02 31 32 00 14 02 33 34 00 16 07 02

Read buffer: 03 84 08 81 00 00 00 00

Event: ACI Event Command Response

Event Opcode: ACI_CMD WriteDyanmicData

Event Status: ACI_STATUS_ERROR_INTERNAL

  • UPDATE:

I have now tried to call writeDynamicData cycle with the data received directly after readDynamicData cycle completes. Without saving the data in a file or manipulating the data at all, I get the same error as above during write sequence 2.

  • So how do you tell whether a 0A or 0D that you read is intended to be data or the CRLF end-of-line marker?

    Can't your filesystem do binary files?

  • The Read: is the dynamic data itself, while the Write: is the data encoded with the WriteDyanmicData command, to be sent via SPI to the nrf8001.

    Ignorng the first 3 Bytes from the encoded Write: command [1D ,08, 01] : 1D is length of 29, 27 from sequence and 2 from #define MSG_WRITE_DYNAMIC_DATA_BASE_LEN 2 in the acilib.h file from the sdk. 08 is the code for WriteDynamicData, and 01 is the sequence number. The rest of the data is acutally the Dynamic Data from the Read ignore-(1D 08 01) read- 04 02 03 00 08 11 ...

    I am not using an Arduino or the SDK for it. I am using the regular nrf8001 SDK, so using the encode command is my only option. From acilib.c :

    void acil_encode_cmd_write_dynamic_data(uint8_t buffer, uint8_t seq_no, uint8_t dynamic_data, uint8_t dynamic_data_size) { *(buffer + OFFSET_ACI_CMD_T_LEN) = MSG_WRITE_DYNAMIC_DATA_BASE_LEN + dynamic_data_size; *(buffer + OFFSET_ACI_CMD_T_CMD_OPCODE) = ACI_CMD_WRITE_DYNAMIC_DATA; *(buffer + OFFSET_ACI_CMD_T_WRITE_DYNAMIC_DATA + OFFSET_ACI_CMD_PARAMS_WRITE_DYNAMIC_DATA_T_SEQ_NO) = seq_no; memcpy((buffer + OFFSET_ACI_CMD_T_WRITE_DYNAMIC_DATA + OFFSET_ACI_CMD_PARAMS_WRITE_DYNAMIC_DATA_T_DYNAMIC_DATA), dynamic_data, dynamic_data_size); }

    Write: displays uint8_t buffer parameter value after calling acil_encode..(), and Read: displays uint8_t dynamic_data parameter value.

    Additionally I have tested the storgage issue, I have tried to call WriteDyanmicData cycle directly after ReadDynamicData cycle, storing the data in uint8_t arrays and sending them directly into the WriteDynamicData cycle as parameters - no saving into storage, no manipulating- and I get the same error at the same sequence, 2. So storage cannot be the issue?

  • Why are the last 3 bytes of the Dynamic Data missing (in sequence 1) ? i.e. 02 00 00, are the missing 3 bytes actually being sent ? . Provide complete information on the messages, otherwise it is difficult to understand what is happening. Looking at the error code that is received you need to double check the Write Dynamic Data that you are sending and verify that it matches the Dynamic data that you have read. Get a logic analyzer trace or print all the ACI messages going on the SPI interface so the full picture is seen.

  • Here is the print out of the ACI messages and RX and TX buffers for SPI

    I am directly writing the buffers from ReadDynamicData back into WriteDynamicData, skipping storage for now, and I still get the same error. Sequence 2 from the ReadDynamicData matches the WriteDyamicData Sequence 2.

    // Blep Setup Messages ...

    BLEP Received ACI_EVT_DEVICE_STARTED event as expected

    BLEP Entering standby mode

    BLEP Sending bond message

    RX: 038410000000000000000000000000000000000000000000000000000000

    BLEP Response is correct

    BLEP Entering advertisement mode (limited)

    RX: 0F85031F6C2D9ACD4227000000D007050000000000000000000000000000

    ACI Event Connected

    Number of Credits Available: 108

    BLEP Waiting for messages in connected mode

    Device Addr: 1F:6C:2D:9A:CD:42

    CASE 26 BLEP Getting nRF8001 status message

    RX: 118801000000000000000000000000000000000000000000000000000000

    ACI Event Pipe Status

    BLEP Waiting for messages in connected mode (limited)

    CASE 26 BLEP Getting nRF8001 status message

    RX: 078906000000D00700000000000000000000000000000000000000000000

    Event was: 89

    CASE 26 BLEP Getting nRF8001 status message

    RX: 078E37393333353200000000000000000000000000000000000000000000

    ACI Display Pass Key

    Passkey: 7 9 3 3 5 2

    CASE 26 BLEP Getting nRF8001 status message

    RX: 078927000000D00700000000000000000000000000000000000000000000

    Event was: 89

    CASE 26 BLEP Getting nRF8001 status message

    RX: 078906000000D00700000000000000000000000000000000000000000000

    Event was: 89

    CASE 26 BLEP Getting nRF8001 status message

    RX: 0787000104021F1C00000000000000000000000000000000000000000000

    Entering Bond Case

    ACI Event Bond Status

    Bonding Succeeded

    BLEP Waiting for messages in connected mode (limited) case 28

    CASE 26 BLEP Getting nRF8001 status message

    RX: 1188FBCD0000000000000000000000000000000000000000000000000000

    ACI Event Pipe Status

    BLEP Waiting for messages in connected mode (limited)

    CASE 26 BLEP Getting nRF8001 status message

    RX: 078927000000D00700000000000000000000000000000000000000000000

    Event was: 89

    CASE 26 BLEP Getting nRF8001 status message

    RX: 1188FBDD0000000000000000000000000000000000000000000000000000

    ACI Event Pipe Status

    BLEP Waiting for messages in connected mode (limited)

    CASE 26 BLEP Getting nRF8001 status message

    RX: 078906000000D00700000000000000000000000000000000000000000000

    Event was: 89

    CASE 26 BLEP Getting nRF8001 status message

    RX: 1188FFDD0000000000000000000000000000000000000000000000000000

    ACI Event Pipe Status

    BLEP Waiting for messages in connected mode (limited)

    CASE 26 BLEP Getting nRF8001 status message

    RX: 078927000000D00700000000000000000000000000000000000000000000

    Event was: 89

    CASE 26 BLEP Getting nRF8001 status message

    RX: 038603130000000000000000000000000000000000000000000000000000

    ACI_STATUS: 0003

    BLE_STATUS 0013

    ACI Event Disconnected2 for ReadDynamicData

    CASE 26 BLEP Getting nRF8001 status message

    RX: 1E840701010402030008110003064E6F5061696E000A0400000000000B020200

    ACI Event Command Response

    ACI evtopcode is READ_DYNAMIC_DATA

    ACI_STATUS transaction CONTINUE

    DynData seq#: 1

    0402030008110003064E6F5061696E000A0400000000000B020200

    CASE 26 BLEP Getting nRF8001 status message

    RX: 1E8407010200000E010A00100230310012023132001402333400160702000000

    ACI Event Command Response

    ACI evtopcode is READ_DYNAMIC_DATA

    ACI_STATUS transaction CONTINUE

    DynData seq#: 2

    00000E010A00100230310012023132001402333400160702000000

    CASE 26 BLEP Getting nRF8001 status message

    RX: 1E84070103AAAACCCC001900001B00001C020000001F00002100002202010000

    ACI Event Command Response

    ACI evtopcode is READ_DYNAMIC_DATA

    ACI_STATUS transaction CONTINUE

    DynData seq#: 3

    AAAACCCC001900001B00001C020000001F00002100002202010000

    CASE 26 BLEP Getting nRF8001 status message

    RX: 1E840701040024000025020000002706FFFFFFFFFFFF0C00105A8CF2B5613F00

    ACI Event Command Response

    ACI evtopcode is READ_DYNAMIC_DATA

    ACI_STATUS transaction CONTINUE

    DynData seq#: 4

    0024000025020000002706FFFFFFFFFFFF0C00105A8CF2B5613F00

    CASE 26 BLEP Getting nRF8001 status message

    RX: 1E84070105F901011F6C2D9ACD42B7641BAC109A154695B6710C5B8D59B10E00

    ACI Event Command Response

    ACI evtopcode is READ_DYNAMIC_DATA

    ACI_STATUS transaction CONTINUE

    DynData seq#: 5

    F901011F6C2D9ACD42B7641BAC109A154695B6710C5B8D59B10E00

    CASE 26 BLEP Getting nRF8001 status message

    RX: 1E84070106B4F5DC6400F8223E543F58F263E8C3F4E8708A42076F463F46A700

    ACI Event Command Response

    ACI evtopcode is READ_DYNAMIC_DATA

    ACI_STATUS transaction CONTINUE

    DynData seq#: 6

    B4F5DC6400F8223E543F58F263E8C3F4E8708A42076F463F46A700

    CASE 26 BLEP Getting nRF8001 status message

    RX: 1E84070107170000000000000000FEDD00000000000000000000000000000000

    ACI Event Command Response

    ACI evtopcode is READ_DYNAMIC_DATA

    ACI_STATUS transaction CONTINUE

    DynData seq#: 7

    170000000000000000FEDD00000000000000000000000000000000

    CASE 26 BLEP Getting nRF8001 status message

    RX: 0F84070208000000000000001402BF6F00000000000000000000000000000000

    ACI Event Command Response

    ACI evtopcode is READ_DYNAMIC_DATA

    ACI_STATUS transaction COMPLETE

    DynData seq#: 8

    000000000000001402BF6F00000000000000000000000000000000

    Calling WriteDynData Seq 1

    TX: 1D08010402030008110003064E6F5061696E000A0400000000000B020200

    CASE 26 BLEP Getting nRF8001 status message

    RX: 038408010000000000000000000000000000000000000000000000000000

    ACI Event Command Response

    ACI_CMD WriteDyanmicData

    WriteDyanmicData ACI_STATUS transaction CONTINUE

    Calling WriteDyanmicData seq 2

    TX: 1D080200000E010A00100230310012023132001402333400160702000000

    CASE 26 BLEP Getting nRF8001 status message

    RX: 038408810000000000000000000000000000000000000000000000000000

    ACI Event Command Response

    ACI_CMD WriteDyanmicData

    WriteDyanmicData ACI_STATUS_ERROR_INTERNAL

  • I have skipped storage all together to test. I still get the same issue from sending the dynamic data arrays into the write dynamic data cycle

Related