Skip to content

Commit 2b29ab0

Browse files
committed
Commander_simple example ported to use Stream
1 parent b6d82ad commit 2b29ab0

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

examples/Commander_simple/Commander_simple.ino

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ Commander commander;
1919

2020
// We have to create the prototypes functions for our commands.
2121
// 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 );
2626

2727
// To tell Commander how many commands we have, it is necessary
2828
// to create an array, that holds some data that represents our
@@ -216,31 +216,31 @@ void loop() {
216216

217217

218218
/// 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 )
220220
{
221221

222222
response -> print("Hello from cat function!\r\n");
223223

224224
}
225225

226226
/// 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 )
228228
{
229229

230230
response -> print("Hello from dog function!\r\n");
231231

232232
}
233233

234234
/// 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 )
236236
{
237237

238238
digitalWrite( LED_BUILTIN, !digitalRead( LED_BUILTIN ) );
239239

240240
}
241241

242242
/// 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 )
244244
{
245245

246246
// These variables will hold the value of the
@@ -274,6 +274,10 @@ void sum_func(char *args, commandResponse *response )
274274
sum = a + b;
275275

276276
// 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 );
278282

279283
}

0 commit comments

Comments
 (0)