Skip to content

Commit f4ef84d

Browse files
committed
app_work: rename to app_sensors
The app_work.c/h files are mainly used for reading sensor data and sending on Golioth Stream. Changing the name to app_sensors.c/h will help users understand the purpose of the file. Signed-off-by: Mike Szczys <[email protected]>
1 parent abfa928 commit f4ef84d

File tree

7 files changed

+25
-24
lines changed

7 files changed

+25
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
- Upgrade `golioth/golioth-zephyr-boards` dependency to [`v1.0.1`](https://github.com/golioth/golioth-zephyr-boards/tree/v1.0.1)
2020
- Dependencies use https instead of ssh GitHub URLs
2121
- libostentus removed from code base and included as a Zephyr module
22+
- renamed app_work.c/h to app_sensors.c/h
2223

2324
### Fixed
2425
- Fix build error when `CONFIG_LIB_OSTENTUS=n` on the `aludel_mini_v1_sparkfun9160` board.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ target_sources(app PRIVATE src/main.c)
1111
target_sources(app PRIVATE src/app_rpc.c)
1212
target_sources(app PRIVATE src/app_settings.c)
1313
target_sources(app PRIVATE src/app_state.c)
14-
target_sources(app PRIVATE src/app_work.c)
14+
target_sources(app PRIVATE src/app_sensors.c)
1515

1616
add_subdirectory_ifdef(CONFIG_ALUDEL_BATTERY_MONITOR src/battery_monitor)

src/app_work.c renamed to src/app_sensors.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
*/
66

77
#include <zephyr/logging/log.h>
8-
LOG_MODULE_REGISTER(app_work, LOG_LEVEL_DBG);
8+
LOG_MODULE_REGISTER(app_sensors, LOG_LEVEL_DBG);
99

1010
#include <golioth/client.h>
1111
#include <golioth/stream.h>
1212
#include <zephyr/drivers/gpio.h>
1313
#include <zephyr/kernel.h>
1414

15-
#include "app_work.h"
15+
#include "app_sensors.h"
1616

1717
#ifdef CONFIG_LIB_OSTENTUS
1818
#include <libostentus.h>
@@ -42,7 +42,7 @@ static void async_error_handler(struct golioth_client *client,
4242

4343
/* This will be called by the main() loop */
4444
/* Do all of your work here! */
45-
void app_work_sensor_read(void)
45+
void app_sensors_read_and_steam(void)
4646
{
4747
int err;
4848
char json_buf[256];
@@ -77,7 +77,7 @@ void app_work_sensor_read(void)
7777
IF_ENABLED(CONFIG_LIB_OSTENTUS, (
7878
/* Update slide values on Ostentus
7979
* -values should be sent as strings
80-
* -use the enum from app_work.h for slide key values
80+
* -use the enum from app_sensors.h for slide key values
8181
*/
8282
snprintk(json_buf, sizeof(json_buf), "%d", counter);
8383
slide_set(UP_COUNTER, json_buf, strlen(json_buf));
@@ -87,7 +87,7 @@ void app_work_sensor_read(void)
8787
++counter;
8888
}
8989

90-
void app_work_init(struct golioth_client *work_client)
90+
void app_sensors_init(struct golioth_client *work_client)
9191
{
9292
client = work_client;
9393
}

src/app_work.h renamed to src/app_sensors.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#ifndef __APP_WORK_H__
8-
#define __APP_WORK_H__
7+
#ifndef __APP_SENSORS_H__
8+
#define __APP_SENSORS_H__
99

10-
/** The `app_work.c` file performs the important work of this application which
11-
* is to read sensor values and report them to the Golioth LightDB Stream as
12-
* time-series data.
10+
/** The `app_sensors.c` file performs the important work of this application
11+
* which is to read sensor values and report them to the Golioth LightDB Stream
12+
* as time-series data.
1313
*
1414
* For this demonstration, a `counter` value is periodically logged and pushed
1515
* to the Golioth time-series database. This simulated sensor reading occurs
16-
* when the loop in `main.c` calls `app_work_sensor_read()`. The frequency of
17-
* this loop is determined by values received from the Golioth Settings Service
18-
* (see app_settings.h).
16+
* when the loop in `main.c` calls `app_sensors_read_and_steam()`. The frequency
17+
* of this loop is determined by values received from the Golioth Settings
18+
* Service (see app_settings.h).
1919
*
2020
* https://docs.golioth.io/firmware/zephyr-device-sdk/light-db-stream/
2121
*/
2222

2323
#include <golioth/client.h>
2424

25-
void app_work_init(struct golioth_client *work_client);
26-
void app_work_sensor_read(void);
25+
void app_sensors_init(struct golioth_client *work_client);
26+
void app_sensors_read_and_steam(void);
2727

2828
#define LABEL_UP_COUNTER "Counter"
2929
#define LABEL_DN_COUNTER "Anti-counter"
@@ -45,4 +45,4 @@ typedef enum {
4545
FIRMWARE
4646
} slide_key;
4747

48-
#endif /* __APP_WORK_H__ */
48+
#endif /* __APP_SENSORS_H__ */

src/app_state.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ LOG_MODULE_REGISTER(app_state, LOG_LEVEL_DBG);
1414
#include "json_helper.h"
1515

1616
#include "app_state.h"
17-
#include "app_work.h"
17+
#include "app_sensors.h"
1818

1919
#define DEVICE_STATE_FMT "{\"example_int0\":%d,\"example_int1\":%d}"
2020

src/battery_monitor/battery.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <golioth/stream.h>
2020

2121
#include "battery_monitor/battery.h"
22-
#include "../app_work.h"
22+
#include "../app_sensors.h"
2323

2424
LOG_MODULE_REGISTER(battery, LOG_LEVEL_DBG);
2525

src/main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LOG_MODULE_REGISTER(golioth_rd_template, LOG_LEVEL_DBG);
1010
#include "app_rpc.h"
1111
#include "app_settings.h"
1212
#include "app_state.h"
13-
#include "app_work.h"
13+
#include "app_sensors.h"
1414
#include <golioth/client.h>
1515
#include <golioth/fw_update.h>
1616
#include <samples/common/net_connect.h>
@@ -87,7 +87,7 @@ static void start_golioth_client(void)
8787
app_state_observe(client);
8888

8989
/* Initialize app work */
90-
app_work_init(client);
90+
app_sensors_init(client);
9191

9292
/* Register Settings service */
9393
app_settings_register(client);
@@ -226,8 +226,8 @@ int main(void)
226226
IF_ENABLED(CONFIG_LIB_OSTENTUS,(
227227
/* Set up a slideshow on Ostentus
228228
* - add up to 256 slides
229-
* - use the enum in app_work.h to add new keys
230-
* - values are updated using these keys (see app_work.c)
229+
* - use the enum in app_sensors.h to add new keys
230+
* - values are updated using these keys (see app_sensors.c)
231231
*/
232232
slide_add(UP_COUNTER, LABEL_UP_COUNTER, strlen(LABEL_UP_COUNTER));
233233
slide_add(DN_COUNTER, LABEL_DN_COUNTER, strlen(LABEL_DN_COUNTER));
@@ -249,7 +249,7 @@ int main(void)
249249
));
250250

251251
while (true) {
252-
app_work_sensor_read();
252+
app_sensors_read_and_steam();
253253

254254
k_sleep(K_SECONDS(get_loop_delay_s()));
255255
}

0 commit comments

Comments
 (0)