Hi,
I am porting the note-c driver from the github example project for my msp430 architecture.
I am using I2C to communicate with the notecard and it is running freertos.
I am struggling to find code examples for freertos (or any rtos for that manner) on here or the developer page. Reading through note-c I see it relies heavily on the heap memory (static variables). This is a bit tricky when when using RTOS.
Am I missing some resource to get this going with an RTOS?
Where I am stuck is during the initialization of the note-c driver.
I currently only have one task in my firmware. And that is initializing the
bool notehub_init( void )
{
// Register callbacks with note-c subsystem that it needs for I/O, memory, timer
NoteSetFn(malloc, free, delay, millis);
// Register callbacks for Notecard I/O, or just do the initialization
//#if NOTECARD_USE_I2C
NoteSetFnI2C(NOTE_I2C_ADDR_DEFAULT, NOTE_I2C_MAX_DEFAULT, noteI2CReset, noteI2CTransmit, noteI2CReceive);
//#else
// //NoteSetFnSerial(noteSerialReset, noteSerialTransmit, noteSerialAvailable, noteSerialReceive);
//#endif
// "NoteNewRequest()" uses the bundled "J" json package to allocate a "req", which is a JSON object
// for the request to which we will then add Request arguments. The function allocates a "req"
// request structure using malloc() and initializes its "req" field with the type of request.
J *req = NoteNewRequest("hub.set");
// This command causes the data to be delivered to the Project on notehub.io that has claimed
// this Product ID. (see above)
#ifdef PRODUCT_UID
if (PRODUCT_UID[0]) {
JAddStringToObject(req, "product", PRODUCT_UID);
}
#endif
// This command determines how often the Notecard connects to the service. If "continuous" the Notecard
// immediately establishes a session with the service at notehub.io, and keeps it active continuously.
// Because of the power requirements of a continuous connection, a battery powered device would instead
// only sample its sensors occasionally, and would only upload to the service on a periodic basis.
//#if myLiveDemo
JAddStringToObject(req, "mode", "continuous");
//#else
//JAddStringToObject(req, "mode", "periodic");
//JAddNumberToObject(req, "outbound", 60);
//#endif
// Issue the request, telling the Notecard how and how often to access the service.
// This results in a JSON message to Notecard formatted like:
// { "req" : "hub.set",
// "product" : PRODUCT_UID,
// "mode" : "continuous"
// }
// Note that NoteRequest() always uses free() to release the request data structure, and it
// returns "true" if success and "false" if there is any failure.
return NoteRequest(req);
}
I am reaching NoteRequest(req) and within that function it runs NoteTransaction(req) and in that routine it seems to serialize the message correctly but fails in the hook _Transaction(json, NULL)
const char *NoteJSONTransaction(char *json, char **jsonResponse)
{
if (notecardTransaction == NULL || hookActiveInterface == interfaceNone) {
return "i2c or serial interface must be selected"; //fails here!
}
return notecardTransaction(json, jsonResponse);
}
The strange thing is that when I hover over the variables that it is evaluating it is not NULL and the second is set to 2