@@ -111,10 +111,42 @@ net_event_handler(struct net_mgmt_event_callback *cb, uint32_t mgmt_event, struc
111
111
/* Print interface information */
112
112
net_if_ipv4_addr_foreach (iface , print_dhcpv4_addr , NULL );
113
113
114
- /* Application can now process to the initialization of the mender-mcu-client */
114
+ /* Indicate the network is available */
115
115
k_event_post (& mender_client_events , MENDER_CLIENT_EVENT_NETWORK_UP );
116
116
}
117
117
118
+ /**
119
+ * @brief Network connnect callback
120
+ * @return MENDER_OK if network is connected following the request, error code otherwise
121
+ */
122
+ static mender_err_t
123
+ network_connect_cb (void ) {
124
+
125
+ LOG_INF ("Mender client connect network" );
126
+
127
+ /* This callback can be used to configure network connection */
128
+ /* Note that the application can connect the network before if required */
129
+ /* This callback only indicates the mender-client requests network access now */
130
+ /* Nothing to do in this example application just return network is available */
131
+ return MENDER_OK ;
132
+ }
133
+
134
+ /**
135
+ * @brief Network release callback
136
+ * @return MENDER_OK if network is released following the request, error code otherwise
137
+ */
138
+ static mender_err_t
139
+ network_release_cb (void ) {
140
+
141
+ LOG_INF ("Mender client released network" );
142
+
143
+ /* This callback can be used to release network connection */
144
+ /* Note that the application can keep network activated if required */
145
+ /* This callback only indicates the mender-client doesn't request network access now */
146
+ /* Nothing to do in this example application just return network is released */
147
+ return MENDER_OK ;
148
+ }
149
+
118
150
/**
119
151
* @brief Authentication success callback
120
152
* @return MENDER_OK if application is marked valid and success deployment status should be reported to the server, error code otherwise
@@ -240,7 +272,7 @@ main(void) {
240
272
net_mgmt_add_event_callback (& mgmt_cb );
241
273
net_dhcpv4_start (iface );
242
274
243
- /* Wait for mender-mcu-client events */
275
+ /* Wait until the network interface is operational */
244
276
k_event_wait_all (& mender_client_events , MENDER_CLIENT_EVENT_NETWORK_UP , false, K_FOREVER );
245
277
246
278
#if defined(CONFIG_NET_SOCKETS_SOCKOPT_TLS )
@@ -283,7 +315,9 @@ main(void) {
283
315
.authentication_poll_interval = 0 ,
284
316
.update_poll_interval = 0 ,
285
317
.recommissioning = false };
286
- mender_client_callbacks_t mender_client_callbacks = { .authentication_success = authentication_success_cb ,
318
+ mender_client_callbacks_t mender_client_callbacks = { .network_connect = network_connect_cb ,
319
+ .network_release = network_release_cb ,
320
+ .authentication_success = authentication_success_cb ,
287
321
.authentication_failure = authentication_failure_cb ,
288
322
.deployment_status = deployment_status_cb ,
289
323
.restart = restart_cb };
0 commit comments