Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 13 additions & 24 deletions .github/workflows/PR_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- uses: pre-commit/[email protected]
gcc:
name: GCC
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
Expand All @@ -22,16 +22,10 @@ jobs:
steps:
- name: Install
run: |
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ trusty main'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ trusty universe'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ xenial main'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ xenial universe'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ bionic main'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ bionic universe'
sudo apt-get update
sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }}
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Configure
Expand All @@ -47,25 +41,20 @@ jobs:

clang:
name: Clang
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- clang: "10"
- clang: "16"
cxxflags: -fsanitize=leak -fno-sanitize-recover=all
steps:
- name: Install
run: |
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ trusty main'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ trusty universe'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ xenial main'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ xenial universe'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ bionic main'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ bionic universe'
sudo apt-get update
sudo apt-get install -y clang-${{ matrix.clang }}
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Configure
Expand All @@ -92,7 +81,7 @@ jobs:
- xcode: "16.1"
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Select XCode version
Expand All @@ -114,7 +103,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Configure
Expand All @@ -125,9 +114,9 @@ jobs:
run: ctest --output-on-failure -V -C Debug .

examples:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
Expand All @@ -143,9 +132,9 @@ jobs:
find . -name platformio.ini -type f | sed 's,/platformio.ini$,,' | xargs --verbose -n 1 pio run --jobs 2 --project-dir

python:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0 # deep clone for setuptools-scm
Expand Down
53 changes: 8 additions & 45 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,18 @@ jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.11'
- uses: pre-commit/[email protected]
gcc:
name: GCC
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- gcc: "4.6"
- gcc: "4.7"
- gcc: "4.8"
- gcc: "4.9"
- gcc: "5"
- gcc: "6"
- gcc: "7"
cxxflags: -fsanitize=leak -fno-sanitize-recover=all
- gcc: "8"
Expand All @@ -36,16 +30,10 @@ jobs:
steps:
- name: Install
run: |
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ trusty main'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ trusty universe'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ xenial main'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ xenial universe'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ bionic main'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ bionic universe'
sudo apt-get update
sudo apt-get install -y gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }}
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Configure
Expand All @@ -63,45 +51,20 @@ jobs:

clang:
name: Clang
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- clang: "3.5"
cxxflags: "-stdlib=libc++"
- clang: "3.6"
cxxflags: "-stdlib=libc++"
- clang: "3.7"
cxxflags: "-stdlib=libc++"
- clang: "3.8"
cxxflags: "-stdlib=libc++"
- clang: "3.9"
cxxflags: "-stdlib=libc++"
- clang: "4.0"
cxxflags: "-stdlib=libc++"
- clang: "5.0"
- clang: "6.0"
- clang: "7"
- clang: "8"
- clang: "16"
cxxflags: -fsanitize=leak -fno-sanitize-recover=all
- clang: "9"
cxxflags: -fsanitize=undefined -fno-sanitize-recover=all
- clang: "10"
cxxflags: -fsanitize=address -fno-sanitize-recover=all
steps:
- name: Install
run: |
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ trusty main'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ trusty universe'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ xenial main'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ xenial universe'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ bionic main'
sudo add-apt-repository -yn 'deb http://archive.ubuntu.com/ubuntu/ bionic universe'
sudo apt-get update
sudo apt-get install -y clang-${{ matrix.clang }}
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Configure
Expand Down Expand Up @@ -130,7 +93,7 @@ jobs:
- xcode: "16.1"
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Select XCode version
Expand All @@ -153,7 +116,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: recursive
- name: Configure
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/manual_test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
jobs:
build-n-publish:
name: Build and publish distribution to TestPyPI
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0 # deep clone for setuptools-scm
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ on:
jobs:
build-n-publish:
name: Build and publish distributions to PyPI
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0 # deep clone for setuptools-scm
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ on:
types: [published]
jobs:
documentation:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
name: Create the documentation and deploy it to GitHub Pages
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v3
with:
Expand Down
27 changes: 14 additions & 13 deletions src/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@
#ifdef DEBUG_DECODER
# include <stdio.h>
# define DEBUG_PRINT(...) \
{ printf(__VA_ARGS__); }
{ \
printf(__VA_ARGS__); \
}
#else
# define DEBUG_PRINT(...) \
{}
{ \
}
#endif

#ifdef UNIT_TESTING
Expand Down Expand Up @@ -63,7 +66,7 @@ void TheengsDecoder::reverse_hex_data(const char* in, char* out, int l) {
i -= 2;
j += 2;
}
out[l] = '\0';
out[j] = '\0';
}

double TheengsDecoder::bf_value_from_hex_string(const char* data_str,
Expand Down Expand Up @@ -285,9 +288,9 @@ bool TheengsDecoder::checkDeviceMatch(const JsonArray& condition,
string_to_compare = mac_string.c_str();

if (strstr(cond_str, "revmac@index") != nullptr) {
char* reverse_mac_string = (char*)malloc(strlen(string_to_compare) + 1);

char reverse_mac_string[13]; // 12 bytes + null terminator
reverse_hex_data(string_to_compare, reverse_mac_string, 12);
reverse_mac_string[12] = '\0'; // Ensure null termination
string_to_compare = reverse_mac_string;
}

Expand All @@ -302,9 +305,7 @@ bool TheengsDecoder::checkDeviceMatch(const JsonArray& condition,
string_to_compare,
cond_index);

if (strncmp(&cmp_str[cond_index],
string_to_compare,
12) == 0) {
if (strncmp(&cmp_str[cond_index], string_to_compare, 12) == 0) {
match = true;
} else {
match = false;
Expand Down Expand Up @@ -439,14 +440,14 @@ bool TheengsDecoder::checkPropCondition(const JsonArray& prop_condition,
cond_met = evaluateDatalength(op, data_len, req_len);
}
} else if (dev_name != nullptr && strstr(prop_condition[i].as<const char*>(), "name") != nullptr) {
if (strstr(prop_condition[i+1].as<const char*>(), "contain") != nullptr) {
if (strstr(dev_name, prop_condition[i+2].as<const char*>()) != nullptr) {
cond_met = (strstr(prop_condition[i+1].as<const char*>(), "not_") != nullptr) ? false : true;
if (strstr(prop_condition[i + 1].as<const char*>(), "contain") != nullptr) {
if (strstr(dev_name, prop_condition[i + 2].as<const char*>()) != nullptr) {
cond_met = (strstr(prop_condition[i + 1].as<const char*>(), "not_") != nullptr) ? false : true;
} else {
cond_met = (strstr(prop_condition[i+1].as<const char*>(), "not_") != nullptr) ? true : false;
cond_met = (strstr(prop_condition[i + 1].as<const char*>(), "not_") != nullptr) ? true : false;
}
}

} else {
DEBUG_PRINT("ERROR property condition data source invalid\n");
return false;
Expand Down