Skip to content
This repository was archived by the owner on Apr 24, 2019. It is now read-only.

Commit 71d86f6

Browse files
changed button abstraction to be mapped via mbed_app.json. also removed the unregistration feature.
1 parent 47095fa commit 71d86f6

12 files changed

+91
-11
lines changed

build_all.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ mbed compile -m K64F -t $TOOL
1111
cp BUILD/K64F/$TOOL/mbed-os-example-client.bin k64f-$TOOL-eth-v4.bin
1212
mbed compile -m NUCLEO_F429ZI -t $TOOL
1313
cp ./BUILD/NUCLEO_F429ZI/$TOOL/mbed-os-example-client.bin f429zi-$TOOL-eth-v4.bin
14+
cp configs/eth_odin_v4.json ./mbed_app.json
1415
mbed compile -m UBLOX_EVK_ODIN_W2 -t $TOOL
1516
cp ./BUILD/UBLOX_EVK_ODIN_W2/$TOOL/mbed-os-example-client.bin ublox-odin-$TOOL-eth-v4.bin
1617

@@ -21,6 +22,7 @@ mbed compile -m K64F -t $TOOL
2122
cp BUILD/K64F/$TOOL/mbed-os-example-client.bin k64f-$TOOL-eth-v6.bin
2223
mbed compile -m NUCLEO_F429ZI -t $TOOL
2324
cp ./BUILD/NUCLEO_F429ZI/$TOOL/mbed-os-example-client.bin f429zi-$TOOL-eth-v4.bin
25+
cp configs/eth_odin_v6.json ./mbed_app.json
2426
mbed compile -m UBLOX_EVK_ODIN_W2 -t $TOOL
2527
cp ./BUILD/UBLOX_EVK_ODIN_W2/$TOOL/mbed-os-example-client.bin ublox-odin-$TOOL-eth-v6.bin
2628

configs/eth_odin_v4.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"config": {
3+
"network-interface":{
4+
"help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
5+
"value": "ETHERNET"
6+
}
7+
},
8+
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
9+
"target_overrides": {
10+
"*": {
11+
"target.features_add": ["LWIP", "COMMON_PAL"],
12+
"platform.stdio-baud-rate": 115200,
13+
"platform.stdio-convert-newlines": true,
14+
"lwip.ipv4-enabled": true,
15+
"lwip.ipv6-enabled": false,
16+
"mbed-trace.enable": 0
17+
},
18+
"UBLOX_EVK_ODIN_W2": {
19+
"target.device_has_remove": ["EMAC"]
20+
}
21+
}
22+
}

configs/eth_odin_v6.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"config": {
3+
"network-interface":{
4+
"help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
5+
"value": "ETHERNET"
6+
}
7+
},
8+
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],
9+
"target_overrides": {
10+
"*": {
11+
"target.features_add": ["LWIP", "COMMON_PAL"],
12+
"platform.stdio-baud-rate": 115200,
13+
"platform.stdio-convert-newlines": true,
14+
"lwip.ipv4-enabled": false,
15+
"lwip.ipv6-enabled": true,
16+
"mbed-trace.enable": 0
17+
},
18+
"UBLOX_EVK_ODIN_W2": {
19+
"target.device_has_remove": ["EMAC"]
20+
}
21+
}
22+
}

configs/eth_v4.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
"network-interface":{
44
"help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
55
"value": "ETHERNET"
6+
},
7+
"button1": {
8+
"help": "Use BUTTON1 from PinNames.h by default",
9+
"value": "BUTTON1"
610
}
711
},
812
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],

configs/eth_v6.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
"network-interface":{
44
"help": "Options are ETHERNET, WIFI_ESP8266, WIFI_ODIN, MESH_LOWPAN_ND, MESH_THREAD",
55
"value": "ETHERNET"
6+
},
7+
"button1": {
8+
"help": "Use BUTTON1 from PinNames.h by default",
9+
"value": "BUTTON1"
610
}
711
},
812
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],

configs/mesh_6lowpan.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"mesh_radio_type": {
88
"help": "options are ATMEL, MCR20",
99
"value": "ATMEL"
10+
},
11+
"button1": {
12+
"help": "Use BUTTON1 from PinNames.h by default",
13+
"value": "BUTTON1"
1014
}
1115
},
1216
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],

configs/mesh_6lowpan_subg.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"mesh_radio_type": {
88
"help": "options are ATMEL, MCR20, SPIRIT1",
99
"value": "SPIRIT1"
10+
},
11+
"button1": {
12+
"help": "Use BUTTON1 from PinNames.h by default",
13+
"value": "BUTTON1"
1014
}
1115
},
1216
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],

configs/mesh_thread.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"mesh_radio_type": {
88
"help": "options are ATMEL, MCR20, EFR32",
99
"value": "ATMEL"
10+
},
11+
"button1": {
12+
"help": "Use BUTTON1 from PinNames.h by default",
13+
"value": "BUTTON1"
1014
}
1115
},
1216
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],

configs/wifi_esp8266_v4.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
"wifi-rx": {
2020
"help": "RX pin for serial connection to external device",
2121
"value": "D0"
22+
},
23+
"button1": {
24+
"help": "Use BUTTON1 from PinNames.h by default",
25+
"value": "BUTTON1"
2226
}
2327
},
2428
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],

configs/wifi_v4.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
"wifi-rx": {
2020
"help": "RX pin for serial connection to external device",
2121
"value": "D0"
22+
},
23+
"button1": {
24+
"help": "Use BUTTON1 from PinNames.h by default",
25+
"value": "BUTTON1"
2226
}
2327
},
2428
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],

main.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,29 @@ struct MbedClientDevice device = {
6565
// Instantiate the class which implements LWM2M Client API (from simpleclient.h)
6666
MbedClient mbed_client(device);
6767

68+
// Set up a button interrupt for user interaction
69+
#ifdef MBED_CONF_APP_BUTTON1
70+
InterruptIn counter_btn(MBED_CONF_APP_BUTTON1);
71+
#endif
72+
6873

6974
/**
70-
* User interaction handler / simulator. Sets up physical button handlers and a ticker
75+
* User interaction handler / simulator. Sets up physical button handler and a ticker
7176
* for regular updates for the resources.
7277
*
73-
* BUTTON1 and BUTTON2 are mapped to actual buttons in the hardware abstraction code.
78+
* MBED_CONF_APP_BUTTON1 is mapped to actual button pin the mbed_app.json file, where you need to
79+
* specify board-specific values or leave them undefined if the board does not have buttons.
7480
*/
7581
class InteractionProvider {
7682

7783
public:
78-
InteractionProvider(Semaphore& updates_sem) : counter_btn(BUTTON1),
79-
unreg_btn(BUTTON2),
80-
updates(updates_sem) {
84+
InteractionProvider(Semaphore& updates_sem) : updates(updates_sem) {
85+
86+
// Set up handler function for the interaction button, if available
8187

82-
// Set up handler functions for the interaction buttons
88+
#ifdef MBED_CONF_APP_BUTTON1
8389
counter_btn.fall(this, &InteractionProvider::counter_button_handler);
84-
unreg_btn.fall(this, &InteractionProvider::unreg_button_handler);
90+
#endif
8591

8692
// Use the counter button handler to send an update of endpoint resource values
8793
// to connector every 15 seconds periodically.
@@ -104,10 +110,6 @@ class InteractionProvider {
104110
updates.release();
105111
}
106112

107-
// physical buttons for counter and unregistration
108-
InterruptIn counter_btn;
109-
InterruptIn unreg_btn;
110-
111113
// time-based event source for regular resource updates
112114
Ticker timer;
113115

mbed_app.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
"wifi-rx": {
2424
"help": "RX pin for serial connection to external device",
2525
"value": "D0"
26+
},
27+
"button1": {
28+
"help": "Use BUTTON1 from PinNames.h by default",
29+
"value": "BUTTON1"
2630
}
2731
},
2832
"macros": ["MBEDTLS_USER_CONFIG_FILE=\"mbedtls_mbed_client_config.h\""],

0 commit comments

Comments
 (0)