@@ -122,21 +122,18 @@ void setup()
122122 // look "similar" to the Notes that will later be added with note.add, in
123123 // that the data types are used to intuit what the ultimate field data types
124124 // will be, and their maximum length.
125- req = notecard.newRequest (" note.add " );
125+ req = notecard.newRequest (" note.template " );
126126 if (req != NULL )
127127 {
128128 // Create the body for a template that will be used to send notes below
129- J *body = JCreateObject ( );
129+ J *body = JAddObjectToObject (req, " body " );
130130 if (body != NULL )
131131 {
132132 // Define the JSON template
133- JAddStringToObject (body, " status" , " AAAAAAAAAAAA" ); // maximum string length
134- JAddNumberToObject (body, " temp" , 1.1 ); // floating point (double)
135- JAddNumberToObject (body, " voltage" , 1.1 ); // floating point (double)
136- JAddNumberToObject (body, " count" , 1 ); // integer
137-
138- // Add the body to the request
139- JAddItemToObject (req, " body" , body);
133+ JAddStringToObject (body, " status" , TSTRING (12 )); // maximum string length
134+ JAddNumberToObject (body, " temp" , TFLOAT64); // floating point (double)
135+ JAddNumberToObject (body, " voltage" , TFLOAT64); // floating point (double)
136+ JAddNumberToObject (body, " count" , TUINT32); // 32-bit unsigned integer
140137 }
141138
142139 // Create a template of the payload that will be used to send
@@ -145,7 +142,6 @@ void setup()
145142
146143 // Register the template in the output queue notefile
147144 JAddStringToObject (req, " file" , " sensors.qo" );
148- JAddBoolToObject (req, " template" , true );
149145 notecard.sendRequest (req);
150146 }
151147}
@@ -199,14 +195,13 @@ void loop()
199195 if (req != NULL )
200196 {
201197 JAddStringToObject (req, " file" , " sensors.qo" );
202- J *body = JCreateObject ( );
198+ J *body = JAddObjectToObject (req, " body " );
203199 if (body != NULL )
204200 {
205201 JAddStringToObject (body, " status" , temperature > 26.67 ? " hot" : " normal" ); // 80F
206202 JAddNumberToObject (body, " temp" , temperature);
207203 JAddNumberToObject (body, " voltage" , voltage);
208204 JAddNumberToObject (body, " count" , eventCounter);
209- JAddItemToObject (req, " body" , body);
210205 }
211206 JAddBinaryToObject (req, " payload" , &binaryData, sizeof (binaryData));
212207 notecard.sendRequest (req);
0 commit comments