Skip to content

Commit

Permalink
Merge branch 'master' into middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasssvaz authored Oct 8, 2024
2 parents 4668e78 + f083e2d commit 09ddacb
Show file tree
Hide file tree
Showing 250 changed files with 7,807 additions and 2,431 deletions.
49 changes: 40 additions & 9 deletions .github/scripts/install-platformio-esp32.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ PLATFORMIO_ESP32_URL="https://github.com/platformio/platform-espressif32.git"
TOOLCHAIN_VERSION="12.2.0+20230208"
ESPTOOLPY_VERSION="~1.40501.0"
ESPRESSIF_ORGANIZATION_NAME="espressif"
SDKCONFIG_DIR="$PLATFORMIO_ESP32_PATH/tools/esp32-arduino-libs"

echo "Installing Python Wheel ..."
pip install wheel > /dev/null 2>&1
Expand Down Expand Up @@ -88,12 +89,26 @@ function count_sketches(){ # count_sketches <examples-path>
local sketchname=$(basename $sketch)
if [[ "${sketchdirname}.ino" != "$sketchname" ]]; then
continue
elif [ -f $sketchdir/ci.json ]; then
# If the target is listed as false, skip the sketch. Otherwise, include it.
is_target=$(jq -r '.targets[esp32]' $sketchdir/ci.json)
if [[ "$is_target" == "false" ]]; then
continue
fi

# Check if the sketch requires any configuration options
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
for requirement in $requirements; do
requirement=$(echo $requirement | xargs)
found_line=$(grep -E "^$requirement" "$SDKCONFIG_DIR/esp32/sdkconfig")
if [[ "$found_line" == "" ]]; then
continue 2
fi
done
fi
fi
is_target=$(jq -r --arg target $target '.targets[$target]' $sketchdir/ci.json)
# If the target is listed as false, skip the sketch. Otherwise, include it.
if [[ "$is_target" == "false" ]]; then
continue
fi

echo $sketch >> sketches.txt
sketchnum=$(($sketchnum + 1))
done
Expand Down Expand Up @@ -163,12 +178,28 @@ function build_pio_sketches(){ # build_pio_sketches <board> <options> <examples-
local sketchdir=$(dirname $sketch)
local sketchdirname=$(basename $sketchdir)
local sketchname=$(basename $sketch)
is_target=$(jq -r --arg target $target '.targets[$target]' $sketchdir/ci.json)
# If the target is listed as false, skip the sketch. Otherwise, include it.
if [ "${sketchdirname}.ino" != "$sketchname" ] \
|| [[ "$is_target" == "false" ]]; then
if [[ "$sketchdirname.ino" != "$sketchname" ]]; then
continue
elif [ -f $sketchdir/ci.json ]; then
# If the target is listed as false, skip the sketch. Otherwise, include it.
is_target=$(jq -r '.targets[esp32]' $sketchdir/ci.json)
if [[ "$is_target" == "false" ]]; then
continue
fi

# Check if the sketch requires any configuration options
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
for requirement in $requirements; do
requirement=$(echo $requirement | xargs)
found_line=$(grep -E "^$requirement" "$SDKCONFIG_DIR/esp32/sdkconfig")
if [[ "$found_line" == "" ]]; then
continue 2
fi
done
fi
fi

sketchnum=$(($sketchnum + 1))
if [ "$sketchnum" -le "$start_index" ] \
|| [ "$sketchnum" -gt "$end_index" ]; then
Expand Down
82 changes: 59 additions & 23 deletions .github/scripts/sketch_utils.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/bin/bash

if [ -d "$ARDUINO_ESP32_PATH/tools/esp32-arduino-libs" ]; then
SDKCONFIG_DIR="$ARDUINO_ESP32_PATH/tools/esp32-arduino-libs"
elif [ -d "$GITHUB_WORKSPACE/tools/esp32-arduino-libs" ]; then
SDKCONFIG_DIR="$GITHUB_WORKSPACE/tools/esp32-arduino-libs"
else
SDKCONFIG_DIR="tools/esp32-arduino-libs"
fi

function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [extra-options]
while [ ! -z "$1" ]; do
case "$1" in
Expand Down Expand Up @@ -81,14 +89,21 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex

len=1

if [ -f $sketchdir/ci.json ]; then
fqbn_append=`jq -r '.fqbn_append' $sketchdir/ci.json`
if [ $fqbn_append == "null" ]; then
fqbn_append=""
fi
fi

# Default FQBN options if none were passed in the command line.

esp32_opts="PSRAM=enabled,PartitionScheme=huge_app,FlashMode=dio"
esp32s2_opts="PSRAM=enabled,PartitionScheme=huge_app,FlashMode=dio"
esp32s3_opts="PSRAM=opi,USBMode=default,PartitionScheme=huge_app,FlashMode=dio"
esp32c3_opts="PartitionScheme=huge_app,FlashMode=dio"
esp32c6_opts="PartitionScheme=huge_app,FlashMode=dio"
esp32h2_opts="PartitionScheme=huge_app,FlashMode=dio"
esp32_opts="PSRAM=enabled,FlashMode=dio${fqbn_append:+,$fqbn_append}"
esp32s2_opts="PSRAM=enabled,FlashMode=dio${fqbn_append:+,$fqbn_append}"
esp32s3_opts="PSRAM=opi,USBMode=default,FlashMode=dio${fqbn_append:+,$fqbn_append}"
esp32c3_opts="FlashMode=dio${fqbn_append:+,$fqbn_append}"
esp32c6_opts="FlashMode=dio${fqbn_append:+,$fqbn_append}"
esp32h2_opts="FlashMode=dio${fqbn_append:+,$fqbn_append}"

# Select the common part of the FQBN based on the target. The rest will be
# appended depending on the passed options.
Expand Down Expand Up @@ -140,16 +155,26 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex

sketchname=$(basename $sketchdir)

# If the target is listed as false, skip the sketch. Otherwise, include it.
if [ -f $sketchdir/ci.json ]; then
# If the target is listed as false, skip the sketch. Otherwise, include it.
is_target=$(jq -r --arg target $target '.targets[$target]' $sketchdir/ci.json)
else
is_target="true"
fi
if [[ "$is_target" == "false" ]]; then
echo "Skipping $sketchname for target $target"
exit 0
fi

if [[ "$is_target" == "false" ]]; then
echo "Skipping $sketchname for target $target"
exit 0
# Check if the sketch requires any configuration options
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
for requirement in $requirements; do
requirement=$(echo $requirement | xargs)
found_line=$(grep -E "^$requirement" "$SDKCONFIG_DIR/$target/sdkconfig")
if [[ "$found_line" == "" ]]; then
echo "Target $target does not meet the requirement $requirement for $sketchname. Skipping."
exit 0
fi
done
fi
fi

ARDUINO_CACHE_DIR="$HOME/.arduino/cache.tmp"
Expand Down Expand Up @@ -259,10 +284,11 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
unset options
}

function count_sketches(){ # count_sketches <path> [target] [file]
function count_sketches(){ # count_sketches <path> [target] [file] [ignore-requirements]
local path=$1
local target=$2
local file=$3
local ignore_requirements=$3
local file=$4

if [ $# -lt 1 ]; then
echo "ERROR: Illegal number of parameters"
Expand All @@ -275,7 +301,7 @@ function count_sketches(){ # count_sketches <path> [target] [file]
return 0
fi

if [ -n "$file" ]; then
if [ -f "$file" ]; then
local sketches=$(cat $file)
else
local sketches=$(find $path -name *.ino | sort)
Expand All @@ -288,16 +314,26 @@ function count_sketches(){ # count_sketches <path> [target] [file]
local sketchname=$(basename $sketch)
if [[ "$sketchdirname.ino" != "$sketchname" ]]; then
continue
elif [[ -n $target ]]; then
elif [[ -n $target ]] && [[ -f $sketchdir/ci.json ]]; then
# If the target is listed as false, skip the sketch. Otherwise, include it.
if [ -f $sketchdir/ci.json ]; then
is_target=$(jq -r --arg target $target '.targets[$target]' $sketchdir/ci.json)
else
is_target="true"
fi
is_target=$(jq -r --arg target $target '.targets[$target]' $sketchdir/ci.json)
if [[ "$is_target" == "false" ]]; then
continue
fi

if [ "$ignore_requirements" != "1" ]; then
# Check if the sketch requires any configuration options
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
for requirement in $requirements; do
requirement=$(echo $requirement | xargs)
found_line=$(grep -E "^$requirement" $SDKCONFIG_DIR/$target/sdkconfig)
if [[ "$found_line" == "" ]]; then
continue 2
fi
done
fi
fi
fi
echo $sketch >> sketches.txt
sketchnum=$(($sketchnum + 1))
Expand Down Expand Up @@ -374,7 +410,7 @@ function build_sketches(){ # build_sketches <ide_path> <user_path> <target> <pat

set +e
if [ -n "$sketches_file" ]; then
count_sketches "$path" "$target" "$sketches_file"
count_sketches "$path" "$target" "0" "$sketches_file"
local sketchcount=$?
else
count_sketches "$path" "$target"
Expand Down
50 changes: 34 additions & 16 deletions .github/scripts/tests_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,6 @@ function run_test() {
local result=0
local error=0

# If the target or platform is listed as false, skip the sketch. Otherwise, include it.
if [ -f $sketchdir/ci.json ]; then
is_target=$(jq -r --arg target $target '.targets[$target]' $sketchdir/ci.json)
selected_platform=$(jq -r --arg platform $platform '.platforms[$platform]' $sketchdir/ci.json)
else
is_target="true"
selected_platform="true"
fi

if [[ $is_target == "false" ]] || [[ $selected_platform == "false" ]]; then
printf "\033[93mSkipping $sketchname test for $target, platform: $platform\033[0m\n"
printf "\n\n\n"
return 0
fi

if [ $options -eq 0 ] && [ -f $sketchdir/ci.json ]; then
len=`jq -r --arg target $target '.fqbn[$target] | length' $sketchdir/ci.json`
if [ $len -eq 0 ]; then
Expand All @@ -34,6 +19,38 @@ function run_test() {
len=1
fi

if [ $len -eq 1 ]; then
SDKCONFIG_PATH="$HOME/.arduino/tests/$sketchname/build.tmp/sdkconfig"
else
SDKCONFIG_PATH="$HOME/.arduino/tests/$sketchname/build0.tmp/sdkconfig"
fi

if [ -f $sketchdir/ci.json ]; then
# If the target or platform is listed as false, skip the sketch. Otherwise, include it.
is_target=$(jq -r --arg target $target '.targets[$target]' $sketchdir/ci.json)
selected_platform=$(jq -r --arg platform $platform '.platforms[$platform]' $sketchdir/ci.json)

if [[ $is_target == "false" ]] || [[ $selected_platform == "false" ]]; then
printf "\033[93mSkipping $sketchname test for $target, platform: $platform\033[0m\n"
printf "\n\n\n"
return 0
fi

# Check if the sketch requires any configuration options
requirements=$(jq -r '.requires[]? // empty' $sketchdir/ci.json)
if [[ "$requirements" != "null" ]] || [[ "$requirements" != "" ]]; then
for requirement in $requirements; do
requirement=$(echo $requirement | xargs)
found_line=$(grep -E "^$requirement" "$SDKCONFIG_PATH")
if [[ "$found_line" == "" ]]; then
printf "\033[93mTarget $target does not meet the requirement $requirement for $sketchname. Skipping.\033[0m\n"
printf "\n\n\n"
return 0
fi
done
fi
fi

if [ $len -eq 1 ]; then
# build_dir="$sketchdir/build"
build_dir="$HOME/.arduino/tests/$sketchname/build.tmp"
Expand Down Expand Up @@ -212,7 +229,8 @@ else
fi

set +e
${COUNT_SKETCHES} $test_folder $target
# Ignore requirements as we don't have the libs. The requirements will be checked in the run_test function
${COUNT_SKETCHES} "$test_folder" "$target" "1"
sketchcount=$?
set -e
sketches=$(cat sketches.txt)
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tests_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
~/.arduino/tests/**/build*.tmp/*.bin
~/.arduino/tests/**/build*.tmp/*.elf
~/.arduino/tests/**/build*.tmp/*.json
~/.arduino/tests/**/build*.tmp/sdkconfig
- name: Evaluate if tests should be built
id: check-build
Expand Down Expand Up @@ -75,6 +76,7 @@ jobs:
~/.arduino/tests/**/build*.tmp/*.bin
~/.arduino/tests/**/build*.tmp/*.elf
~/.arduino/tests/**/build*.tmp/*.json
~/.arduino/tests/**/build*.tmp/sdkconfig
- name: Upload ${{ inputs.chip }} ${{ inputs.type }} binaries as artifacts
uses: actions/upload-artifact@v4
Expand All @@ -85,3 +87,4 @@ jobs:
~/.arduino/tests/**/build*.tmp/*.bin
~/.arduino/tests/**/build*.tmp/*.elf
~/.arduino/tests/**/build*.tmp/*.json
~/.arduino/tests/**/build*.tmp/sdkconfig
4 changes: 0 additions & 4 deletions .github/workflows/tests_hw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ jobs:
sparse-checkout: |
*
- name: List files
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
run: ls -la

# setup-python currently only works on ubuntu images
# - uses: actions/setup-python@v5
# if: ${{ steps.check-tests.outputs.enabled == 'true' }}
Expand Down
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ set(ARDUINO_ALL_LIBRARIES
WiFi
WiFiProv
Wire
Zigbee
)

set(ARDUINO_LIBRARY_ArduinoOTA_SRCS libraries/ArduinoOTA/src/ArduinoOTA.cpp)
Expand Down Expand Up @@ -244,6 +245,18 @@ set(ARDUINO_LIBRARY_WiFiProv_SRCS libraries/WiFiProv/src/WiFiProv.cpp)

set(ARDUINO_LIBRARY_Wire_SRCS libraries/Wire/src/Wire.cpp)

set(ARDUINO_LIBRARY_Zigbee_SRCS
libraries/Zigbee/src/ZigbeeCore.cpp
libraries/Zigbee/src/ZigbeeEP.cpp
libraries/Zigbee/src/ZigbeeHandlers.cpp
libraries/Zigbee/src/ep/ZigbeeColorDimmableLight.cpp
libraries/Zigbee/src/ep/ZigbeeColorDimmerSwitch.cpp
libraries/Zigbee/src/ep/ZigbeeLight.cpp
libraries/Zigbee/src/ep/ZigbeeSwitch.cpp
libraries/Zigbee/src/ep/ZigbeeTempSensor.cpp
libraries/Zigbee/src/ep/ZigbeeThermostat.cpp
)

set(ARDUINO_LIBRARY_BLE_SRCS
libraries/BLE/src/BLE2901.cpp
libraries/BLE/src/BLE2902.cpp
Expand Down
Loading

0 comments on commit 09ddacb

Please sign in to comment.