This repository should be used as a git submodule for the RF interface such as packet definition. The goal is to minimize the protocol interface difficulties encountered between the AV-GS-GSE-PL subsystems. By having this git submodule repository shared between subsystems, no more interface documents are required as a git pull would be sufficient to be updated.
Follow this link or directly the instructions below.
Go in your main project folder, which is alreay a git repository, and run:
git submodule add https://github.com/EPFLRocketTeam/ERT_RF_Protocol_Interface.git
By default, it will create a folder name "ERT_RF_Protocol_Interface". You can add a different path at the end of the command if you want it to go elsewhere.
Then in your C++ code, you can simply do:
#include <ERT_RF_Protocol_Interface/PacketDefinition.h>
Now you can have access to the struct definitions in your code, see the example at the end.
You will need to run git pull but from the submodule directory
git pull
Once you made some modifications to the code of this submodule, you need to go in the submodule folder (ERT_RF_Protocol_Interface), then you can run git status
to see if some changes are seen. If yes you need to add this files, commit with a message and finally push.
git add --all
git commit -m "uplink packet update"
git push
Note that as it is a private repository, you will need to connect to your account. You can read the next section for more infos.
- TODO: Maybe it is possible to directly push on this repo from the main repo ?
TODO
You can find some infos here or
- Click on your profile picture top right, and got to Settings
- Then go to Developer settings at the complete bottom
- Then to Personal Access Tokens > Tokens (classic) , i.e. here https://github.com/settings/tokens
- Generate New Token
- You need to select: [repo, gist, workflow, admin (read:org)]
Note that as you will see this token only once, you need to save it. If you want to avoid to insert your username and password (token) each time, run this before writing them. :warning: This might not be really safe as they will be stored on your computer in plain text.
git config credential.helper store
Then, when you git push
for example, you will need to write them, but only the first time.
$ git clone https://github.com/USERNAME/REPO.git
Username: YOUR_USERNAME
Password: YOUR_TOKEN
Some useful links:
- Git command cheat sheet https://education.github.com/git-cheat-sheet-education.pdf
- Markdown summary https://www.markdownguide.org/basic-syntax/
In Reception mode, imagine that a serial interface (e.g. UART, USB, LoRa, WiFi) sent you a byte array (in C++ it would be a pointer of uint8_t* with its length in bytes). Then here is a code example:
void get_packet_content(uint8_t* byte-array_ptr, size_t byte_array_length) { // arguments given by serial interface
PacketAV_uplink packetAV_uplink; // declare a new variable, in some case it may required dynamic allocation
if (byte_array_length == packetAV_uplink_size) { // check if same size, but you should use a better method
// This is the key function, copy the byte array at the struct address
memcpy(&packetAV_uplink, byte_array_ptr, packetAV_uplink_size);
// Now you can use & check every fields of the structure
if (packetAV_uplink.ventN2O == CMD_ACTIVE) {
printf("N2O valve active !");
}
}
}
In Transmission mode, this is quite similar, once your packet structure is filled with what you need, you can send the associated byte array to your serial interface function.
void send_packet_content(PacketAV_downlink &packetAV_downlink) { // you can pass the pointer directly or by reference
// Here are some examples
Serial.write(&packetAV_downlink, packetAV_downlink_size); // with write(uint8_t* byte_array, size_t size)
LoRa.write(&packetAV_downlink, packetAV_downlink_size);
udp.broadcastTo(&packetAV_downlink, packetAV_downlink_size, 1234); // UDP broadcast on port 1234
}