Skip to content

Commit 7922f04

Browse files
GwendalRaoulStephaneTriomphevg-wp
authored
Feature/proto api (#118)
Add a new API called proto api that allow to parse and generate request/response as per wirepas gateway api defined here: https://github.com/wirepas/backend-apis/tree/master/gateway_to_backend --------- Co-authored-by: Stephane Triomphe <[email protected]> Co-authored-by: GitHub Actions <> Co-authored-by: vg-wp <[email protected]>
1 parent 732221c commit 7922f04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+5103
-11
lines changed

.github/workflows/c-cpp.yml

+12-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ name: Build example
22

33
on:
44
push:
5-
branches: [ master ]
65
pull_request:
76
branches: [ master ]
87

@@ -12,10 +11,21 @@ jobs:
1211
runs-on: ubuntu-latest
1312

1413
steps:
15-
- uses: actions/checkout@v2
14+
- name: checkout code
15+
uses: actions/checkout@v4
16+
with:
17+
submodules: true
1618
- name: make example
1719
run: make
1820
working-directory: example
21+
- name: make proto example
22+
run: make
23+
working-directory: example/linux/proto-api
24+
- name: install libpaho-mqtt
25+
run: sudo apt install libpaho-mqtt-dev
26+
- name: make gateway example
27+
run: make
28+
working-directory: example/linux/gw-example
1929
- name: make test
2030
run: make
2131
working-directory: test

.github/workflows/generate_protos.yml

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Generate proto file
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- update_proto/**
8+
paths:
9+
- 'lib/wpc_proto/deps/nanopb/**'
10+
- 'lib/wpc_proto/deps/backend-apis/**'
11+
- 'lib/wpc_proto/proto_options/**'
12+
- '.github/workflows/generate_protos.yml'
13+
- 'lib/wpc_proto/tools/generate_proto_code.sh'
14+
15+
workflow_dispatch:
16+
inputs:
17+
message:
18+
description: 'Commit message'
19+
required: true
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: checkout code
26+
uses: actions/checkout@v4
27+
with:
28+
submodules: true
29+
30+
- name: install python
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: '3.10'
34+
35+
- name: install requirements
36+
run: pip install -r lib/wpc_proto/deps/nanopb/requirements.txt
37+
38+
- name: generate our proto files
39+
run: lib/wpc_proto/tools/generate_proto_code.sh
40+
41+
- name: setup git config
42+
run: |
43+
git config user.name "GitHub Actions"
44+
git config user.email "<>"
45+
46+
- name: commit
47+
run: |
48+
# Stage the file, commit and push
49+
git add lib/wpc_proto/gen/generated_protos/*
50+
git commit --allow-empty -m "Update generated proto files ${message}"
51+
git push origin ${GITHUB_REF}

.gitmodules

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[submodule "lib/wpc_proto/deps/backend-apis"]
2+
path = lib/wpc_proto/deps/backend-apis
3+
url = https://github.com/wirepas/backend-apis
4+
[submodule "lib/wpc_proto/deps/nanopb"]
5+
path = lib/wpc_proto/deps/nanopb
6+
url = https://github.com/nanopb/nanopb.git

example/linux/gw-example/Readme.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Gateway example
2+
3+
## Overview
4+
5+
This application example implements the Wirepas Gateway API (MQTT + protobuf messages) in a single monolithic application.
6+
7+
This example is based on Linux environment but can be used as a starting point for a different platform.
8+
Linux is chosen here as it is the default target for c-mesh-api library and it is easy to execute from a PC.
9+
10+
This example mainly demonstrates the usage of the proto API of c-mesh-api and the "glue" required to convert it into a Wirepas gateway with an MQTT client.
11+
12+
## Installation
13+
14+
In order to build this application in Ubuntu (only tested environment) you need the libpaho-mqtt library:
15+
16+
```bash
17+
sudo apt install libpaho-mqtt-dev
18+
```
19+
20+
Application can be built directly with following command:
21+
22+
```bash
23+
make
24+
```
25+
26+
## Usage
27+
28+
Some parameters are mandatory to start the application:
29+
30+
```bash
31+
Usage: gw-example -p <port name> [-b <baudrate>] -g <gateway_id> -H <mqtt hostname> [-U <mqtt user>] [-P <mqtt password>]
32+
```
33+
34+
## Limitation
35+
36+
This example implements only the "happy case". There is no buffering implemented in case the connection to the broker is down.
37+
Mqtt client is used in synchronous mode so may have an impact on the global performances.
38+

0 commit comments

Comments
 (0)