Skip to content

Commit

Permalink
Merge remote-tracking branch 'zenoh/master' into freertos
Browse files Browse the repository at this point in the history
  • Loading branch information
bjsowa committed Oct 26, 2023
2 parents 376ed99 + 995f082 commit 7f9c2cf
Show file tree
Hide file tree
Showing 186 changed files with 2,111 additions and 1,275 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/arduino_esp32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
mkdir -p $ARDUINO_BASE
cd $ARDUINO_BASE
platformio init -b esp32thing_plus --project-option="build_flags=-DZ_LINK_BLUETOOTH=1 -DZENOH_DEBUG=3"
platformio init -b esp32thing_plus --project-option="build_flags=-DZ_FEATURE_LINK_BLUETOOTH=1 -DZENOH_DEBUG=3"
cd $ARDUINO_BASE/lib
ln -s $ZENOH_PICO_BASE
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/emscripten.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Compile debug
run: |
mkdir build
emcmake cmake -E env CFLAGS="-DZ_LINK_WS=1 -DZ_LINK_TCP=0 -DZ_LINK_UDP_MULTICAST=0 -DZ_LINK_UDP_UNICAST=0 -DZ_SCOUTING_UDP=0" cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_STANDARD=11 -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=OFF -DBUILD_MULTICAST=OFF -DBUILD_INTEGRATION=OFF -DBUILD_TOOLS=OFF -DZENOH_DEBUG=3 -H. -Bbuild
emcmake cmake -E env CFLAGS="-DZ_FEATURE_LINK_WS=1 -DZ_FEATURE_LINK_TCP=0 -DZ_FEATURE_LINK_UDP_MULTICAST=0 -DZ_FEATURE_LINK_UDP_UNICAST=0 -DZ_FEATURE_SCOUTING_UDP=0" cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_STANDARD=11 -DBUILD_EXAMPLES=OFF -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=OFF -DBUILD_MULTICAST=OFF -DBUILD_INTEGRATION=OFF -DBUILD_TOOLS=OFF -DZENOH_DEBUG=3 -H. -Bbuild
make -C build
2 changes: 1 addition & 1 deletion .github/workflows/mbed.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
mkdir -p $MBED_BASE
cd $MBED_BASE
pio init -b nucleo_f767zi --project-option="framework=mbed" --project-option="build_flags=-DZ_LINK_SERIAL=1 -DZENOH_DEBUG=3"
pio init -b nucleo_f767zi --project-option="framework=mbed" --project-option="build_flags=-DZ_FEATURE_LINK_SERIAL=1 -DZENOH_DEBUG=3"
cd $MBED_BASE/lib
ln -s $ZENOH_PICO_BASE
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/zephyr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
mkdir -p $ZEPHYR_BASE
cd $ZEPHYR_BASE
pio init -b nucleo_f767zi --project-option="framework=zephyr" --project-option="build_flags=-DZ_LINK_SERIAL=1 -DZENOH_DEBUG=3"
pio init -b nucleo_f767zi --project-option="framework=zephyr" --project-option="build_flags=-DZ_FEATURE_LINK_SERIAL=1 -DZENOH_DEBUG=3"
cd $ZEPHYR_BASE/lib
ln -s $ZENOH_PICO_BASE
Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#
cmake_minimum_required(VERSION 3.13)

project(zenohpico VERSION 0.10.0.0 LANGUAGES C)
project(zenohpico VERSION 0.11.0.0 LANGUAGES C)

include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
Expand All @@ -22,6 +22,11 @@ option(BUILD_SHARED_LIBS "Build shared libraries if ON, otherwise build static l
option(ZENOH_DEBUG "Use this to set the ZENOH_DEBUG variable." 0)
option(WITH_ZEPHYR "Build for Zephyr RTOS" OFF)
option(WITH_FREERTOS_PLUS_TCP "Build for FreeRTOS RTOS and FreeRTOS-Plus-TCP network stack" OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
if(CMAKE_EXPORT_COMPILE_COMMANDS)
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES
${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(BUILD_SHARED_LIBS "OFF")
Expand Down
47 changes: 40 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,23 +331,24 @@ To build and upload the code into the board, run the following command:
```

## 3. Running the Examples
The simplest way to run some of the example is to get a Docker image of the **zenoh** network router (see [http://zenoh.io/docs/getting-started/quick-test/](http://zenoh.io/docs/getting-started/quick-test/)) and then to run the examples on your machine.

### 3.1. Starting the zenoh Network Service
Assuming you've pulled the Docker image of the **zenoh** network router on a Linux host (to leverage UDP multicast scouting has explained [here](https://zenoh.io/docs/getting-started/quick-test/#run-zenoh-router-in-a-docker-container), then simply do:
The simplest way to run some of the example is to get a Docker image of the **zenoh** router (see [http://zenoh.io/docs/getting-started/quick-test/](http://zenoh.io/docs/getting-started/quick-test/)) and then to run the examples on your machine.

### 3.1. Starting the Zenoh Router
Assuming you've pulled the Docker image of the **zenoh** router on a Linux host (to leverage UDP multicast scouting as explained [here](https://zenoh.io/docs/getting-started/quick-test/#run-zenoh-router-in-a-docker-container), then simply do:
```bash
$ docker run --init --net host eclipse/zenoh:master
```

To see the zenoh manual page, simply do:

```bash
$ docker run --init --net host eclipse/zenoh:master --help
```

:warning: **Please notice that the `--net host` option in Docker is restricted to Linux only.**
The cause is that Docker doesn't support UDP multicast between a container and its host (see cases [moby/moby#23659](https://github.com/moby/moby/issues/23659), [moby/libnetwork#2397](https://github.com/moby/libnetwork/issues/2397) or [moby/libnetwork#552](https://github.com/moby/libnetwork/issues/552)). The only known way to make it work is to use the `--net host` option that is [only supported on Linux hosts](https://docs.docker.com/network/host/).

### 3.2. Basic Pub/Sub Example
Assuming that (1) you are running the **zenoh** network router, and (2) you are under the build directory, do:
Assuming that (1) you are running the **zenoh** router, and (2) you are under the build directory, do:
```bash
$ ./z_sub
```
Expand All @@ -357,7 +358,7 @@ And on another shell, do:
$ ./z_pub
```
### 3.3. Basic Queryable/Get Example
Assuming you are running the **zenoh** network router, do:
Assuming you are running the **zenoh** router, do:
```bash
$ ./z_queryable
```
Expand All @@ -366,3 +367,35 @@ And on another shell, do:
```bash
$ ./z_get
```

### 3.4. Basic Pub/Sub Example - P2P over UDP multicast
Zenoh-Pico can also work in P2P mode over UDP multicast. This allows a Zenoh-Pico application to communicate directly with another Zenoh-Pico application without requiring a Zenoh Router.

Assuming that (1) you are under the build directory, do:
```bash
$ ./z_sub -m peer -l udp/224.0.0.123:7447#iface=lo0
```

And on another shell, do:
```bash
$ ./z_pub -m peer -l udp/224.0.0.123:7447#iface=lo0
```
where `lo0` is the network interface you want to use for multicast communication.

### 3.4. Basic Pub/Sub Example - Mixing Client and P2P communication
To allow Zenoh-Pico unicast clients to talk to Zenoh-Pico multicast peers, as well as with any other Zenoh client/peer, you need to start a Zenoh Router that listens on both multicast and unicast:
```bash
$ docker run --init --net host eclipse/zenoh:master -l udp/224.0.0.123:7447#iface=lo0 -l tcp/127.0.0.1:7447
```

Assuming that (1) you are running the **zenoh** router as indicated above, and (2) you are under the build directory, do:
```bash
$ ./z_sub -m client -e tcp/127.0.0.1:7447
```
A subscriber will connect in client mode to the **zenoh** router over TCP unicast.

And on another shell, do:
```bash
$ ./z_pub -m peer -l udp/224.0.0.123:7447#iface=lo0
```
A publisher will start publishing over UDP multicast and the **zenoh** router will take care of forwarding data from the Zenoh-Pico publisher to the Zenoh-Pico subscriber.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
project = 'zenoh-pico'
copyright = '2017, 2022 ZettaScale Technology Inc'
author = 'ZettaScale Zenoh team'
release = '0.10.0.0'
release = '0.11.0.0'

# -- General configuration ---------------------------------------------------
master_doc = 'index'
Expand Down
7 changes: 7 additions & 0 deletions examples/arduino/z_get.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <WiFi.h>
#include <zenoh-pico.h>

#if Z_FEATURE_QUERY == 1
// WiFi-specific parameters
#define SSID "SSID"
#define PASS "PASS"
Expand Down Expand Up @@ -118,3 +119,9 @@ void loop() {
Serial.println("Unable to send query.");
}
}
#else
void setup() {
Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it.");
}
void loop() {}
#endif
7 changes: 7 additions & 0 deletions examples/arduino/z_pub.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <WiFi.h>
#include <zenoh-pico.h>

#if Z_FEATURE_PUBLICATION == 1
// WiFi-specific parameters
#define SSID "SSID"
#define PASS "PASS"
Expand Down Expand Up @@ -107,3 +108,9 @@ void loop() {

delay(1000);
}
#else
void setup() {
Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.");
}
void loop() {}
#endif
7 changes: 7 additions & 0 deletions examples/arduino/z_pull.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <WiFi.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
// WiFi-specific parameters
#define SSID "SSID"
#define PASS "PASS"
Expand Down Expand Up @@ -108,3 +109,9 @@ void loop() {
delay(5000);
z_subscriber_pull(z_pull_subscriber_loan(&sub));
}
#else
void setup() {
Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.");
}
void loop() {}
#endif
8 changes: 8 additions & 0 deletions examples/arduino/z_queryable.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <WiFi.h>
#include <zenoh-pico.h>

#if Z_FEATURE_QUERYABLE == 1
// WiFi-specific parameters
#define SSID "SSID"
#define PASS "PASS"
Expand Down Expand Up @@ -106,3 +107,10 @@ void setup() {
}

void loop() { delay(5000); }

#else
void setup() {
Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it.");
}
void loop() {}
#endif
8 changes: 8 additions & 0 deletions examples/arduino/z_sub.ino
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <WiFi.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
// WiFi-specific parameters
#define SSID "SSID"
#define PASS "PASS"
Expand Down Expand Up @@ -104,3 +105,10 @@ void setup() {
}

void loop() { delay(5000); }

#else
void setup() {
Serial.println("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.");
}
void loop() {}
#endif
4 changes: 4 additions & 0 deletions examples/espidf/z_get.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <unistd.h>
#include <zenoh-pico.h>

#if Z_FEATURE_QUERY == 1
#define ESP_WIFI_SSID "SSID"
#define ESP_WIFI_PASS "PASS"
#define ESP_MAXIMUM_RETRY 5
Expand Down Expand Up @@ -172,3 +173,6 @@ void app_main() {
z_close(z_move(s));
printf("OK!\n");
}
#else
void app_main() { printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it.\n"); }
#endif
6 changes: 6 additions & 0 deletions examples/espidf/z_pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <unistd.h>
#include <zenoh-pico.h>

#if Z_FEATURE_PUBLICATION == 1
#define ESP_WIFI_SSID "SSID"
#define ESP_WIFI_PASS "PASS"
#define ESP_MAXIMUM_RETRY 5
Expand Down Expand Up @@ -163,3 +164,8 @@ void app_main() {
z_close(z_move(s));
printf("OK!\n");
}
#else
void app_main() {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n");
}
#endif
6 changes: 6 additions & 0 deletions examples/espidf/z_pull.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <unistd.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
#define ESP_WIFI_SSID "SSID"
#define ESP_WIFI_PASS "PASS"
#define ESP_MAXIMUM_RETRY 5
Expand Down Expand Up @@ -168,3 +169,8 @@ void app_main() {
z_close(z_move(s));
printf("OK!\n");
}
#else
void app_main() {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
}
#endif
6 changes: 6 additions & 0 deletions examples/espidf/z_queryable.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#define ESP_MAXIMUM_RETRY 5
#define WIFI_CONNECTED_BIT BIT0

#if Z_FEATURE_QUERYABLE == 1
static bool s_is_wifi_connected = false;
static EventGroupHandle_t s_event_group_handler;
static int s_retry_count = 0;
Expand Down Expand Up @@ -171,3 +172,8 @@ void app_main() {
z_close(z_move(s));
printf("OK!\n");
}
#else
void app_main() {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERYABLE but this example requires it.\n");
}
#endif
6 changes: 6 additions & 0 deletions examples/espidf/z_sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <unistd.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
#define ESP_WIFI_SSID "SSID"
#define ESP_WIFI_PASS "PASS"
#define ESP_MAXIMUM_RETRY 5
Expand Down Expand Up @@ -166,3 +167,8 @@ void app_main() {
z_close(z_move(s));
printf("OK!\n");
}
#else
void app_main() {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
}
#endif
10 changes: 5 additions & 5 deletions examples/freertos_plus_tcp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ target_link_libraries(zenohpico
)
target_compile_definitions(zenohpico
PUBLIC
Z_MULTI_THREAD=1
Z_LINK_TCP=1
Z_SCOUTING_UDP=1
Z_LINK_UDP_UNICAST=1
Z_LINK_UDP_MULTICAST=0
Z_FEATURE_MULTI_THREAD=1
Z_FEATURE_LINK_TCP=1
Z_FEATURE_SCOUTING_UDP=1
Z_FEATURE_LINK_UDP_UNICAST=1
Z_FEATURE_LINK_UDP_MULTICAST=0
Z_CONFIG_SOCKET_TIMEOUT=1000
)

Expand Down
7 changes: 7 additions & 0 deletions examples/mbed/z_get.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <randLIB.h>
#include <zenoh-pico.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 @@ -94,3 +95,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_QUERY but this example requires it\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/mbed/z_pub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <randLIB.h>
#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 Down Expand Up @@ -85,3 +86,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_PUBLICATION but this example requires it.\n");
return -1;
}
#endif
7 changes: 7 additions & 0 deletions examples/mbed/z_pull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <randLIB.h>
#include <zenoh-pico.h>

#if Z_FEATURE_SUBSCRIPTION == 1
#define CLIENT_OR_PEER 0 // 0: Client mode; 1: Peer mode
#if CLIENT_OR_PEER == 0
#define MODE "client"
Expand Down Expand Up @@ -91,3 +92,9 @@ int main(int argc, char **argv) {

return 0;
}
#else
int main(void) {
printf("ERROR: Zenoh pico was compiled without Z_FEATURE_SUBSCRIPTION but this example requires it.\n");
return -1;
}
#endif
Loading

0 comments on commit 7f9c2cf

Please sign in to comment.