Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiFiStorage: writing/reading small files is not working #239

Open
vshymanskyy opened this issue Mar 7, 2023 · 0 comments
Open

WiFiStorage: writing/reading small files is not working #239

vshymanskyy opened this issue Mar 7, 2023 · 0 comments
Labels
type: imperfection Perceived defect in any part of project

Comments

@vshymanskyy
Copy link

When working on the multi-platform Preferences library, I noticed that storing small chunks of data on the NINA module produces incorrect results.

Example Code

I'm using Arduino Nano 33 IoT. WiFiNINA v1.8.13. Firmware v1.4.8.
This happens with small values, i.e. with the length of 1, 2, or 3 bytes.

#include "WiFiNINA.h"

void setup() {
  Serial.begin(115200);
  delay(2000);

  const char* fn = "/fs/test.bin";

  WiFiStorage.remove(fn);

  uint8_t data[3] = { 'A', 'B', 'C' };
  WiFiStorage.write(fn, 0, data, sizeof(data));

  uint32_t fsize = 0;
  if (WiFiStorage.exists(fn, &fsize)) {
    Serial.print("File exists. Size: "); Serial.println(fsize);
  }

  uint8_t result[16];
  WiFiStorage.read(fn, 0, result, fsize);

  for (int i=0; i<fsize; i++) {
    char out[4] = { 0, };
    uint8_t c = result[i];
    sprintf(out, "%02X ", c, c);
    Serial.print(out);
  }
  Serial.println();

  // Cleanup
  WiFiStorage.remove(fn);
}

void loop() {
  delay(100);
}

Actual Output

File exists. Size: 3
41 00 00 

Expected Output

File exists. Size: 3
41 42 43 
@per1234 per1234 added the type: imperfection Perceived defect in any part of project label Mar 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

2 participants