Notecard CLI req

I cannot figure out how to do a simple Notecard CLI request. I installed the Notecard CLI and then I opened up a Windows 10 command prompt. If I issue the commands “notecard -version” and “notecard -info” it is clear the communication is working fine. But when I try the “notecard -req {“req”:“card.wifi”,“ssid”:”“,“password”:”“}” command (substituting my wifi credentials), I get a “flag provided but not defined:…” response.
Trying “notecard -req '{“req”:“card.wifi”,“ssid”:”“,“password”:”“}'” from an online example, I get the error “invalid character ‘'’ looking for beginning of value”. Trying: “notecard -req’{“req”:“card.wifi”,“ssid”:”“,“password”:”“}'” returns “flag provided but not defined:”. Trying: “notecard -req”{“req”:“card.wifi”,“ssid”:“”,“password”:“”}“” returns “flag provided but not defined:”. UGH!!!

Yes, I can use other tools to do this, but I want to be able to execute a simple request from the notecard CLI.

This link from the documentation indicates the JSON request must be wrapped in single quotes: Notecard CLI - Blues Wireless Developers
But the command notecard -req ‘{“req”:“hub.get”}’ from a Windows command prompt (using the installed CLI) results in the error: invalid character ‘'’ looking for beginning of value

Another similar link: Notecard CLI - Blues Wireless Developers

Hi @markwkiehl,

When using the command prompt on Windows, make sure you are escaping any double quotes used in a request, like so:

notecard -req "{\"req\":\" … }"

The use of single quotes is only available on macOS/linux environments. Hope that helps!

Rob

Interesting. I still don’t quite have it right, but at least the following doesn’t throw an error from the Windows command prompt:

notecard -req “{"req":"card.version"}”

notecard -req “{"req":"card.wireless"}”

notecard -req “{"req":"hub.sync"}”

notecard -req “{"req":"hub.sync.status"}”

notecard -req “{"req":"hub.status"}”

notecard -req “{"req":"note.add","body":{"temp":35.5,"humid":56.23}}”

None of the above requests generated events on Notehub. But when I executed them from the In-Browser Terminal, events were generated. Therefore I think the requests were ignored.

Any suggestions?

I don’t see a hub.set request in here (which is what “links” a Notecard to a project on Notehub). Also, depending on the mode argument of your hub.set request, the note.add at the end may or may not cause a new Note to appear in Notehub immediately (i.e. you may be waiting for a periodic cellular sync from the Notecard).

What is returned when you enter the following in the command prompt?

notecard -req "{\"req\":\"hub.get\"}"

I had previously performed a “hub.set” using the In-Browser Terminal., and the response was simply “{}” that the documentation states confirms it was successful. How else can I check “hub.set”?

Executing a

notecard -req "{\"req\":\"hub.get\"}"

Returns nothing, just like the other commands, including hub.get. Adding -verbose to the hub.get returns:

{“req”:“hub.get”}
{“mode”:“periodic”,“host”:“a.notefile.net”,“product”:“com.gmail.myemail:initial_assessment”,“device”:“dev:01abc345678d”}

(private content above modified)

Other Notecard CLI commands such as -info or -version work just fine. The problems seem to be isolated to a Notecard CLI -req. I can execute requests from the In-Browser terminal without an issue. Running the command prompt as administrator doesn’t change anything.

Hi @markwkiehl,

Sorry, I should have mentioned that the -verbose flag is needed to see any responses from the Notecard. You may be interested in the Interactive Request Mode as well, which allows you to interact with the Notecard like the in-browser terminal via the -play flag.

In addition, you can use the -trace flag to see more detailed output from the Notecard.

Rob

That did it! You are correct, using the ‘-verbose’ option with the Notecard CLI causes the response from any JSON requests to be displayed. Thank you!

FYI… My exploration of Notecard on Windows OS and with a Swan is being posted online at: https://savvymicrocontrollersolutions.info/blues_io.php?blog=blues-io-getting-started

1 Like

This is great @markwkiehl! My only nit pick suggestion in the article is that you mention the Wi-Fi Notecard doesn’t waste your consumption credits. Actually consumption credits are primarily used when you route data (events) out of Notehub and to another cloud provider. Event ingress is free whether it’s a cellular or Wi-Fi Notecard. To me, the main value of the Wi-Fi Notecard is that you don’t use up any cellular data while prototyping and connections are usually lag-free :slight_smile:.

I thought that each time data is routed between the Notecard device to the Notehub.io cloud, a single Consumption Credit (1 CC) is consumed. That was my understanding from the blues.io pricing page. : “An Event is the basic unit of data sent from a Notecard to Notehub and to a customer’s servers through a Route if a Route is defined. It’s the user-defined JSON data from a customer’s microcontroller or Notecard, further annotated with things such as time and cell tower location.”

Did I get the scope wrong? If the data only goes from a Notecard to Notehub, does it use a Consumption Credit? Does that same path consume cellular data?

I think the Consumption Credit model is fair for production, and is the primary reason I am looking to move to Notecard. I just don’t want to consume Consumption Credits while developing and testing anymore than necessary.

Hi @markwkiehl,

Consumption Credits are only used when an event is routed out of Notehub (via a Notehub Route) or pulled out of Notehub (via the Notehub API).

Notes delivered to Notehub from a Notecard that don’t go anywhere do not consume a CC. If using a Cellular Notecard, yes those do use cellular data.

Thanks,
Rob