Skip to content

Commit

Permalink
fix: update freertos examples with modular features
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-roland committed Oct 31, 2023
1 parent d0828e9 commit 4c7f141
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 12 deletions.
4 changes: 4 additions & 0 deletions examples/freertos_plus_tcp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ target_link_libraries(zenohpico
target_compile_definitions(zenohpico
PUBLIC
Z_FEATURE_MULTI_THREAD=1
Z_FEATURE_PUBLICATION=1
Z_FEATURE_SUBSCRIPTION=1
Z_FEATURE_QUERY=1
Z_FEATURE_QUERYABLE=1
Z_FEATURE_LINK_TCP=1
Z_FEATURE_SCOUTING_UDP=1
Z_FEATURE_LINK_UDP_UNICAST=1
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/include/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#define configUSE_PREEMPTION 1
#define configTICK_RATE_HZ ((TickType_t)1000)
#define configMAX_PRIORITIES (56)
#define configMINIMAL_STACK_SIZE ((uint16_t) PTHREAD_STACK_MIN)
#define configMINIMAL_STACK_SIZE ((uint16_t)PTHREAD_STACK_MIN)
#define configMAX_TASK_NAME_LEN (16)
#define configUSE_16_BIT_TICKS 0
#define configQUEUE_REGISTRY_SIZE 0
Expand Down
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/include/FreeRTOSIPConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

// Set ipconfigBUFFER_PADDING on 64-bit platforms
#if INTPTR_MAX == INT64_MAX
#define ipconfigBUFFER_PADDING 14U
#define ipconfigBUFFER_PADDING 14U
#endif

#endif /* FREERTOS_IP_CONFIG_H */
10 changes: 8 additions & 2 deletions examples/freertos_plus_tcp/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "FreeRTOS.h"

#if Z_FEATURE_QUERY == 1
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
#if CLIENT_OR_PEER == 0
#define MODE "client"
Expand Down Expand Up @@ -47,7 +48,7 @@ void reply_handler(z_owned_reply_t *reply, void *ctx) {
}
}

void app_main() {
void app_main(void) {
z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
Expand Down Expand Up @@ -92,4 +93,9 @@ void app_main() {
zp_stop_lease_task(z_loan(s));

z_close(z_move(s));
}
}
#else
void app_main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it.\n");
}
#endif
8 changes: 7 additions & 1 deletion examples/freertos_plus_tcp/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "FreeRTOS.h"

#if Z_FEATURE_PUBLICATION == 1
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
#if CLIENT_OR_PEER == 0
#define MODE "client"
Expand All @@ -30,7 +31,7 @@
#define KEYEXPR "demo/example/zenoh-pico-pub"
#define VALUE "[FreeRTOS-Plus-TCP] Pub from Zenoh-Pico!"

void app_main() {
void app_main(void) {
z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
Expand Down Expand Up @@ -104,3 +105,8 @@ void app_main() {

z_close(z_move(s));
}
#else
void app_main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n");
}
#endif
8 changes: 7 additions & 1 deletion examples/freertos_plus_tcp/z_pub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "FreeRTOS.h"

#if Z_FEATURE_PUBLICATION == 1
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
#if CLIENT_OR_PEER == 0
#define MODE "client"
Expand All @@ -30,7 +31,7 @@
#define KEYEXPR "demo/example/zenoh-pico-pub"
#define VALUE "[FreeRTOS-Plus-TCP] Pub from Zenoh-Pico!"

void app_main() {
void app_main(void) {
z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
Expand Down Expand Up @@ -72,3 +73,8 @@ void app_main() {

z_close(z_move(s));
}
#else
void app_main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n");
}
#endif
8 changes: 7 additions & 1 deletion examples/freertos_plus_tcp/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <zenoh-pico.h>

#if Z_FEATURE_PUBLICATION == 1
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
#if CLIENT_OR_PEER == 0
#define MODE "client"
Expand All @@ -35,7 +36,7 @@ void data_handler(const z_sample_t *sample, void *ctx) {
z_drop(z_move(keystr));
}

void app_main() {
void app_main(void) {
z_owned_config_t config = z_config_default();
zp_config_insert(z_config_loan(&config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
Expand Down Expand Up @@ -77,3 +78,8 @@ void app_main() {

z_close(z_move(s));
}
#else
void app_main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n");
}
#endif
8 changes: 7 additions & 1 deletion examples/freertos_plus_tcp/z_put.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <zenoh-pico.h>

#if Z_FEATURE_PUBLICATION == 1
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
#if CLIENT_OR_PEER == 0
#define MODE "client"
Expand All @@ -28,7 +29,7 @@
#define KEYEXPR "demo/example/zenoh-pico-put"
#define VALUE "[FreeRTOS-Plus-TCP] Pub from Zenoh-Pico!"

void app_main() {
void app_main(void) {
z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
Expand Down Expand Up @@ -74,3 +75,8 @@ void app_main() {

z_close(z_move(s));
}
#else
void app_main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n");
}
#endif
8 changes: 7 additions & 1 deletion examples/freertos_plus_tcp/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <zenoh-pico.h>

#if Z_FEATURE_QUERYABLE == 1
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
#if CLIENT_OR_PEER == 0
#define MODE "client"
Expand Down Expand Up @@ -43,7 +44,7 @@ void query_handler(const z_query_t *query, void *ctx) {
z_drop(z_move(keystr));
}

void app_main() {
void app_main(void) {
z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
Expand Down Expand Up @@ -89,3 +90,8 @@ void app_main() {

z_close(z_move(s));
}
#else
void app_main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it.\n");
}
#endif
2 changes: 1 addition & 1 deletion examples/freertos_plus_tcp/z_scout.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void drop(void *context) {
}
}

void app_main() {
void app_main(void) {
int *context = (int *)pvPortMalloc(sizeof(int));
*context = 0;
z_owned_scouting_config_t config = z_scouting_config_default();
Expand Down
7 changes: 6 additions & 1 deletion examples/freertos_plus_tcp/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void data_handler(const z_sample_t *sample, void *ctx) {
z_drop(z_move(keystr));
}

void app_main() {
void app_main(void) {
z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
Expand Down Expand Up @@ -75,3 +75,8 @@ void app_main() {

z_close(z_move(s));
}
#else
void app_main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
}
#endif
7 changes: 6 additions & 1 deletion examples/freertos_plus_tcp/z_sub_st.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void data_handler(const z_sample_t *sample, void *ctx) {
z_drop(z_move(keystr));
}

void app_main() {
void app_main(void) {
z_owned_config_t config = z_config_default();
zp_config_insert(z_loan(config), Z_CONFIG_MODE_KEY, z_string_make(MODE));
if (strcmp(CONNECT, "") != 0) {
Expand Down Expand Up @@ -67,3 +67,8 @@ void app_main() {

z_close(z_move(s));
}
#else
void app_main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
}
#endif

0 comments on commit 4c7f141

Please sign in to comment.