Skip to content

Commit 6a0f80f

Browse files
committed
Create README.md
1 parent 0462ffd commit 6a0f80f

14 files changed

+131
-6
lines changed

CMakeLists.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
cmake_minimum_required(VERSION 3.19)
1+
cmake_minimum_required(VERSION 3.15)
22
project(basic_grpc)
33

44
# Support C++ 14
55
set(CMAKE_CXX_STANDARD 14)
66

77
## Enable testing targets
8-
option(ChirpStackClient_TESTING "Enable testing targets" ON)
8+
option(ChirpStackClient_TESTING "Enable testing targets" OFF)
99

1010
# Find Threads package
1111
find_package(Threads)
@@ -69,7 +69,7 @@ foreach(google_proto ${google_protos})
6969
list(APPEND google_grpc_hdrs ${current_grpc_hdrs})
7070
endforeach()
7171

72-
# Generate Chirpstack API
72+
# Generate ChirpStack API
7373
get_filename_component(chirpstack_proto_dir "modules/chirpstack-api/protobuf/" ABSOLUTE)
7474
file(GLOB_RECURSE chirpstack_protos RELATIVE ${chirpstack_proto_dir} ${chirpstack_proto_dir}/*.proto)
7575
set(chirpstack_proto_srcs "")
@@ -103,7 +103,7 @@ endforeach()
103103
include_directories(${CMAKE_CURRENT_BINARY_DIR})
104104

105105
# Create chirpstack_grpc_proto target
106-
add_library(chirpstack_grpc_proto
106+
add_library(chirpstack_grpc_proto SHARED
107107
${chirpstack_proto_srcs}
108108
${chirpstack_proto_hdrs}
109109
${chirpstack_grpc_srcs}
@@ -126,7 +126,7 @@ set(chirpstack_client_srcs
126126
set(chirpstack_client_hdrs
127127
"include/chirpstack_client/chirpstack_client.h"
128128
"include/chirpstack_client/messages.h")
129-
add_library(chirpstack_client
129+
add_library(chirpstack_client SHARED
130130
${chirpstack_client_srcs}
131131
${chirpstack_client_hdrs})
132132
target_link_libraries(chirpstack_client
@@ -139,4 +139,4 @@ target_include_directories(chirpstack_client
139139

140140
if (ChirpStackClient_TESTING)
141141
add_subdirectory(tests)
142-
endif()
142+
endif()

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# ChirpStack Client
2+
3+
## Building
4+
5+
### How to build
6+
7+
As for many C++ projects, **ChirpStack Client** can be built using the CMake build system. The minimum required version of CMake is 3.15. To build **ChirpStack Client**, use the following commands:
8+
9+
```bash
10+
$ mkdir bin
11+
$ cd bin
12+
$ cmake ..
13+
$ cmake --build . -- -j 8
14+
```
15+
16+
The shared libraries will be located at `bin/libchirpstack_client.so` and `bin/libchirpstack_grpc_proto.so`.
17+
18+
### Note
19+
20+
- **gRPC** should be installed in advance. See also: [grpc-cpp](https://github.com/chungphb/grpc-cpp).
21+
- You might also need to copy the `grpc/third_party/googleapis/google/` and `grpc/third_party/protobuf/src/google/` directories to the `/usr/local/include/` directory beforehand.
22+
23+
## Testing
24+
25+
### How to build
26+
27+
To build **ChirpStack Client** with tests, use the following commands:
28+
29+
```bash
30+
$ mkdir bin
31+
$ cd bin
32+
$ cmake -DChirpStackClient_TESTING=ON ..
33+
$ cmake --build . -- -j 8
34+
```
35+
36+
The test binary files will be located at `bin/tests/`.
37+
38+
### How to configure
39+
40+
Before testing, you have to modify the TOML configuration file located at `bin/tests/test_config.toml`. Since most of the fields already have a default value, you only need to fill in 3 fields:
41+
42+
- `test.jwt_token`
43+
- Using in the `application`, `device`, `device_profile`, `gateway`, `internal` and `multicast_group` tests.
44+
- Can be acquired in the `Token` field after creating a new API key using **ChirpStack Application Server** web-interface.
45+
- `test.service_profile_id`
46+
- Using in the `application`, `device`, `device_profile`, `gateway`, `internal` and `multicast_group` tests.
47+
- Can be acquired in the URL after creating a new service-profile using **ChirpStack Application Server** web-interface.
48+
- `test.global_jwt_token`
49+
- Using in the `gateway_profile`, `network_server`, `organization`, `service_profile` and `user` tests.
50+
- Can be acquired in the `Token` field after creating a new API key using **ChirpStack Application Server** web-interface.
51+
52+
### Detail
53+
54+
| Test | Tested functions | Configuration parameters |
55+
| ---------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
56+
| `application_test` | - `create_application`<br />- `get_application`<br />- `update_application`<br />- `delete_application`<br />- `list_application` | - `general.application_server`<br />- `test.jwt_token`<br />- `test.service_profile_id`<br />- `test.application.name` |
57+
| `device_test` | - `create_device`<br />- `get_device`<br />- `update_device`<br />- `delete_device`<br />- `list_device`<br />- `create_device_keys`<br />- `get_device_keys`<br />- `update_device_keys`<br />- `delete_device_keys`<br />- `activate_device`<br />- `deactivate_device`<br />- `get_device_activation`<br />- `get_random_dev_addr`<br />- `enqueue_device_queue_item`<br />- `flush_device_queue`<br />- `list_device_queue_items` | - `general.application_server`<br />- `test.jwt_token`<br />- `test.service_profile_id`<br />- `test.application.name`<br />- `test.device_profile.name`<br />- `test.device.eui`<br />- `test.device.nwk_key`<br />- `test.device.app_key`<br />- `test.device.address`<br />- `test.device.app_s_key`<br />- `test.device.nwk_s_enc_key`<br />- `test.device.s_nwk_int_key`<br />- `test.device.f_nwk_int_key`<br />- `test.device.f_port`<br />- `test.device.payload` |
58+
| `device_profile_test` | - `create_device_profile`<br />- `get_device_profile`<br />- `update_device_profile`<br />- `delete_device_profile`<br />- `list_device_profile` | - `general.application_server`<br />- `test.jwt_token`<br />- `test.service_profile_id`<br />- `test.device_profile.name` |
59+
| `gateway_test` | - `create_gateway`<br />- `get_gateway`<br />- `update_gateway`<br />- `delete_gateway`<br />- `list_gateway`<br />- `get_gateway_stats`<br />- `get_last_ping`<br />- `generate_gateway_client_certificate` | - `general.application_server`<br />- `test.jwt_token`<br />- `test.service_profile_id`<br />- `test.gateway.id` |
60+
| `gateway_profile_test` | - `create_gateway_profile`<br />- `get_gateway_profile`<br />- `update_gateway_profile`<br />- `delete_gateway_profile`<br />- `list_gateway_profile` | - `general.application_server`<br />- `test.global_jwt_token`<br />- `test.service_profile_id`<br />- `test.gateway_profile.name`<br />- `test.gateway_profile.bandwidth`<br />- `test.gateway_profile.frequency`<br />- `test.gateway_profile.spreading_factors` |
61+
| `internal_test` | - `login`<br />- `profile`<br />- `global_search`<br />- `create_api_key`<br />- `delete_api_key`<br />- `list_api_keys`<br />- `settings`<br />- `open_id_connect_login`<br />- `get_devices_summary`<br />- `get_gateways_summary` | - `general.application_server`<br />- `test.jwt_token`<br />- `test.service_profile_id`<br />- `test.internal.admin_username`<br />- `test.internal.admin_password`<br />- `test.internal.api_key_name` |
62+
| `multicast_group_test` | - `create_multicast_group`<br />- `get_multicast_group`<br />- `update_multicast_group`<br />- `delete_multicast_group`<br />- `list_multicast_group`<br />- `add_device_to_multicast_group`<br />- `remove_device_from_multicast_group`<br />- `enqueue_multicast_queue_item`<br />- `flush_multicast_group_queue_items`<br />- `list_multicast_group_queue_items` | - `general.application_server`<br />- `test.jwt_token`<br />- `test.service_profile_id`<br />- `test.application.name`<br />- `test.device_profile.name`<br />- `test.device.eui`<br />- `test.device.address`<br />- `test.device.app_s_key`<br />- `test.device.nwk_s_enc_key`<br />- `test.device.s_nwk_int_key`<br />- `test.device.f_nwk_int_key`<br />- `test.device.f_port`<br />- `test.device.payload`<br />- `test.multicast_group.name`<br />- `test.multicast_group.address`<br />- `test.multicast_group.app_s_key`<br />- `test.multicast_group.nwk_s_key` |
63+
| `network_server_test` | - `create_network_server`<br />- `get_network_server`<br />- `update_network_server`<br />- `delete_network_server`<br />- `list_network_server`<br />- `get_adr_algorithms` | - `general.application_server`<br />- `test.global_jwt_token`<br />- `test.network_server.name`<br />- `test.network_server.server` |
64+
| `organization_test` | - `create_organization`<br />- `get_organization`<br />- `update_organization`<br />- `delete_organization`<br />- `list_organization`<br />- `add_organization_user`<br />- `get_organization_user`<br />- `update_organization_user`<br />- `delete_organization_user`<br />- `list_organization_users` | - `general.application_server`<br />- `test.global_jwt_token`<br />- `test.organization.name`<br />- `test.organization.display_name`<br />- `test.user.username`<br />- `test.user.password` |
65+
| `service_profile_test` | - `create_server_profile`<br />- `get_server_profile`<br />- `update_server_profile`<br />- `delete_server_profile`<br />- `list_server_profile` | - `general.application_server`<br />- `test.global_jwt_token`<br />- `test.network_server.name`<br />- `test.network_server.server`<br />- `test.organization.name`<br />- `test.organization.display_name`<br />- `test.service_profile.name` |
66+
| `user_test` | - `create_user`<br />- `get_user`<br />- `update_user`<br />- `delete_user`<br />- `list_user`<br />- `update_user_password` | - `general.application_server`<br />- `test.global_jwt_token`<br />- `test.user.username`<br />- `test.user.password` |
67+
68+
### Note
69+
70+
- The `network-server` and `service-profile` tests require manually running a new instance of **ChirpStack Network Server** to reduce the effects on other existing instances. To do that, they will generate 2 bash files `start-sample-network-server.sh` and `stop-sample-network-server.sh` to the `bin/tests/` directory. You should follow the instruction of the tests to be able to run them correctly.
71+
72+
## License
73+
74+
This project is licensed under the terms of the MIT license.

tests/application_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//
2+
// Created by vht on 6/24/21.
3+
//
4+
15
#include "test_config.h"
26
#include <chirpstack_client/chirpstack_client.h>
37
#include <iostream>

tests/device_profile_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//
2+
// Created by vht on 6/24/21.
3+
//
4+
15
#include "test_config.h"
26
#include <chirpstack_client/chirpstack_client.h>
37
#include <iostream>

tests/device_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//
2+
// Created by vht on 6/24/21.
3+
//
4+
15
#include "test_config.h"
26
#include <chirpstack_client/chirpstack_client.h>
37
#include <iostream>

tests/gateway_profile_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//
2+
// Created by vht on 6/24/21.
3+
//
4+
15
#include "test_config.h"
26
#include <chirpstack_client/chirpstack_client.h>
37
#include <iostream>

tests/gateway_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//
2+
// Created by vht on 6/24/21.
3+
//
4+
15
#include "test_config.h"
26
#include <chirpstack_client/chirpstack_client.h>
37
#include <iostream>

tests/internal_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//
2+
// Created by vht on 6/24/21.
3+
//
4+
15
#include "test_config.h"
26
#include <chirpstack_client/chirpstack_client.h>
37
#include <iostream>

tests/multicast_group_test.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//
2+
// Created by vht on 6/24/21.
3+
//
4+
15
#include "test_config.h"
26
#include <chirpstack_client/chirpstack_client.h>
37
#include <iostream>
@@ -379,6 +383,9 @@ void validate_config() {
379383
if (test_config().dev_payload.empty()) {
380384
throw std::runtime_error("Invalid device payload");
381385
}
386+
if (test_config().mc_name.empty()) {
387+
throw std::runtime_error("Invalid multicast-group name");
388+
}
382389
if (test_config().mc_address.empty()) {
383390
throw std::runtime_error("Invalid multicast-group address");
384391
}

tests/network_server_test.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//
2+
// Created by vht on 6/24/21.
3+
//
4+
15
#include "test_config.h"
26
#include <chirpstack_client/chirpstack_client.h>
37
#include <sys/stat.h>

0 commit comments

Comments
 (0)