Browse Source

Add automatic library configuration to build setup task

master
Starbeamrainbowlabs 2 years ago
parent
commit
35b2dd447c
  1. 7
      README.md
  2. 50
      build

7
README.md

@ -21,13 +21,6 @@ Run `bash ./build setup` from the command line at the root of this repository.
### IoT Device
- Copy `settings.custom.cpp.example` to `settings.custom.cpp` and fill in the fields there
- Review `settings.h` to make sure it matches your setup
- Edit `iot/libraries/arduino-lmic/src/lmic/config.h`, and add the following to the bottom:
```c++
#define DISABLE_PING
#define DISABLE_BEACONS
```
- Copy the folders in `iot/libraries` to your Arduino IDE libraries folder
## Useful Links

50
build

@ -43,18 +43,60 @@ fi
###############################################################################
# Toggles commenting and uncommenting lines in a file that contain a specific
# substring. Checks for word boundaries either side of the substring.
# From https://stackoverflow.com/a/24901636/1460422
# $1 - Filename
# $2 - Search string
comment_toggle() {
filename="${1}";
search_string="${2}";
awk -v commentId='//' -v word="${search_string}" '
$0 ~ "(^|[[:punct:][:space:]])" word "($|[[:punct:][:space:]])" {
if (match($0, "^[[:space:]]*" commentId))
$0 = substr($0, RSTART + RLENGTH)
else
$0 = commentId $0
}
{ print }' "${filename}" > tmpfile.$$ && mv tmpfile.$$ "${filename}"
}
task_setup() {
task_begin "Setting up";
stage_begin "Setting up";
task_begin "Checking Environment";
check_command git true;
check_command awk true;
check_command pdflatex true;
check_command bibtex true;
task_end $?;
subtask_begin "Initialising submodules";
task_begin "Initialising submodules";
git submodule update --init;
subtask_end $?;
task_end $?;
task_begin "Preconfiguring libraries";
config_file_directory="./iot/libraries/arduino-lmic/src/lmic/";
config_file_name="config.h";
cd "${config_file_directory}";
git reset --hard;
# Disable OTAA
comment_toggle "${config_file_name}" "#define DISABLE_JOIN";
# Disable class b stuff
comment_toggle "${config_file_name}" "#define DISABLE_PING";
comment_toggle "${config_file_name}" "#define DISABLE_BEACONS";
# Disable other misc. stuff we're not likely to use
comment_toggle "${config_file_name}" "#define DISABLE_MCMD_DCAP_REQ"; # Duty cycle cap - won't work anyway 'cause we're shutting down in between
comment_toggle "${config_file_name}" "#define DISABLE_MCMD_DN2P_SET"; # Receiving stuff
# echo "#define DISABLE_JOIN" >>"${config_file_name}";
# echo "#define DISABLE_PING" >>"${config_file_name}";
# echo "#define DISABLE_BEACONS" >>"${config_file_name}";
cd -;
task_end $?;
task_end 0;
stage_end 0;
}
task_render() {

Loading…
Cancel
Save