Skip to content

Commit

Permalink
Replace puml with inline mermaid
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcodenBesten committed Oct 24, 2024
1 parent 9fbd070 commit 80d0044
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 65 deletions.
70 changes: 59 additions & 11 deletions doc/networkconnectivity/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Network connection profile interface

libocpp automatically tries to connect using the given network connection profiles.
libocpp automatically tries to connect using the given network connection profiles.
However, if you want more control, you can use the callbacks provided for the network connection.

Check notice on line 4 in doc/networkconnectivity/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

doc/networkconnectivity/README.md#L4

Expected: 80; Actual: 97

libocpp will automatically connect to the network profile with the highest priority.
If this fails, it will network profile with the second highest priority, and so on.
libocpp will automatically connect to the network profile with the highest priority.
If this fails, it will network profile with the second highest priority, and so on.

## Set up interface (optional)

A callback can be implemented to set up the interface. For example, if the interface is a modem, it must first be
A callback can be implemented to set up the interface. For example, if the interface is a modem, it must first be

Check notice on line 11 in doc/networkconnectivity/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

doc/networkconnectivity/README.md#L11

Expected: 80; Actual: 114
be activated before it is possible to connect to this interface. To do this, you can implement the callback

Check notice on line 12 in doc/networkconnectivity/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

doc/networkconnectivity/README.md#L12

Expected: 80; Actual: 107
`std::future<ConfigNetworkResult>(configure_network_connection_profile_callback(configuration_slot, NetworkConnectionProfile))`

Check notice on line 13 in doc/networkconnectivity/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

doc/networkconnectivity/README.md#L13

Expected: 80; Actual: 127

Expand All @@ -19,24 +19,24 @@ std::future<ocpp::v201::ConfigNetworkResult> future = promise.get_future();
return future;
```

If the network was setup successfully, you can set the values in the promise with
If the network was setup successfully, you can set the values in the promise with
```cpp
promise.set_value(configNetworkResult);
```

Check notice on line 25 in doc/networkconnectivity/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

doc/networkconnectivity/README.md#L25

Fenced code blocks should be surrounded by blank lines
This way, libocpp knows that it can connect to the given interface and will try to do so.
This way, libocpp knows that it can connect to the given interface and will try to do so.

Check notice on line 26 in doc/networkconnectivity/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

doc/networkconnectivity/README.md#L26

Expected: 80; Actual: 90
A timeout can be configured using `NetworkConfigTimeout' to wait longer or shorter than the default 60 seconds.

Check notice on line 27 in doc/networkconnectivity/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

doc/networkconnectivity/README.md#L27

Expected: 80; Actual: 111

### Bind to a specific interface

In some cases there are multiple network interfaces available and you may want to connect to a specific one.
In `ConfigNetworkResult` you can specify which interface you want the websocket to bind to.
Sometimes an interface has more than one IP address (in the case of a local/auto link for example).
In this case you want the websocket to bind to a specific IP address. The `interface_address` in ConfigNetworkResult supports both.
In `ConfigNetworkResult` you can specify which interface you want the websocket to bind to.

Check notice on line 32 in doc/networkconnectivity/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

doc/networkconnectivity/README.md#L32

Expected: 80; Actual: 92
Sometimes an interface has more than one IP address (in the case of a local/auto link for example).

Check notice on line 33 in doc/networkconnectivity/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

doc/networkconnectivity/README.md#L33

Expected: 80; Actual: 100
In this case you want the websocket to bind to a specific IP address. The `interface_address` in ConfigNetworkResult supports both.

Check notice on line 34 in doc/networkconnectivity/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

doc/networkconnectivity/README.md#L34

Expected: 80; Actual: 132
It will bind to the given network interface (a string containing the name of the interface) or the given ip address (a string containing the ip address in human readable format).

## Connect to higher network connection profile priority (optional)

Normally, when libocpp is connected with a network connection profile, it will not disconnect.
Normally, when libocpp is connected with a network connection profile, it will not disconnect.

Check notice on line 39 in doc/networkconnectivity/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

doc/networkconnectivity/README.md#L39

Expected: 80; Actual: 95
However, there may be a situation where libocpp is connected to a profile with priority 2 or lower, and you find out at system level that an interface (with a higher priority) has changed and is now up.

Check notice on line 40 in doc/networkconnectivity/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

doc/networkconnectivity/README.md#L40

Expected: 80; Actual: 203
A call is added so that you can suggest that libocpp switch to this profile: `bool on_try_switch_network_connection_profile(const int32_t configuration_slot)`.

Check notice on line 41 in doc/networkconnectivity/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

doc/networkconnectivity/README.md#L41

Expected: 80; Actual: 159
libocpp will inform the caller by the return value if it tries to switch to this profile.

Check notice on line 42 in doc/networkconnectivity/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

doc/networkconnectivity/README.md#L42

Expected: 80; Actual: 89
Expand All @@ -52,4 +52,52 @@ in these callbacks, so you can keep the network connection in use (e.g. not disa

For step 9, ping is one way to check if a CSMS is up, but you of course can implement a way to check this yourself.

Check notice on line 53 in doc/networkconnectivity/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

doc/networkconnectivity/README.md#L53

Expected: 80; Actual: 115

![Sequence diagram](networkconnectivity_libocpp.png)
```mermaid
sequenceDiagram
participant csms
participant libocpp
participant core
autonumber
note over csms,libocpp: libocpp wants to connect to network connection profile
libocpp ->>+ core: std::future<ConfigNetworkResult>(configure_network_connection_profile_callback(<br>configuration_slot, NetworkConnectionProfile))

Check notice on line 64 in doc/networkconnectivity/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

doc/networkconnectivity/README.md#L64

Expected: 80; Actual: 148
note over core: ... possible delay ...
core ->> core: Setup network, e.g. setup modem
core ->>- libocpp: promise.set_value(status,<br>ip_address, etc)
alt within timeout
%% core ->> libocpp: on_network_update (ip address)
libocpp ->> csms: connect websocket (ip address)
csms ->> libocpp: ACK
libocpp ->> core: websocket_connected_callback(configuration_slot, NetworkConnectionProfile)
core ->> core: disable unneeded interfaces, <br>e.g. disable modem
else timeout reached, next network connection profile selected
libocpp -->> core: std::future<ConfigNetworkResult>(configure_network_connection_profile_callback(<br>configuration_slot, NetworkConnectionProfile)) (see 1)

Check notice on line 77 in doc/networkconnectivity/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

doc/networkconnectivity/README.md#L77

Expected: 80; Actual: 160
end
note over libocpp: CSMS is connected via connection profile prio 2 (for example modem) but prio 1 (for example eth0) comes up

Check notice on line 81 in doc/networkconnectivity/README.md

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

doc/networkconnectivity/README.md#L81

Expected: 80; Actual: 126
loop until prio 1 csms is found
core ->> csms: ping
end
core ->> libocpp: on_try_switch_networkconnectionprofile(configuration_slot)
libocpp -->> core: std::future<ConfigNetworkResult>(configure_network_connection_profile_callback(<br>configuration_slot, NetworkConnectionProfile)) (see 1)
note over csms,libocpp: Network is disconnected (for example networkcable removed)
core ->> libocpp: disconnect csms (on_network_disconnected(configuration_slot, OCPPInterfaceEnum)
libocpp ->> core: websocket_disconnected_callback(configuration_slot, NetworkConnectionProfile)
libocpp -->> core: std::future<ConfigNetworkResult>(configure_network_connection_profile_callback(<br>configuration_slot, NetworkConnectionProfile)) (see 1)
note over csms,libocpp: Network is disconnected (websocket timeout)
libocpp ->> libocpp: disconnect csms
libocpp ->> core: websocket_disconnected_callback(configuration_slot, NetworkConnectionProfile)
libocpp -->> core: std::future<ConfigNetworkResult>(configure_network_connection_profile_callback(<br>configuration_slot, NetworkConnectionProfile)) (see 1)
```
Binary file not shown.
54 changes: 0 additions & 54 deletions doc/networkconnectivity/networkconnectivity_libocpp.puml

This file was deleted.

0 comments on commit 80d0044

Please sign in to comment.