Accessign data sent from notecard through notehub API?

Hi,

how am I supposed to get data from the notecard through the notehub and access it using e.g. curl? If I add a note to e.g. sensor.qo from the notecard it shows up in the events on the notehub web UI, and I can see it when I use the events API. But I cannot seem to get it if I try to use curl like this:

curl -L "https://api.notefile.net/req?product=no.met.gauteh&device=dev:XXXX&project=${PUID}" \
  -d '{"req":"note.get","file":"sensor.qo"}' \
  -H "X-SESSION-TOKEN: ${TOKEN}"

this gives the error:

{"err":"no notes available in queue {note-noexist}"}

if I add a note through curl like this:

 curl -L "https://api.notefile.net/req?product=no.met.gauteh&device=dev:XXX&project=${PUID}" \
   -d '{"req":"note.add","file":"blah.qi", "body": {"temp": 72.22 }}' \
   -H "X-SESSION-TOKEN: ${TOKEN}"

  • dev is a dev:UID string
  • PUID is a app:aaaa-bbbb-uuid-string

I can get it back using note.changes, but not using note.get.

I can get the data by using the events API, is this the way to do it? Except using routed web methods.

Does qo files work like queues? I can add notes to it repeatedly and access it with note.get + delete to get all the items, not just the latest?

Edit: It seems that I can use .db files for this. I guess it makes sense to clean them out after a time, but how much can be stored on the notecard? I am thinking about using a .dbx to store data that I might not be able to afford to transmit (in terms of power, etc), but could retrieve manually from the notecard when I get physical access to it again.

Regards, Gaute

Hi @gauteh,

I believe you are on the right path. Using the Notehub Event API you can query Notehub for previously synced events and use a variety of parameters to filter out the resulting Notes you want to view.

This scenario applies only if your Notecard has successfully synced with Notehub. If the sensor.qo Notefile hasn’t been synced yet, I recommend looking at the Notecard File API to inspect individual Notefiles.

Let me know if you have any other questions!

Rob

If I add a note to sensor.qo on the notecard (e.g. using the host MCU), trigger a hub.sync I can see the event in the event log. But I cannot find a way to get that note using note.get and curl. Is that supposed to work? For sensor.db it works.

The web + routing API requires continuous wireless mode, so I think I will have to work with the Note API.

Hi @gauteh,

If you’re trying to route data from Notecard → Notehub → your cloud app, I recommend looking at the route tutorials we provide which make it considerably easier to transmit your data to your endpoint.

If, however, you want to view/download/whatever events from Notehub, I’d recommend using the Notehub Event API (linked above).

As you discovered, a note.get request against Notehub is only useful when using .db files.

Rob

1 Like

Thanks. So .db with templates is presumably the most efficient in terms of bandwidth way to transmit sensor data produced at the notecard (rather than Events + .qo)? Routing requires a continuous connection, which is probably too power-hungry. This is for a battery-powered application.

What is the local data-capacity of the notecard for .dbx and queued notes?

Routing via Notehub actually doesn’t require a continuous connection. You may be confusing Notehub routing vs the Notecard Web APIs which DO require a continuous connection.

The most efficient way to route data is by using Notehub routes, since the routing of data itself is performed on Notehub, not on your device!

To answer your other question, the Notecard provides about 900KB of non-volatile storage for Notefiles.

Ah, I see! So I can set up a route and filter it on e.g. sensor.qo and it will then post the notes to the endpoint whenever the notecard syncs with the hub?

Thanks a lot!

2 Likes

Exactly! Couldn’t have explained it better myself.