Skip to content

Commit

Permalink
New function and such
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanrolds committed Feb 3, 2025
1 parent 2a7b41a commit 814f9a4
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions code/nrf-connect/samples/ble/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ static int prst_init() {
return 0;
}

static void dump_config() {
#if IS_ENABLED(CONFIG_PRST_BLE_ENCODING_BTHOME_V2)
LOG_INF("Payload encoding: BTHOME_V2");
#elif IS_ENABLED(CONFIG_PRST_BLE_ENCODING_BTHOME_V1)
LOG_INF("Payload encoding: BTHOME_V1");
#elif IS_ENABLED(CONFIG_PRST_BLE_ENCODING_BPARASITE_V2)
LOG_INF("Payload encoding: BPARASITE_V2");
#else
#error "Unhandled CONFIG_PRST_BLE_ENCODING_ choice in dump_config()"
#endif

LOG_INF("Sleep duration: %d ms", CONFIG_PRST_SLEEP_DURATION_MSEC);
}

static int prst_loop(prst_sensors_t *sensors) {
RET_IF_ERR(prst_sensors_read_all(sensors));
RET_IF_ERR(prst_ble_adv_set_data(sensors));
Expand All @@ -35,15 +49,7 @@ int main(void) {
__ASSERT(!prst_init(), "Error in prst_init()");
prst_led_flash(2);

if (IS_ENABLED(CONFIG_PRST_BLE_ENCODING_BTHOME_V2)) {
LOG_INF("Payload Encoding: BTHOME_V2");
} else if (IS_ENABLED(CONFIG_PRST_BLE_ENCODING_BTHOME_V1)) {
LOG_INF("Payload Encoding: BTHOME_V1");
} else if (IS_ENABLED(CONFIG_PRST_BLE_ENCODING_BPARASITE_V2)) {
LOG_INF("Payload Encoding: BPARASITE_V2");
}

LOG_INF("Sleep duration: %d", CONFIG_PRST_SLEEP_DURATION_MSEC);
dump_config();

prst_sensors_t sensors;
while (true) {
Expand Down

0 comments on commit 814f9a4

Please sign in to comment.