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
83 changes: 67 additions & 16 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,78 @@
name: Run Tests
name: CI

on:
push:
branches: [ master ]
branches: [main, master]
tags: ["v*"]
pull_request:
branches: [main, master]
workflow_dispatch:

jobs:
test:
arduino-lint:
name: arduino-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: arduino/arduino-lint-action@v2
with:
library-manager: update
project-type: library
compliance: specification
recursive: true

host-tests:
name: host Catch2 tests (Ubuntu c++)
runs-on: ubuntu-latest
needs: arduino-lint
steps:
- uses: actions/checkout@v4
- name: Install build-essential (make / c++)
run: sudo apt-get update -qq && sudo apt-get install -y -qq build-essential
- name: Run host tests (clean-first via ci-test to defeat any stale cached .o)
working-directory: tests
run: make ci-test

compile-examples:
name: Compile Arduino examples (ESP8266 + ESP32)
runs-on: ubuntu-latest
needs: host-tests
strategy:
fail-fast: false
matrix:
include:
- fqbn: esp8266:esp8266:d1_mini
platform: esp8266:esp8266
platform-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json
example: examples/ESP32_SNMP
- fqbn: esp32:esp32:esp32
platform: esp32:esp32
platform-url: https://dl.espressif.com/dl/package_esp32_index.json
example: examples/ESP32_SNMP
- fqbn: esp8266:esp8266:d1_mini
platform: esp8266:esp8266
platform-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json
example: examples/SNMP_Sensor
- fqbn: esp32:esp32:esp32
platform: esp32:esp32
platform-url: https://dl.espressif.com/dl/package_esp32_index.json
example: examples/SNMP_Sensor
steps:
- uses: actions/checkout@v2
- name: arduino/arduino-lint-action
uses: arduino/arduino-lint-action@v1.0.0
with:
library-manager: update
- name: run tests
run: |
cd tests
make test
- name: compile example
run: |
cd tests
make example
- uses: actions/checkout@v4
- name: Install arduino-cli
run: |
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/usr/local/bin sh
arduino-cli version
- name: Add 3rd-party platform URLs
run: |
arduino-cli config init
arduino-cli config set board_manager.additional_urls '${{ matrix.platform-url }}'
arduino-cli core update-index
- name: Install platform core
run: arduino-cli core install ${{ matrix.platform }}
- name: Install example-library deps (ArduinoJson — used by SNMP_Sensor)
run: arduino-cli lib install "ArduinoJson"
- name: Install library (self, by path)
run: arduino-cli lib install --no-deps --git-url . || true
- name: Compile sketch ${{ matrix.example }} for ${{ matrix.fqbn }}
run: arduino-cli compile --fqbn ${{ matrix.fqbn }} --libraries . ${{ matrix.example }}
195 changes: 182 additions & 13 deletions README.md

Large diffs are not rendered by default.

31 changes: 24 additions & 7 deletions examples/ESP32_SNMP/ESP32_SNMP.ino
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
#if defined (ESP8266)
#include <ESP8266WiFi.h> // ESP8266 Core WiFi Library
#include <ESP8266WiFi.h> // ESP8266 Core WiFi Library
#else
#include <WiFi.h> // ESP32 Core WiFi Library
#include <WiFi.h> // ESP32 Core WiFi Library
#endif

/* -------------------------------------------------------------------------- *
* COMPILE-TIME TUNING (optional, BEFORE #include <SNMP_Agent.h>)
*
* All SNMP size constants in src/include/defs.h are wrapped with
* `#ifndef ... #endif` so a sketch-side #define placed here wins over the
* library defaults. Good targets for ESP-01 1 MB / 80 KB RAM sensors:
*
* #define SNMP_MAX_COMPLEX_CHILDREN 8
* #define SNMP_MAX_VARBINDS 4
* #define SNMP_MAX_CALLBACKS_PER_AGENT 16
* #define SNMP_MAX_TRAPS_INFLIGHT 4
* #define SNMP_POOL_ASN_OBJECTS 32
* #define SNMP_POOL_VARBIND_OBJECTS 12
*
* Saves ~25 KB BSS (ASNPool halves: (64 - 32) * 768 B = 24,576 B) and a
* few KB more from smaller fixed callback/varbind arrays.
* -------------------------------------------------------------------------- */

#include <WiFiUdp.h>
#include <SNMP_Agent.h>
#include <SNMPTrap.h>
Expand All @@ -21,19 +39,20 @@ int settableNumber = 0;
uint32_t tensOfMillisCounter = 0;

// arbitrary data will be stored here to act as an OPAQUE data-type
uint8_t* stuff = 0;
uint8_t stuff[4];


// If we want to change the functionaality of an OID callback later, store them here.
ValueCallback* changingNumberOID;
ValueCallback* settableNumberOID;
TimestampCallback* timestampCallbackOID;

std::string staticString = "This value will never change";
char staticString[] = "This value will never change";

// Setup an SNMPTrap for later use
SNMPTrap* settableNumberTrap = new SNMPTrap("public", SNMP_VERSION_2C);
char* changingString;
char _changingStringBuf[25];
char* changingString = _changingStringBuf;

void setup(){
Serial.begin(115200);
Expand All @@ -57,7 +76,6 @@ void setup(){
snmp.begin();

// setup our OPAQUE data-type
stuff = (uint8_t*)malloc(4);
stuff[0] = 1;
stuff[1] = 2;
stuff[2] = 24;
Expand All @@ -80,7 +98,6 @@ void setup(){
snmp.addReadOnlyStaticStringHandler(".1.3.6.1.4.1.5.11", staticString);

// Setup read/write string
changingString = (char*)malloc(25 * sizeof(char));
snprintf(changingString, 25, "This is changeable");
snmp.addReadWriteStringHandler(".1.3.6.1.4.1.5.12", &changingString, 25, true);

Expand Down
Loading
Loading