Application Introduction
State
Defines
Custom Application States
#define STATE_DIAG_CHECK 0 #define STATE_DIAG_ISR_XFER 1
STATE_DIAG_CHECK
- When this state is received by the polling callback and the application has not be marked for deactivation, it will generate a diagnostic report, send the results to the Gateway Notecard, and mark itself ready for deactivation. Otherwise, if this state is received by the polling callback and the application has already been marked for deactivation then it will log a completion message and immediately deactivate.STATE_DIAG_ISR_XFER
- This state is set from within the ISR, and it allows the polling callback to know the interrupt was invoked.
Application Specific Values
#define REQUESTID_TEMPLATE 2
REQUESTID_TEMPLATE
- This allows you to match a response to a request. To keep track of responses to specific Notes, you need to supply an “id” tag to the Note. If an “id” was supplied to a Note, then the response parameter provided todiagResponse()
will contain the matching “id”.
#define APPLICATION_NOTEFILE "*#diag.qo"
APPLICATION_NOTEFILE
- The dynamic filename of the application specific queue.NOTE: The Gateway will replace
*
with the originating node's ID. The resulting transformation will resemble2037335832365003001b0037#diag.qo
.
Array and Counter Limits
#define ISR_MAX_CALL_RETENTION 8 // Must be a power of 2 #define ISR_COUNTER_MASK ~(ISR_MAX_CALL_RETENTION-1)
ISR_MAX_CALL_RETENTION
- The maximum number of ISRs that will be recorded.ISR_COUNTER_MASK
- The mask will limit the value of the counter.
Structures
typedef struct ISR_parameters { int appID; uint16_t pins; } ISR_parameters;
ISR_parameters
- Used to collect information available in ISR for later processing.
Variables (a.k.a. Application Specific Context)
Callbacks
bool diagActivate(int appID, void *appContext);
void diagISR(int appID, uint16_t pins, void *appContext);
void diagPoll(int appID, int state, void *appContext);
void diagResponse(int appID, J *rsp, void *appContext);
Other Functions
External
bool diagInit(void);
Internal
static void addNote(bool immediate);
static bool registerNotefileTemplate();