@@ -66,18 +66,22 @@ struct MbedClientDevice device = {
66
66
MbedClient mbed_client (device);
67
67
68
68
69
- // In case of K64F board , there is button resource available
70
- // to change resource value and unregister
71
- #ifdef TARGET_K64F
69
+ // If board has a button_1, use it to update the counter.
70
+ #ifdef BUTTON_1
72
71
// Set up Hardware interrupt button.
73
- InterruptIn obs_button (SW2);
74
- InterruptIn unreg_button (SW3);
72
+ InterruptIn obs_button (BUTTON_1);
75
73
#else
76
74
// In non K64F boards , set up a timer to simulate updating resource,
77
75
// there is no functionality to unregister.
78
76
Ticker timer;
79
77
#endif
80
78
79
+ // If the board has a 2nd button - hook the unregistration to that.
80
+ #ifdef BUTTON_2
81
+ InterruptIn unreg_button (BUTTON_2);
82
+ #endif
83
+
84
+
81
85
/*
82
86
* Arguments for running "blink" in it's own thread.
83
87
*/
@@ -242,7 +246,7 @@ class ButtonResource {
242
246
243
247
// up counter
244
248
counter++;
245
- #ifdef TARGET_K64F
249
+ #ifdef BUTTON_1
246
250
printf (" handle_button_click, new value of counter is %d\n " , counter);
247
251
#else
248
252
printf (" simulate button_click, new value of counter is %d\n " , counter);
@@ -373,18 +377,20 @@ Add MBEDTLS_NO_DEFAULT_ENTROPY_SOURCES and MBEDTLS_TEST_NULL_ENTROPY in mbed_app
373
377
LedResource led_resource;
374
378
BigPayloadResource big_payload_resource;
375
379
376
- #ifdef TARGET_K64F
377
- // On press of SW3 button on K64F board , example application
380
+ #ifdef BUTTON_2
381
+ // On press 2nd button (boards that have it) , example application
378
382
// will call unregister API towards mbed Device Connector
379
383
//unreg_button.fall(&mbed_client,&MbedClient::test_unregister);
380
384
unreg_button.fall(&unregister);
385
+ #endif // BUTTON_2
381
386
382
- // Observation Button (SW2) press will send update of endpoint resource values to connector
387
+ #ifdef BUTTON_1
388
+ // 1st button - observation button press will send update of endpoint resource values to connector
383
389
obs_button.fall(&button_clicked);
384
390
#else
385
391
// Send update of endpoint resource values to connector every 15 seconds periodically
386
392
timer.attach(&button_clicked, 15.0);
387
- #endif
393
+ #endif // BUTTON_1
388
394
389
395
// Create endpoint interface to manage register and unregister
390
396
mbed_client.create_interface(MBED_SERVER_ADDRESS, network);
0 commit comments