You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- Provide a single sentence or a short paragraph describing the module's purpose. When using the documentation inside repository, add link to the README and vice versa - link the README to this documentation.
3
+
<!-- Provide a single sentence or a short paragraph describing the module's purpose. When using the documentation inside repository, add link to the README and vice versa - link the README to this documentation.-->
4
4
5
-
Example:
6
-
7
-
The Test module is provides communication between car test devices and the testing application. For more details on the usage of the module, see the [README](<path-to-readme>).
8
-
-->
5
+
This module serves as an example for module maintainers to implement their own modules outside reserved range of modules and does not serve any role in the production environment.
9
6
10
7
# Identification and supported devices
11
8
12
-
<!-- Provide a list of supported devices and their identification.
13
-
14
-
Example:
9
+
<!-- Provide a list of supported devices and their identification. -->
| button1 | 0 | test | Button driving a state of a dedicated LED |
18
+
| button1 | 10 | test | Button driving a state of a dedicated LED |
19
+
| button2 | 0 | test2 | Button driving a state of a dedicated LED |
26
20
27
-
# Messages
28
21
29
-
<!-- Describe all types of messages handled by the module (including status, status error and command). For each type, describe the message contents, structure and example of the message.
22
+
# Messages
30
23
31
-
Example of a status description:
24
+
<!-- Describe all types of messages handled by the module (including status, status error and command). For each type, describe the message contents, structure and example of the message. -->
32
25
33
26
## Status
34
27
35
-
The status message contains information about test components with their state (`ON` or `OFF`).
28
+
Each device (button) expects a status message containing a single key `pressed` with a boolean value indicating whether the button is pressed.
36
29
37
30
### Example
38
31
39
32
```json
40
-
{"state": "ON"}
33
+
{
34
+
"pressed": true
35
+
}
36
+
```
37
+
## Status Error
38
+
39
+
Status errors are not defined for this module.
40
+
41
+
## Command
42
+
43
+
Each device (button) expects a command message containing a single key `lit_up` with a boolean value indicating whether the LED should be lit up.
44
+
45
+
### Example
46
+
47
+
```json
48
+
{
49
+
"lit_up": true
50
+
}
41
51
```
42
-
-->
43
52
44
53
# Details of supported devices
45
54
@@ -50,3 +59,11 @@ The status message contains information about test components with their state (
50
59
- how the state is affected by the received command.
51
60
52
61
-->
62
+
63
+
## Button
64
+
65
+
Button is a simple button device which has one LED attached to it. As status, it sends JSON with key `"pressed"` indicating whether button is pressed. As command, it expects JSON with key `"lit_up"` indicating the desired state of internal LED.
66
+
67
+
See the state transition diagram below:
68
+
69
+

This repo contains implementation of example module device using internal client for fleet protocol v2.
4
-
These devices is a virtual button which sends it's current state and expects state of it's LED as response.
4
+
These devices is a virtual button which sends its current state and expects state of it's LED as response.
5
5
6
6
#### Preparing environment
7
+
7
8
Before running example devices, it is good practice to create a virtual environment:
8
-
```
9
+
10
+
```bash
9
11
python -m venv .venv
10
12
source .venv/bin/activate
11
13
```
14
+
12
15
Install dependencies:
13
-
```
16
+
17
+
```bash
14
18
pip install -r requirements.txt
15
19
```
16
20
17
21
## Button
18
-
Button is a simple button device which has one LED attached to it. As status, it sends json with key `"pressed"` indicationg wheter button is pressed. As command, it expects json with key `"lit_up"` indicating the desired state of internal LED.
22
+
23
+
Button is a simple button device which has one LED attached to it. As status, it sends JSON with key `"pressed"` indicating whether button is pressed. As command, it expects JSON with key `"lit_up"` indicating the desired state of internal LED.
24
+
19
25
### Usage
26
+
20
27
Fake buttons can be run with `run_buttons.py` script. It expects config in `yaml` format which specifies attributes for button or multiple buttons (see `buttons.yaml`):
28
+
21
29
```yaml
22
30
- button1_name:
23
31
type: <int> specifying module specific device type (default is 0)
Multiple fake buttons will be created according to yaml config. They will try to connect to specified server, generate and send their statuses periodically and set their LED states according to commands.
35
45
36
-
> Manual mode of actual button pressing on keyboard can be specified by `--manual` argument.
46
+
> Manual mode of actual button pressing on keyboard can be specified by `--manual` argument.
0 commit comments