Problem adding large strings to note requests with C/Zephyr

Hi All,

My old project, using PlatformIO/Arduino and the Swan, sends notes with a string 2,100 characters long with no problem via the I2C interface.

I am rebuilding it to run on Zephyr, written in C. There is a de-facto limit on strings that can be added to the message body of between 300 and 900 bytes. If the string is too big, the NoteRequest call just fails and the code stops. It does not return a value or error and the host needs to be reset.

I have tried it with the Xiao ESP32C3 and Particle Xenon Nordic ARM based board . The ESP device will accept 900 bytes but the Nordic one chokes at 300.

One clue is that the ESP32C3 gets slow before failing.It manages 500 bytes quickly but takes maybe a second to process 900 bytes. The I2C interface can’t be that slow.

Any clues would be welcome. The code is as follows:

    int p = 200;
    int i;
    char tCSV[p + 1];
    for(i = 0; i < p; i++)
    {
        tCSV[i] = 0x62;
    }
    tCSV[p] = 0;
    printk(" Table: \n %s\n", tCSV);       //print whole table

    char teststr[8] = {0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0};

    bool iTrue = true;
    if(iTrue)
    {
        J *req = NoteNewRequest("note.add");
        if (req)
        {
            JAddStringToObject(req, "file", "data.qo");
            JAddBoolToObject(req, "sync", true);
            J *body = JAddObjectToObject(req, "body");
            JAddStringToObject(body, "Data1", teststr);
            JAddStringToObject(body, "Data2", tCSV);

            printk("Calling NoteRequest.\n");
                
            bool nrq = (NoteRequest(req));              //Fails here if the iCSV array is too big.
            if(nrq)
            {
                printk("NoteRequest called.\n");
            }
            else
            {
                printk("NoteRequest failed.\n");
            }
        }
    }
1 Like

Today I have another problem, which is possibly related.

I am trying to get binary notes working. The code froze on the NoteBinaryStoreReset function. The debug stream says:
[INFO] {“req”:“card.binary”,“delete”:true,“crc”:“0001:A95AF483”}

I tried to break the function into its parts to see where it fails:

J *req = NoteNewRequest(“card.binary”);
if (req)
{
JAddBoolToObject(req, “delete”, true);
J *rsp = NoteRequestResponse(req);
if (NoteResponseError(rsp))
{
printk(“Error resetting note binary store.\n”);
}
else
{
printk(“Note binary store reset.\n”);
}
JDelete(rsp);
}

It fails at the NoteRequestResponse line with the same information from the debug stream.

The notecard is a NOTE-WIFI running firmware 7.5.2.17004. I don’t have any other notecards to compare it with.

Any clues would be welcome.

Thanks in advance,

Rob