Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

static global variables (singleton model)

When application context is supplied as static global variables, then it is available to everything in the containing .c file. This is suitable for most single purpose applications (e.g. an interface to specific hardware, performs a unique operation, etc.). To use a static global variable, you only need to define a variable as static in the global space of your application’s .c file.

appContext - portable struct (multiple instances)
However, there are several instances where a portable struct can facilitate code reuse and enable higher level abstractions (e.g. using one source file to interface to an array of identical sensors, enabling a context based language, etc.). To use a portable struct, you would define it in your application’s .c file, allocate it from the heap in an initialization function, and provide a pointer to the appContext field of the application configuration struct, schedAppConfig.

Console Logging

Console logging can be performed via the APP_PRINTF() function.

WARNING: The maximum number of characters is ninety (90).

Dynamic Queue File Naming

...

  • * is a special character that will be replaced with the Sparrow node's ID by the Gateway.

Note Submission

Notes are submitted to the Gateway using the following API:

void noteSendToGatewayAsync(J *req, bool responseExpected)

The function has two parameters. The first is the JSON representation of the Note you would like to submit to the Notecard attached to the Sparrow Gateway. The second indicates whether or not a response is requested.

Invoking this API causes a cascade of changes to be made to the applications runtime.

  1. The current state is send to STATE_SENDING_REQUEST and if you indicated you were expecting a response, the state will change to STATE_RECEIVING_RESPONSE after sending the request.
    However, both the success and failure states are set to STATE_DEACTIVATED, which means whether your application succeeds or fails at it’s attempt to send the Note (or receive a response), it will ultimately become deactivated. If you wish to alter the success and failure states, then schedSetCompletionState() can be called promptly after noteSendToGatewayAsync() has returned.

  2. If a response has been requested, then the application will continue running - blocking the main thread of execution. This, in turn, prevents other applications from running.

Note Tracking

An If you have requested a response, then an arbitrary number can be added to the id tag of a the Note, which allows you to match it with a particular responsethe response with the original request. When "id" is supplied to a Note, then the response (which comes as the rsp parameter of diagResponse() callback) will contain a matching "id" tag

Console Logging

Console logging can be performed via the APP_PRINTF() function.

...

.

NOTE: Responses are expected to be used sparingly, as this works against the spirit of typical LoRa communications and the core of the Sparrow application design pattern. Responses can be an invaluable tool during the early development of a Sparrow application, but they should be removed (unless critical to the application) before an application should be considered ready for production.

Integrating a Custom Sensor into CMake

...