bluetooth-lowenergystm32bluenrg

BlueNRG wrong header


I bought STEVAL-MKSBOX1V1 of ST and wanted to write my own library to create a BLE application.

The BLE module on board is SPBTLE-1S which mounts BlueNRG-1, I wrote my own firmware in order to communicate using SPI protocol.

After resetting the module using the pin I send a read request from MCU to the BLE module,

 HAL_GPIO_WritePin(SPI1_CS_GPIO_Port,SPI1_CS_Pin,0);
 HAL_SPI_TransmitReceive(&hspi2,tx,rx,5,1);
 HAL_GPIO_WritePin(SPI1_CS_GPIO_Port,SPI1_CS_Pin,1);

I send:

{0x0b,0x00,0x00,0x00,0x00}

I get:

{0xff,0x08,0x00,0x06,0x00}

So apparently nothing good because the first byte is 0xff and not 0x02 (right?), but the 4th bit(0x06) should indicate the amount of data inside the read buffer.

If I read 6 bytes I get

{0x04,0xff,0x03,0x01,0x00,0x01}

And according to AN4494 It is exactly what I should read after the reset event on the module.

Then my question is why I keep getting {0xff,0x08,0x00,0x06,0x00} and not something like {0x02,....}?

Is there anything related to BlueNRG1 that is different from BlueNRG2? (It is so hard to find good documentation)

If anyone has some experience on SPI communication with this module I would like to have a bit of consulting.

Thanks in advance


Solution

  • {0xff,..} would be correct.

    AN4494 is for BlueNRG-MS, the 5-byte SPI header for MISO is: {Ready, WBufLen, 0x00, RBufLen, 0x00}. In BlueNRG-1 and BlueNRG-2, that SPI header has been modified to: {0xff, CmdLen0, CmdLen1, DataLen0, DataLen1}, in order to support ACI packets with length more than 127 bytes in a single SPI transaction. The first byte in the header is fixed to 0xff.

    Unfortunately currently there is no document describing the modification. You may need to refer to DTM SPI sample project to know the details.

    In your transaction, if executing a Read command and continuing to read MISO for the 6 byte data:

    That is a ACI Blue initialized event, saying firmware has started properly. That can be parsed: