Skip to content

Commit a129d3f

Browse files
committed
modules: cloud: Rename module from transport to cloud
Previously there was a mix in use of terms between `transport` and `cloud`. This patch renames consistently to `cloud`. Signed-off-by: Jan Tore Guggedal <jantore.guggedal@nordicsemi.no>
1 parent 5ccbd04 commit a129d3f

15 files changed

+109
-105
lines changed

app/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ add_subdirectory(src/common)
1515
# Include mandatory module source folders
1616
add_subdirectory(src/modules/battery)
1717
add_subdirectory(src/modules/network)
18-
add_subdirectory(src/modules/transport)
18+
add_subdirectory(src/modules/cloud)
1919
add_subdirectory(src/modules/location)
2020
add_subdirectory(src/modules/app)
2121
add_subdirectory(src/modules/fota)

app/Kconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ config APP_PAYLOAD_CHANNEL_BUFFER_MAX_SIZE
1515

1616
rsource "src/modules/battery/Kconfig.battery"
1717
rsource "src/modules/network/Kconfig.network"
18-
rsource "src/modules/transport/Kconfig.transport"
18+
rsource "src/modules/cloud/Kconfig.cloud"
1919
rsource "src/modules/location/Kconfig.location"
2020
rsource "src/modules/led/Kconfig.led"
2121
rsource "src/modules/app/Kconfig.app"

app/prj.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ CONFIG_THREAD_NAME=y
220220
CONFIG_APP_FOTA_LOG_LEVEL_DBG=y
221221
CONFIG_APP_BATTERY_LOG_LEVEL_DBG=y
222222
CONFIG_APP_LOCATION_LOG_LEVEL_DBG=y
223-
CONFIG_APP_TRANSPORT_LOG_LEVEL_DBG=y
223+
CONFIG_APP_CLOUD_LOG_LEVEL_DBG=y
224224
CONFIG_APP_NETWORK_LOG_LEVEL_DBG=y
225225
CONFIG_APP_LED_LOG_LEVEL_DBG=y
226226
CONFIG_APP_ENVIRONMENTAL_LOG_LEVEL_DBG=y

app/src/common/message_channel.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <memfault/panics/assert.h>
1717
#endif
1818

19-
#include "transport_module.h"
19+
#include "cloud_module.h"
2020

2121
#ifdef __cplusplus
2222
extern "C" {

app/src/modules/transport/CMakeLists.txt app/src/modules/cloud/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
#
66

7-
target_sources(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/transport_module.c)
7+
target_sources(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/cloud_module.c)
88
target_include_directories(app PRIVATE .)

app/src/modules/transport/Kconfig.transport app/src/modules/cloud/Kconfig.cloud

+22-22
Original file line numberDiff line numberDiff line change
@@ -4,81 +4,81 @@
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
#
66

7-
menu "Transport"
7+
menu "Cloud module"
88
depends on NRF_CLOUD_COAP
99

10-
config APP_TRANSPORT_BACKOFF_INITIAL_SECONDS
10+
config APP_CLOUD_BACKOFF_INITIAL_SECONDS
1111
int "Reconnection backoff time in seconds"
1212
default 60
1313
help
14-
Time in between reconnection attempts to the CoAP server.
14+
Time in between reconnection attempts to the nRF Cloud CoAP server.
1515
The timer starts after the last failed attempt.
1616

17-
choice APP_TRANSPORT_BACKOFF_TYPE
17+
choice APP_CLOUD_BACKOFF_TYPE
1818
prompt "Reconnection backoff type"
19-
default APP_TRANSPORT_BACKOFF_TYPE_LINEAR
19+
default APP_CLOUD_BACKOFF_TYPE_LINEAR
2020

21-
config APP_TRANSPORT_BACKOFF_TYPE_EXPONENTIAL
21+
config APP_CLOUD_BACKOFF_TYPE_EXPONENTIAL
2222
bool "Exponential backoff"
2323
help
2424
Exponential backoff doubles the reconnection timeout after each failed attempt.
25-
The maximum reconnection timeout is defined by APP_TRANSPORT_BACKOFF_MAX_SECONDS.
25+
The maximum reconnection timeout is defined by APP_CLOUD_BACKOFF_MAX_SECONDS.
2626

27-
config APP_TRANSPORT_BACKOFF_TYPE_LINEAR
27+
config APP_CLOUD_BACKOFF_TYPE_LINEAR
2828
bool "Linear backoff"
2929
help
3030
Linear backoff adds a fixed amount of time to the reconnection timeout after each failed attempt,
31-
as defined by APP_TRANSPORT_BACKOFF_LINEAR_INCREMENT_SECONDS.
31+
as defined by APP_CLOUD_BACKOFF_LINEAR_INCREMENT_SECONDS.
3232

33-
config APP_TRANSPORT_BACKOFF_TYPE_NONE
33+
config APP_CLOUD_BACKOFF_TYPE_NONE
3434
bool "No backoff"
3535
help
3636
No backoff means that the reconnection timeout is constant at the value defined by
37-
APP_TRANSPORT_BACKOFF_INITIAL_SECONDS.
37+
APP_CLOUD_BACKOFF_INITIAL_SECONDS.
3838

3939
endchoice
4040

41-
config APP_TRANSPORT_BACKOFF_LINEAR_INCREMENT_SECONDS
41+
config APP_CLOUD_BACKOFF_LINEAR_INCREMENT_SECONDS
4242
int "Reconnection backoff time increment"
4343
default 60
4444
help
4545
Time added to the reconnection timeout after each failed attempt in seconds.
46-
The maximum reconnection timeout is defined by APP_TRANSPORT_BACKOFF_MAX_SECONDS.
46+
The maximum reconnection timeout is defined by APP_CLOUD_BACKOFF_MAX_SECONDS.
4747

48-
config APP_TRANSPORT_BACKOFF_MAX_SECONDS
48+
config APP_CLOUD_BACKOFF_MAX_SECONDS
4949
int "Maximum reconnection timeout"
5050
default 3600
5151
help
5252
Maximum reconnection backoff value in seconds.
5353

54-
config APP_TRANSPORT_THREAD_STACK_SIZE
54+
config APP_CLOUD_THREAD_STACK_SIZE
5555
int "Thread stack size"
5656
default 4096
5757

58-
config APP_TRANSPORT_MESSAGE_QUEUE_SIZE
58+
config APP_CLOUD_MESSAGE_QUEUE_SIZE
5959
int "Message queue size"
6060
default 5
6161
help
6262
ZBus subscriber message queue size.
6363

64-
config APP_TRANSPORT_POLL_INTERVAL_SECONDS
64+
config APP_CLOUD_POLL_INTERVAL_SECONDS
6565
int "Poll interval in seconds"
6666
default 10
6767
help
6868
Interval in seconds between polling nRF Cloud CoAP.
6969

70-
config APP_TRANSPORT_WATCHDOG_TIMEOUT_SECONDS
70+
config APP_CLOUD_WATCHDOG_TIMEOUT_SECONDS
7171
int "Watchdog timeout seconds"
7272
default 180
7373

74-
config APP_TRANSPORT_EXEC_TIME_SECONDS_MAX
74+
config APP_CLOUD_EXEC_TIME_SECONDS_MAX
7575
int "Maximum execution time seconds"
7676
default 120
7777
help
7878
Maximum time allowed for a single execution of the module's thread loop.
7979

80-
module = APP_TRANSPORT
81-
module-str = Transport
80+
module = APP_CLOUD
81+
module-str = Cloud
8282
source "subsys/logging/Kconfig.template.log_config"
8383

84-
endmenu # Transport
84+
endmenu # Cloud

app/src/modules/transport/transport_module.c app/src/modules/cloud/cloud_module.c

+49-49
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,25 @@
2121
#include "message_channel.h"
2222

2323
/* Register log module */
24-
LOG_MODULE_REGISTER(transport, CONFIG_APP_TRANSPORT_LOG_LEVEL);
24+
LOG_MODULE_REGISTER(cloud, CONFIG_APP_CLOUD_LOG_LEVEL);
2525

2626
#define CUSTOM_JSON_APPID_VAL_CONEVAL "CONEVAL"
2727
#define CUSTOM_JSON_APPID_VAL_BATTERY "BATTERY"
28-
#define MAX_MSG_SIZE (MAX(sizeof(struct cloud_payload), \
28+
#define MAX_MSG_SIZE (MAX(sizeof(struct cloud_payload), \
2929
MAX(sizeof(struct network_msg), sizeof(struct battery_msg))))
3030

31-
BUILD_ASSERT(CONFIG_APP_TRANSPORT_WATCHDOG_TIMEOUT_SECONDS >
32-
CONFIG_APP_TRANSPORT_EXEC_TIME_SECONDS_MAX,
31+
BUILD_ASSERT(CONFIG_APP_CLOUD_WATCHDOG_TIMEOUT_SECONDS >
32+
CONFIG_APP_CLOUD_EXEC_TIME_SECONDS_MAX,
3333
"Watchdog timeout must be greater than maximum execution time");
3434

3535
/* Register subscriber */
36-
ZBUS_MSG_SUBSCRIBER_DEFINE(transport);
36+
ZBUS_MSG_SUBSCRIBER_DEFINE(cloud);
3737

3838
/* Observe channels */
39-
ZBUS_CHAN_ADD_OBS(PAYLOAD_CHAN, transport, 0);
40-
ZBUS_CHAN_ADD_OBS(NETWORK_CHAN, transport, 0);
41-
ZBUS_CHAN_ADD_OBS(BATTERY_CHAN, transport, 0);
42-
ZBUS_CHAN_ADD_OBS(TRIGGER_CHAN, transport, 0);
39+
ZBUS_CHAN_ADD_OBS(PAYLOAD_CHAN, cloud, 0);
40+
ZBUS_CHAN_ADD_OBS(NETWORK_CHAN, cloud, 0);
41+
ZBUS_CHAN_ADD_OBS(BATTERY_CHAN, cloud, 0);
42+
ZBUS_CHAN_ADD_OBS(TRIGGER_CHAN, cloud, 0);
4343

4444
/* Define channels provided by this module */
4545

@@ -59,21 +59,21 @@ ZBUS_CHAN_DEFINE(CLOUD_CHAN,
5959
CLOUD_DISCONNECTED
6060
);
6161

62-
/* Enumerator to be used in privat transport channel */
63-
enum priv_transport_msg {
62+
/* Enumerator to be used in privat cloud channel */
63+
enum priv_cloud_msg {
6464
CLOUD_BACKOFF_EXPIRED,
6565
};
6666

67-
/* Create private transport channel for internal messaging that is not intended for external use.
67+
/* Create private cloud channel for internal messaging that is not intended for external use.
6868
* The channel is needed to communicate from asynchronous callbacks to the state machine and
69-
* ensure state transitions only happen from the transport module thread where the state machine
69+
* ensure state transitions only happen from the cloud module thread where the state machine
7070
* is running.
7171
*/
72-
ZBUS_CHAN_DEFINE(PRIV_TRANSPORT_CHAN,
73-
enum priv_transport_msg,
72+
ZBUS_CHAN_DEFINE(PRIV_CLOUD_CHAN,
73+
enum priv_cloud_msg,
7474
NULL,
7575
NULL,
76-
ZBUS_OBSERVERS(transport),
76+
ZBUS_OBSERVERS(cloud),
7777
CLOUD_BACKOFF_EXPIRED
7878
);
7979

@@ -108,9 +108,9 @@ static void state_connected_ready_run(void *o);
108108
static void state_connected_paused_entry(void *o);
109109
static void state_connected_paused_run(void *o);
110110

111-
/* Defining the hierarchical transport module states:
111+
/* Defining the hierarchical cloud module states:
112112
*
113-
* STATE_RUNNING: The transport module has started and is running
113+
* STATE_RUNNING: The cloud module has started and is running
114114
* - STATE_DISCONNECTED: Cloud connection is not established
115115
* - STATE_CONNECTING: The module is connecting to cloud
116116
* - STATE_CONNECTING_ATTEMPT: The module is trying to connect to cloud
@@ -197,7 +197,7 @@ static struct state_object {
197197

198198
/* Connection backoff time */
199199
uint32_t backoff_time;
200-
} transport_state;
200+
} cloud_state;
201201

202202
/* Static helper function */
203203
static void task_wdt_callback(int channel_id, void *user_data)
@@ -225,32 +225,32 @@ static void connect_to_cloud(void)
225225

226226
err = nrf_cloud_coap_connect(APP_VERSION_STRING);
227227
if (err == 0) {
228-
STATE_SET(transport_state, STATE_CONNECTED);
228+
STATE_SET(cloud_state, STATE_CONNECTED);
229229

230230
return;
231231
}
232232

233233
/* Connection failed, retry */
234234
LOG_ERR("nrf_cloud_coap_connect, error: %d", err);
235235

236-
STATE_SET(transport_state, STATE_CONNECTING_BACKOFF);
236+
STATE_SET(cloud_state, STATE_CONNECTING_BACKOFF);
237237
}
238238

239239
static uint32_t calculate_backoff_time(uint32_t attempts)
240240
{
241-
uint32_t backoff_time = CONFIG_APP_TRANSPORT_BACKOFF_INITIAL_SECONDS;
241+
uint32_t backoff_time = CONFIG_APP_CLOUD_BACKOFF_INITIAL_SECONDS;
242242

243243
/* Calculate backoff time */
244-
if (IS_ENABLED(CONFIG_APP_TRANSPORT_BACKOFF_TYPE_EXPONENTIAL)) {
245-
backoff_time = CONFIG_APP_TRANSPORT_BACKOFF_INITIAL_SECONDS << (attempts - 1);
246-
} else if (IS_ENABLED(CONFIG_APP_TRANSPORT_BACKOFF_TYPE_LINEAR)) {
247-
backoff_time = CONFIG_APP_TRANSPORT_BACKOFF_INITIAL_SECONDS +
248-
((attempts - 1) * CONFIG_APP_TRANSPORT_BACKOFF_LINEAR_INCREMENT_SECONDS);
244+
if (IS_ENABLED(CONFIG_APP_CLOUD_BACKOFF_TYPE_EXPONENTIAL)) {
245+
backoff_time = CONFIG_APP_CLOUD_BACKOFF_INITIAL_SECONDS << (attempts - 1);
246+
} else if (IS_ENABLED(CONFIG_APP_CLOUD_BACKOFF_TYPE_LINEAR)) {
247+
backoff_time = CONFIG_APP_CLOUD_BACKOFF_INITIAL_SECONDS +
248+
((attempts - 1) * CONFIG_APP_CLOUD_BACKOFF_LINEAR_INCREMENT_SECONDS);
249249
}
250250

251251
/* Limit backoff time */
252-
if (backoff_time > CONFIG_APP_TRANSPORT_BACKOFF_MAX_SECONDS) {
253-
backoff_time = CONFIG_APP_TRANSPORT_BACKOFF_MAX_SECONDS;
252+
if (backoff_time > CONFIG_APP_CLOUD_BACKOFF_MAX_SECONDS) {
253+
backoff_time = CONFIG_APP_CLOUD_BACKOFF_MAX_SECONDS;
254254
}
255255

256256
LOG_DBG("Backoff time: %u seconds", backoff_time);
@@ -261,9 +261,9 @@ static uint32_t calculate_backoff_time(uint32_t attempts)
261261
static void backoff_timer_work_fn(struct k_work *work)
262262
{
263263
int err;
264-
enum priv_transport_msg msg = CLOUD_BACKOFF_EXPIRED;
264+
enum priv_cloud_msg msg = CLOUD_BACKOFF_EXPIRED;
265265

266-
err = zbus_chan_pub(&PRIV_TRANSPORT_CHAN, &msg, K_SECONDS(1));
266+
err = zbus_chan_pub(&PRIV_CLOUD_CHAN, &msg, K_SECONDS(1));
267267
if (err) {
268268
LOG_ERR("zbus_chan_pub, error: %d", err);
269269
SEND_FATAL_ERROR();
@@ -301,7 +301,7 @@ static void state_running_run(void *o)
301301
struct network_msg msg = MSG_TO_NETWORK_MSG(state_object->msg_buf);
302302

303303
if (msg.type == NETWORK_DISCONNECTED) {
304-
STATE_SET(transport_state, STATE_DISCONNECTED);
304+
STATE_SET(cloud_state, STATE_DISCONNECTED);
305305

306306
return;
307307
}
@@ -336,7 +336,7 @@ static void state_disconnected_run(void *o)
336336
struct network_msg msg = MSG_TO_NETWORK_MSG(state_object->msg_buf);
337337

338338
if ((state_object->chan == &NETWORK_CHAN) && (msg.type == NETWORK_CONNECTED)) {
339-
STATE_SET(transport_state, STATE_CONNECTING);
339+
STATE_SET(cloud_state, STATE_CONNECTING);
340340

341341
return;
342342
}
@@ -386,11 +386,11 @@ static void state_connecting_backoff_run(void *o)
386386

387387
LOG_DBG("%s", __func__);
388388

389-
if (state_object->chan == &PRIV_TRANSPORT_CHAN) {
390-
enum priv_transport_msg msg = *(enum priv_transport_msg *)state_object->msg_buf;
389+
if (state_object->chan == &PRIV_CLOUD_CHAN) {
390+
enum priv_cloud_msg msg = *(enum priv_cloud_msg *)state_object->msg_buf;
391391

392392
if (msg == CLOUD_BACKOFF_EXPIRED) {
393-
STATE_SET(transport_state, STATE_CONNECTING_ATTEMPT);
393+
STATE_SET(cloud_state, STATE_CONNECTING_ATTEMPT);
394394

395395
return;
396396
}
@@ -495,11 +495,11 @@ static void state_connected_ready_run(void *o)
495495

496496
switch (msg.type) {
497497
case NETWORK_DISCONNECTED:
498-
STATE_SET(transport_state, STATE_CONNECTED_PAUSED);
498+
STATE_SET(cloud_state, STATE_CONNECTED_PAUSED);
499499
break;
500500

501501
case NETWORK_CONNECTED:
502-
STATE_EVENT_HANDLED(transport_state);
502+
STATE_EVENT_HANDLED(cloud_state);
503503
break;
504504

505505
case NETWORK_QUALITY_SAMPLE_RESPONSE:
@@ -593,28 +593,28 @@ static void state_connected_paused_run(void *o)
593593
LOG_DBG("%s", __func__);
594594

595595
if ((state_object->chan == &NETWORK_CHAN) && (msg.type == NETWORK_CONNECTED)) {
596-
STATE_SET(transport_state, STATE_CONNECTED_READY);
596+
STATE_SET(cloud_state, STATE_CONNECTED_READY);
597597

598598
return;
599599
}
600600
}
601601

602602
/* End of state handlers */
603603

604-
static void transport_module_thread(void)
604+
static void cloud_module_thread(void)
605605
{
606606
int err;
607607
int task_wdt_id;
608-
const uint32_t wdt_timeout_ms = (CONFIG_APP_TRANSPORT_WATCHDOG_TIMEOUT_SECONDS * MSEC_PER_SEC);
609-
const uint32_t execution_time_ms = (CONFIG_APP_TRANSPORT_EXEC_TIME_SECONDS_MAX * MSEC_PER_SEC);
608+
const uint32_t wdt_timeout_ms = (CONFIG_APP_CLOUD_WATCHDOG_TIMEOUT_SECONDS * MSEC_PER_SEC);
609+
const uint32_t execution_time_ms = (CONFIG_APP_CLOUD_EXEC_TIME_SECONDS_MAX * MSEC_PER_SEC);
610610
const k_timeout_t zbus_wait_ms = K_MSEC(wdt_timeout_ms - execution_time_ms);
611611

612-
LOG_DBG("Transport module task started");
612+
LOG_DBG("cloud module task started");
613613

614614
task_wdt_id = task_wdt_add(wdt_timeout_ms, task_wdt_callback, (void *)k_current_get());
615615

616616
/* Initialize the state machine to STATE_RUNNING, which will also run its entry function */
617-
STATE_SET_INITIAL(transport_state, STATE_RUNNING);
617+
STATE_SET_INITIAL(cloud_state, STATE_RUNNING);
618618

619619
while (true) {
620620
err = task_wdt_feed(task_wdt_id);
@@ -625,7 +625,7 @@ static void transport_module_thread(void)
625625
return;
626626
}
627627

628-
err = zbus_sub_wait_msg(&transport, &transport_state.chan, transport_state.msg_buf,
628+
err = zbus_sub_wait_msg(&cloud, &cloud_state.chan, cloud_state.msg_buf,
629629
zbus_wait_ms);
630630
if (err == -ENOMSG) {
631631
continue;
@@ -636,7 +636,7 @@ static void transport_module_thread(void)
636636
return;
637637
}
638638

639-
err = STATE_RUN(transport_state);
639+
err = STATE_RUN(cloud_state);
640640
if (err) {
641641
LOG_ERR("STATE_RUN(), error: %d", err);
642642
SEND_FATAL_ERROR();
@@ -646,6 +646,6 @@ static void transport_module_thread(void)
646646
}
647647
}
648648

649-
K_THREAD_DEFINE(transport_module_thread_id,
650-
CONFIG_APP_TRANSPORT_THREAD_STACK_SIZE,
651-
transport_module_thread, NULL, NULL, NULL, K_LOWEST_APPLICATION_THREAD_PRIO, 0, 0);
649+
K_THREAD_DEFINE(cloud_module_thread_id,
650+
CONFIG_APP_CLOUD_THREAD_STACK_SIZE,
651+
cloud_module_thread, NULL, NULL, NULL, K_LOWEST_APPLICATION_THREAD_PRIO, 0, 0);

0 commit comments

Comments
 (0)