For my project, I am going to use notefiles (sensors.qo) and would like to sync as soon as they are added. But seems that sync is not that much fast for my case. It takes approx 5 mins on average to happen. My code adds these files every one minutes or so. And the file contains data from the same sensors always.
What I would like to do is detele those old files and only keep the most recently added file. So that I get right data on my cloud dashboard.
What I tried so far is some request from notehub-api.
First,
{"req":"note.add","file":"sensors.qo","body":{ "temp":72.22 },"sync":true}
{"total":1}
Then,
{"req":"note.get","file":"sensors.qo","delete":true}
{"err":"no notes available {note-noexist}"}
Hi @ujur007,
Make sure your Notecard is in continuous
mode:
{
"req": "hub.set",
"mode": "continuous"
}
…and you’re using "sync":true
(to immediately sync) and "live":true
(to bypass saving the Notefile to flash) with your note.add request:
{
"req": "note.add",
"file": "sensors.qo",
"body": { "temp": 72.22 },
"sync": true,
"live": true
}
That’s about as fast as you’ll be able to sync with Notehub, and it should only take seconds.
Hi @RobLauer
I did that but still there is no notes?
{
"req": "hub.set","mode": "continuous"
}
{}
{
"req": "note.add",
"file": "sensors.qo",
"body": { "temp": 72.22 },
"sync": true,
"live": true
}
{}
> {"req":"note.get","file":"sensors.qo","delete":true}
{"err":"no notes available {note-noexist}"}
I see that now the sync is very fast so no need technically to delete the old files. Nevertheless, it would be nice to know. if there is a possibility to delete the file once added.
Yeah, sorry I wasn’t initially clear. My instructions were to make it as fast as possible!
You can use the file.delete API to delete Notefiles on the Notecard:
{"req":"file.delete","files":["sensors.qo"]}
1 Like