2017-07-28 04:42 AM
for example the datasheet offers this command
'AT+S.SOCKDW=<sid>,<cid> <len><cr>{data}'
this is the format if UART is used, but at no point is explained how I do this with SPI! All thats written is:
'To map an AT command in the equivalent SPI command, the following procedure applies:
1. Use the corresponding CMD ID specified in Table 1: 'SPWF04Sx commands' and fill the 4th bytes of the master packet.2. If optional parameters are available, count the number of comma-separated items after the “=� character and with that number the 6th byte of the message. Starting from the 7th byte, start to write 1 byte containing the field lengths and then copy the field bytes. Then continue with the remaining parameters.3. Once the full payload has been filled, calculate the full message payload lengths and accordingly fill bytes 1 and 2 in the SPI message packet request.'Do I just add bytes after the last parameter and adjust the payload length? does the parameter needs to start with <cr> character and is just comma seperated?
Best Regards
2017-07-31 10:57 PM
so I think I solved this. It seems it expects a normal SPI packet without the additional data, then waits for a single 0x02 SYNC byte, and then holds the IRQ line down like it would for receiving a message from it. Just this time the data is written instead of read! lets assume I want to create a file 'test.txt' and I want to write 5 bytes 'hello' into it. In UART that would be:
AT+S.FSC=test.txt,5<cr>{hello}
now in SPI thats:
0x02, 0x00, 0x0D, 0x23, 0x02, 0x08, 0x74, 0x65, 0x73, 0x74, 0x2E, 0x74, 0x78, 0x74, 0x01, 0x35
and the additional data:
0x68, 0x65, 0x6C, 0x6C, 0x6F
After ALOT trial an error I found that this order of events works reliable for me: (assuming the IRQ line is already high)
transfer out the SPI packet (0x02, 0x00, 0x0D, 0x23, 0x02,...)
set CS HIGH
set CS LOW