Dear @rickkas7 ,
I have a Winbond W25Q128JVSIQ correctly connected to Boron (CS=D2).
When I run the following test code of PublishQueueAsyncRK using the retained SRAM (so not using "USE_SPI_FLASH" below), it works perfectly. I can call store() from the cloud, which stores 7 packets in retained, disconnects from cloud, and then when I press Reset and it reboots, it correctly re-uploads the previously trapped data packets.
When I run the same exact code using the SPI Flash, this does not happen. However, after such a store() + Reset, gn() then returns "7". So it is writing the packets to the SPI Flash chip, but not reading them and reuploading them later when it can.
Why is this? There is no question the W25Q128JVSIQ is correctly connected because the file system mount succeeds (res=0), and the getNumEvents() indicates that the trapped packets are getting queued/written to/remembered into the SPI Flash chip - but never retrieved and reuploaded therefrom.
This is disappointing since I went through the hassle, wait, and expense of doing my own PCB design with surface mount components assembled including the memory chip, and if this library doesn't work I would need to go back to my SD Card design.
Thanks for help.
#include <SpiffsParticleRK.h>
#include <PublishQueueAsyncRK.h>
SYSTEM_MODE(SEMI_AUTOMATIC);
SpiFlashWinbond spiFlash(SPI, D2);
SpiffsParticle fs(spiFlash);#define USE_SPI_FLASH
#ifdef USE_SPI_FLASH
PublishQueueAsyncSpiffs publishQueue(fs, "events");
#else
retained uint8_t publishQueueRetainedBuffer[2048];
PublishQueueAsync publishQueue(publishQueueRetainedBuffer, sizeof(publishQueueRetainedBuffer));
#endifint store(String command) {
Particle.disconnect();
Cellular.off();
delay(2000);
publishQueue.publish("M1", "test", PRIVATE, WITH_ACK);
publishQueue.publish("M2", "test", PRIVATE, WITH_ACK);
publishQueue.publish("M3", "test", PRIVATE, WITH_ACK);
publishQueue.publish("M4", "test", PRIVATE, WITH_ACK);
publishQueue.publish("M5", "test", PRIVATE, WITH_ACK);
publishQueue.publish("M6", "test", PRIVATE, WITH_ACK);
publishQueue.publish("M7", "test", PRIVATE, WITH_ACK);
return 0;
}int gn(String c) { return publishQueue.getNumEvents() ; }
int add(String c) { publishQueue.publish("M1", "test", PRIVATE, WITH_ACK); return 0; }
void setup() {
Cellular.on();
Cellular.connect();
Particle.connect();spiFlash.begin(); fs.withPhysicalSize(16 * 1024); s32_t res = fs.mountAndFormatIfNecessary(); Particle.publish("Setup", String::format("mount res=%ld", res)); if (res == 0) { publishQueue.setup(); } else { Particle.publish("Setup", "Error:SPIFlashInit"); } Particle.function("Store", store); Particle.function("gn", gn); Particle.function("add", add);
}
void loop() { Particle.process(); }
Proof of correct connection to Boron in my PCB: