This might be really simple, but I am having trouble getting it. I am trying to create a template for a message that will contain a variable length string. The string is usually 2062 characters long, so if I do this:
JAddStringToObject(body, “log_data”, “2062”);
does it mean I am allocating a fixed length string, or is the string variable length?
The string will be either empty or “none”, 150 bytes or 2062 bytes. Maybe I could create three templates with different data lengths.
Thanks in advance,
Perhaps I am getting ahead here, but how about I do this:
Set up three templates with three different data files: logdata.qo, devstatus.qo and commfail.qo, with structures appropriate to each type of message.
Set up three routes, each one to handle the different files and to send the messages to three different API controllers.
Can anyone see a problem with this?
This is different on versions prior to v3.2.1 and after. In the older versions, the length is the max length a string can be, but a string of any length up to that can be used. In the later versions, the string is variable length. I am however not sure of the specifics of this, as the documentation is unclear, I will follow up.
Low Bandwidth Design - Blues Developers is the documentation I was referring to.
Just to clarify - when you are establishing a template (which only needs to be done once), the value you pass to configure a given parameter as a string can be any arbitrary string value. Like Kimball stated, as long as you are on Notecard firmware >= 3.2.1, you don’t have to specify a
length argument either, and thus strings can be of any length:
JAddStringToObject(body, "log_data", "x");
When using this template, your
log_data string can be any length.
If you need to route three different sets of data, having three different Notefile names (and thus three different templates) is probably the right way to go.
Thanks again. I am using 22.214.171.12420, which seems to be the default.
I have got it sending the messages very happily; queueing up 10 messages and syncing. I will keep refining it.