@@ -19,10 +19,10 @@ Commander commander;
19
19
20
20
// We have to create the prototypes functions for our commands.
21
21
// The arguments have to be the same for all command functions.
22
- void cat_func ( char *args, commandResponse *response );
23
- void dog_func ( char *args, commandResponse *response );
24
- void sum_func ( char *args, commandResponse *response );
25
- void led_func ( char *args, commandResponse *response );
22
+ void cat_func ( char *args, Stream *response );
23
+ void dog_func ( char *args, Stream *response );
24
+ void sum_func ( char *args, Stream *response );
25
+ void led_func ( char *args, Stream *response );
26
26
27
27
// To tell Commander how many commands we have, it is necessary
28
28
// to create an array, that holds some data that represents our
@@ -216,31 +216,31 @@ void loop() {
216
216
217
217
218
218
// / This is an example function for the cat command
219
- void cat_func (char *args, commandResponse *response )
219
+ void cat_func (char *args, Stream *response )
220
220
{
221
221
222
222
response -> print (" Hello from cat function!\r\n " );
223
223
224
224
}
225
225
226
226
// / This is an example function for the dog command
227
- void dog_func (char *args, commandResponse *response )
227
+ void dog_func (char *args, Stream *response )
228
228
{
229
229
230
230
response -> print (" Hello from dog function!\r\n " );
231
231
232
232
}
233
233
234
234
// / This is an example function for the led command
235
- void led_func (char *args, commandResponse *response )
235
+ void led_func (char *args, Stream *response )
236
236
{
237
237
238
238
digitalWrite ( LED_BUILTIN, !digitalRead ( LED_BUILTIN ) );
239
239
240
240
}
241
241
242
242
// / This is an example function for the sum command
243
- void sum_func (char *args, commandResponse *response )
243
+ void sum_func (char *args, Stream *response )
244
244
{
245
245
246
246
// These variables will hold the value of the
@@ -274,6 +274,10 @@ void sum_func(char *args, commandResponse *response )
274
274
sum = a + b;
275
275
276
276
// Print out the result.
277
- response -> printf ( " %d + %d = %d\r\n " , a, b, sum );
277
+ response -> print ( a );
278
+ response -> print ( " + " );
279
+ response -> print ( b );
280
+ response -> print ( " = " );
281
+ response -> println ( sum );
278
282
279
283
}
0 commit comments