Add support for Arduino Due (#228)

* added support for Arduino Due

* update tests

* update changelog and docs

* fix tests
This commit is contained in:
Dawid Chyrzyński
2024-02-09 22:16:54 +01:00
committed by GitHub
parent a838dac9c0
commit 105e96197b
22 changed files with 39 additions and 36 deletions
+1
View File
@@ -18,6 +18,7 @@
* Added `getState` method to the `HAMqtt` class
* Added `onDisconnected` callback method to the `HAMqtt` class
* Added `onStateChanged` callback method to the `HAMqtt` class
* Added support for Arduino Due [#137](https://github.com/dawidchyrzynski/arduino-home-assistant/issues/137)
**Fixes:**
* Fixed a bug with the maximum number of device types [#190](https://github.com/dawidchyrzynski/arduino-home-assistant/issues/190) by [@martaisty](https://github.com/martaisty)
+1
View File
@@ -94,6 +94,7 @@ Here is the list of devices on which the library was tested:
* Arduino Nano
* Arduino Pro Mini
* Arduino Nano 33 IoT
* Arduino Due
* NodeMCU
* Controllino Mega (Pure)
* Controllino Maxi (Pure)
-5
View File
@@ -161,11 +161,6 @@
<dt class="sig sig-object cpp" id="_CPPv4N6HAMqtt15ConnectionStateE">
<span id="_CPPv3N6HAMqtt15ConnectionStateE"></span><span id="_CPPv2N6HAMqtt15ConnectionStateE"></span><span class="target" id="class_h_a_mqtt_1a46bf495384c36afc3d85edbaa3d495b7"></span><span class="k"><span class="pre">enum</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">ConnectionState</span></span></span><a class="headerlink" href="#_CPPv4N6HAMqtt15ConnectionStateE" title="Permalink to this definition"></a><br /></dt>
<dd><p><em>Values:</em></p>
<dl class="cpp enumerator">
<dt class="sig sig-object cpp" id="_CPPv4N6HAMqtt15ConnectionState19StateNotInitializedE">
<span id="_CPPv3N6HAMqtt15ConnectionState19StateNotInitializedE"></span><span id="_CPPv2N6HAMqtt15ConnectionState19StateNotInitializedE"></span><span class="target" id="class_h_a_mqtt_1a46bf495384c36afc3d85edbaa3d495b7a70f12f4588040a1a33004df4f6b7e75c"></span><span class="k"><span class="pre">enumerator</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">StateNotInitialized</span></span></span><a class="headerlink" href="#_CPPv4N6HAMqtt15ConnectionState19StateNotInitializedE" title="Permalink to this definition"></a><br /></dt>
<dd></dd></dl>
<dl class="cpp enumerator">
<dt class="sig sig-object cpp" id="_CPPv4N6HAMqtt15ConnectionState15StateConnectingE">
<span id="_CPPv3N6HAMqtt15ConnectionState15StateConnectingE"></span><span id="_CPPv2N6HAMqtt15ConnectionState15StateConnectingE"></span><span class="target" id="class_h_a_mqtt_1a46bf495384c36afc3d85edbaa3d495b7a26e4b442b7686873d5d46a112fae55bd"></span><span class="k"><span class="pre">enumerator</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">StateConnecting</span></span></span><a class="headerlink" href="#_CPPv4N6HAMqtt15ConnectionState15StateConnectingE" title="Permalink to this definition"></a><br /></dt>
@@ -158,6 +158,7 @@ It should work fine as long as the <cite>Client</cite> class is available.</p>
<li><p>Arduino Nano</p></li>
<li><p>Arduino Pro Mini</p></li>
<li><p>Arduino Nano 33 IoT</p></li>
<li><p>Arduino Due</p></li>
<li><p>NodeMCU</p></li>
<li><p>Controllino Mega (Pure)</p></li>
<li><p>Controllino Maxi (Pure)</p></li>
+2 -4
View File
@@ -900,11 +900,11 @@
<li><a href="documents/api/device-types/ha-light.html#_CPPv4N7HALight9_featuresE">HALight::_features (C++ member)</a>
</li>
<li><a href="documents/api/device-types/ha-light.html#_CPPv4N7HALight5_iconE">HALight::_icon (C++ member)</a>
</li>
<li><a href="documents/api/device-types/ha-light.html#_CPPv4N7HALight10_maxMiredsE">HALight::_maxMireds (C++ member)</a>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="documents/api/device-types/ha-light.html#_CPPv4N7HALight10_maxMiredsE">HALight::_maxMireds (C++ member)</a>
</li>
<li><a href="documents/api/device-types/ha-light.html#_CPPv4N7HALight10_minMiredsE">HALight::_minMireds (C++ member)</a>
</li>
<li><a href="documents/api/device-types/ha-light.html#_CPPv4N7HALight11_optimisticE">HALight::_optimistic (C++ member)</a>
@@ -1140,8 +1140,6 @@
<li><a href="documents/api/core/ha-mqtt.html#_CPPv4N6HAMqtt15ConnectionState22StateConnectionTimeoutE">HAMqtt::ConnectionState::StateConnectionTimeout (C++ enumerator)</a>
</li>
<li><a href="documents/api/core/ha-mqtt.html#_CPPv4N6HAMqtt15ConnectionState17StateDisconnectedE">HAMqtt::ConnectionState::StateDisconnected (C++ enumerator)</a>
</li>
<li><a href="documents/api/core/ha-mqtt.html#_CPPv4N6HAMqtt15ConnectionState19StateNotInitializedE">HAMqtt::ConnectionState::StateNotInitialized (C++ enumerator)</a>
</li>
<li><a href="documents/api/core/ha-mqtt.html#_CPPv4N6HAMqtt15ConnectionState17StateUnauthorizedE">HAMqtt::ConnectionState::StateUnauthorized (C++ enumerator)</a>
</li>
BIN
View File
Binary file not shown.
+1 -1
View File
File diff suppressed because one or more lines are too long
@@ -11,6 +11,7 @@ Here is the list of devices on which the library was tested:
- Arduino Nano
- Arduino Pro Mini
- Arduino Nano 33 IoT
- Arduino Due
- NodeMCU
- Controllino Mega (Pure)
- Controllino Maxi (Pure)
+5
View File
@@ -33,5 +33,10 @@
#define ARDUINOHA_DEBUG_PRINT(x)
#endif
#if defined(__SAMD21G18A__) or defined(__SAM3X8E__)
#define ARDUINOHA_INT_OVERLOAD
#endif
#define AHATOFSTR(x) reinterpret_cast<const __FlashStringHelper*>(x)
#define AHAFROMFSTR(x) reinterpret_cast<const char*>(x)
+4 -4
View File
@@ -140,7 +140,7 @@ public:
_SET_CURRENT_TEMPERATURE_OVERLOAD(uint32_t)
_SET_CURRENT_TEMPERATURE_OVERLOAD(float)
#ifdef __SAMD21G18A__
#ifdef ARDUINOHA_INT_OVERLOAD
_SET_CURRENT_TEMPERATURE_OVERLOAD(int)
#endif
@@ -218,7 +218,7 @@ public:
_SET_TARGET_TEMPERATURE_OVERLOAD(uint32_t)
_SET_TARGET_TEMPERATURE_OVERLOAD(float)
#ifdef __SAMD21G18A__
#ifdef ARDUINOHA_INT_OVERLOAD
_SET_TARGET_TEMPERATURE_OVERLOAD(int)
#endif
@@ -240,7 +240,7 @@ public:
_SET_CURRENT_CURRENT_TEMPERATURE_OVERLOAD(uint32_t)
_SET_CURRENT_CURRENT_TEMPERATURE_OVERLOAD(float)
#ifdef __SAMD21G18A__
#ifdef ARDUINOHA_INT_OVERLOAD
_SET_CURRENT_CURRENT_TEMPERATURE_OVERLOAD(int)
#endif
@@ -378,7 +378,7 @@ public:
_SET_CURRENT_TARGET_TEMPERATURE_OVERLOAD(uint32_t)
_SET_CURRENT_TARGET_TEMPERATURE_OVERLOAD(float)
#ifdef __SAMD21G18A__
#ifdef ARDUINOHA_INT_OVERLOAD
_SET_CURRENT_TARGET_TEMPERATURE_OVERLOAD(int)
#endif
+2 -2
View File
@@ -64,7 +64,7 @@ public:
_SET_STATE_OVERLOAD(uint32_t)
_SET_STATE_OVERLOAD(float)
#ifdef __SAMD21G18A__
#ifdef ARDUINOHA_INT_OVERLOAD
_SET_STATE_OVERLOAD(int)
#endif
@@ -86,7 +86,7 @@ public:
_SET_CURRENT_STATE_OVERLOAD(uint32_t)
_SET_CURRENT_STATE_OVERLOAD(float)
#ifdef __SAMD21G18A__
#ifdef ARDUINOHA_INT_OVERLOAD
_SET_CURRENT_STATE_OVERLOAD(int)
#endif
+2 -2
View File
@@ -52,7 +52,7 @@ public:
_SET_VALUE_OVERLOAD(uint32_t)
_SET_VALUE_OVERLOAD(float)
#ifdef __SAMD21G18A__
#ifdef ARDUINOHA_INT_OVERLOAD
_SET_VALUE_OVERLOAD(int)
#endif
@@ -73,7 +73,7 @@ public:
_SET_CURRENT_VALUE_OVERLOAD(uint32_t)
_SET_CURRENT_VALUE_OVERLOAD(float)
#ifdef __SAMD21G18A__
#ifdef ARDUINOHA_INT_OVERLOAD
_SET_CURRENT_VALUE_OVERLOAD(int)
#endif
+1 -1
View File
@@ -30,7 +30,7 @@
assertEqual(eTopic, publishedMessage->topic); \
assertEqual(messageP, publishedMessage->buffer); \
assertEqual(messageLen, publishedMessage->bufferSize - 1); \
assertEqual(eRetained, publishedMessage->retained); \
assertEqual(static_cast<bool>(eRetained), publishedMessage->retained); \
}
#define assertSingleMqttMessage(eTopic, eMessage, eRetained) { \
+1 -1
View File
@@ -96,7 +96,7 @@ HANumeric::HANumeric(const uint32_t value, const uint8_t precision):
_value = value * getPrecisionBase();
}
#ifdef __SAMD21G18A__
#ifdef ARDUINOHA_INT_OVERLOAD
HANumeric::HANumeric(const int value, const uint8_t precision):
_isSet(true),
_precision(precision)
+2 -1
View File
@@ -3,6 +3,7 @@
#define AHA_NUMERIC_H
#include <stdint.h>
#include "../ArduinoHADefines.h"
/**
* This class represents a numeric value that simplifies use of different types of numbers across the library.
@@ -92,7 +93,7 @@ public:
*/
HANumeric(const uint32_t value, const uint8_t precision);
#ifdef __SAMD21G18A__
#ifdef ARDUINOHA_INT_OVERLOAD
/**
* Converts the given int into number representation of the given precision.
* If the precision is greater than zero the given value will be converted to float.
+2 -2
View File
@@ -203,7 +203,7 @@ AHA_TEST(BinarySensorTest, default_state_false) {
initMqttTest(testDeviceId)
HABinarySensor sensor(testUniqueId);
assertEqual(false, sensor.getCurrentState());
assertFalse(sensor.getCurrentState());
}
AHA_TEST(BinarySensorTest, default_state_true) {
@@ -211,7 +211,7 @@ AHA_TEST(BinarySensorTest, default_state_true) {
HABinarySensor sensor(testUniqueId);
sensor.setCurrentState(true);
assertEqual(true, sensor.getCurrentState());
assertTrue(sensor.getCurrentState());
}
AHA_TEST(BinarySensorTest, publish_state_on) {
+1 -1
View File
@@ -291,7 +291,7 @@ AHA_TEST(DeviceTest, lwt_enabled) {
assertEqual(AHATOFSTR(AvailabilityTopic), mock->getLastWill().topic);
assertEqual("offline", mock->getLastWill().message);
assertEqual(true, mock->getLastWill().retain);
assertTrue(mock->getLastWill().retain);
}
AHA_TEST(DeviceTest, full_serialization) {
+2 -2
View File
@@ -8,7 +8,7 @@
#define assertStateCallbackCalled(expectedState, callerPtr) \
assertTrue(lastStateCallbackCall.called); \
assertEqual(expectedState, lastStateCallbackCall.state); \
assertEqual(static_cast<bool>(expectedState), lastStateCallbackCall.state); \
assertEqual(callerPtr, lastStateCallbackCall.caller);
#define assertStateCallbackNotCalled() \
@@ -377,7 +377,7 @@ AHA_TEST(FanTest, current_state_setter) {
fan.setCurrentState(true);
assertEqual(0, mock->getFlushedMessagesNb());
assertEqual(true, fan.getCurrentState());
assertTrue(fan.getCurrentState());
}
AHA_TEST(FanTest, current_speed_setter) {
+2 -2
View File
@@ -12,7 +12,7 @@
#define assertAuxStateCallbackCalled(expectedState, callerPtr) \
assertTrue(lastAuxStateCallbackCall.called); \
assertEqual(expectedState, lastAuxStateCallbackCall.state); \
assertEqual(static_cast<bool>(expectedState), lastAuxStateCallbackCall.state); \
assertEqual(callerPtr, lastAuxStateCallbackCall.caller);
#define assertAuxStateCallbackNotCalled() \
@@ -20,7 +20,7 @@
#define assertPowerCallbackCalled(expectedState, callerPtr) \
assertTrue(lastPowerCallbackCall.called); \
assertEqual(expectedState, lastPowerCallbackCall.state); \
assertEqual(static_cast<bool>(expectedState), lastPowerCallbackCall.state); \
assertEqual(callerPtr, lastPowerCallbackCall.caller);
#define assertPowerCallbackNotCalled() \
+2 -2
View File
@@ -10,7 +10,7 @@
#define assertStateCallbackCalled(expectedState, callerPtr) \
assertTrue(lastStateCallbackCall.called); \
assertEqual(expectedState, lastStateCallbackCall.state); \
assertEqual(static_cast<bool>(expectedState), lastStateCallbackCall.state); \
assertEqual(callerPtr, lastStateCallbackCall.caller);
#define assertStateCallbackNotCalled() \
@@ -603,7 +603,7 @@ AHA_TEST(LightTest, current_state_setter) {
light.setCurrentState(true);
assertEqual(0, mock->getFlushedMessagesNb());
assertEqual(true, light.getCurrentState());
assertTrue(light.getCurrentState());
}
AHA_TEST(LightTest, current_brightness_setter) {
+2 -2
View File
@@ -7,7 +7,7 @@
#define assertCommandCallbackCalled(expectedCommand, callerPtr) \
assertTrue(lastCommandCallbackCall.called); \
assertEqual(expectedCommand, lastCommandCallbackCall.state); \
assertEqual(static_cast<bool>(expectedCommand), lastCommandCallbackCall.state); \
assertEqual(callerPtr, lastCommandCallbackCall.caller);
#define assertCommandCallbackNotCalled() \
@@ -272,7 +272,7 @@ AHA_TEST(SwitchTest, current_state_setter) {
testSwitch.setCurrentState(true);
assertEqual(0, mock->getFlushedMessagesNb());
assertEqual(true, testSwitch.getCurrentState());
assertTrue(testSwitch.getCurrentState());
}
AHA_TEST(SwitchTest, publish_state_on) {
+4 -4
View File
@@ -6,7 +6,7 @@
mega = arduino:avr:mega:cpu=atmega2560
nodemcuv2 = esp8266:esp8266:nodemcuv2:xtal=80,eesz=4M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=921600
esp32 = esp32:esp32:esp32da:PartitionScheme=default,EraseFlash=none,FlashMode=qio,FlashFreq=80,FlashSize=4M,LoopCore=1,EventsCore=1,UploadSpeed=921600,DebugLevel=none
nano_33_iot = arduino:samd:nano_33_iot
due = arduino:sam:arduino_due_x_dbg
[env:uno]
board = uno
@@ -24,6 +24,6 @@
board = esp32
preprocessor = -D AUNITER_ESP32 -D ARDUINOHA_TEST
[env:samd]
board = nano_33_iot
preprocessor = -D AUNITER_SAMD -D ARDUINOHA_TEST
[env:due]
board = due
preprocessor = -D AUNITER_DUE -D ARDUINOHA_TEST