diff --git a/src/ArduinoIoTCloudTCP.cpp b/src/ArduinoIoTCloudTCP.cpp index 97a15de6d..1efbf3f33 100644 --- a/src/ArduinoIoTCloudTCP.cpp +++ b/src/ArduinoIoTCloudTCP.cpp @@ -132,16 +132,7 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress, _brokerAddress = brokerAddress; _brokerPort = brokerPort; -#if defined(__AVR__) - String const nina_fw_version = WiFi.firmwareVersion(); - if (nina_fw_version < "1.4.2") - { - DEBUG_ERROR("ArduinoIoTCloudTCP::%s NINA firmware needs to be >= 1.4.2 to support cloud on Uno WiFi Rev. 2, current %s", __FUNCTION__, nina_fw_version.c_str()); - return 0; - } -#endif /* AVR */ - -#if OTA_ENABLED && !defined(__AVR__) +#if OTA_ENABLED _ota_img_sha256 = OTA::getImageSHA256(); DEBUG_VERBOSE("SHA256: HASH(%d) = %s", strlen(_ota_img_sha256.c_str()), _ota_img_sha256.c_str()); #endif /* OTA_ENABLED */ @@ -483,18 +474,14 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SubscribeThingTopics() if (!_mqttClient.subscribe(_dataTopicIn)) { DEBUG_ERROR("ArduinoIoTCloudTCP::%s could not subscribe to %s", __FUNCTION__, _dataTopicIn.c_str()); -#if !defined(__AVR__) DEBUG_ERROR("Check your thing configuration, and press the reset button on your board."); -#endif return State::SubscribeThingTopics; } if (!_mqttClient.subscribe(_shadowTopicIn)) { DEBUG_ERROR("ArduinoIoTCloudTCP::%s could not subscribe to %s", __FUNCTION__, _shadowTopicIn.c_str()); -#if !defined(__AVR__) DEBUG_ERROR("Check your thing configuration, and press the reset button on your board."); -#endif return State::SubscribeThingTopics; } diff --git a/src/cbor/CBORDecoder.h b/src/cbor/CBORDecoder.h index d1bf91ca0..5e9496b2a 100644 --- a/src/cbor/CBORDecoder.h +++ b/src/cbor/CBORDecoder.h @@ -24,10 +24,6 @@ #include -#ifdef __AVR__ -# include -#endif - #undef max #undef min #include diff --git a/src/cbor/CBOREncoder.h b/src/cbor/CBOREncoder.h index fa68d2200..cbba5522d 100644 --- a/src/cbor/CBOREncoder.h +++ b/src/cbor/CBOREncoder.h @@ -24,10 +24,6 @@ #include -#ifdef __AVR__ -# include -#endif - #undef max #undef min #include diff --git a/src/cbor/lib/tinycbor/src/cbor.h b/src/cbor/lib/tinycbor/src/cbor.h index 93d448daf..27a4fe4a8 100644 --- a/src/cbor/lib/tinycbor/src/cbor.h +++ b/src/cbor/lib/tinycbor/src/cbor.h @@ -25,11 +25,6 @@ #ifndef CBOR_H #define CBOR_H -#ifdef __AVR__ -#define FP_NAN NAN -#define FP_INFINITE INFINITY -#endif - #ifndef assert #include #endif diff --git a/src/cbor/lib/tinycbor/src/cborpretty.c b/src/cbor/lib/tinycbor/src/cborpretty.c index b82b985ac..2db4b253a 100644 --- a/src/cbor/lib/tinycbor/src/cborpretty.c +++ b/src/cbor/lib/tinycbor/src/cborpretty.c @@ -28,8 +28,6 @@ # define __STDC_LIMIT_MACROS 1 #endif -#ifndef __AVR__ - #include "cbor.h" #include "cborinternal_p.h" #include "compilersupport_p.h" @@ -582,6 +580,4 @@ CborError cbor_value_to_pretty_stream(CborStreamFunction streamFunction, void *t #pragma GCC diagnostic pop -#endif // __AVR__ - /** @} */ diff --git a/src/cbor/lib/tinycbor/src/cbortojson.c b/src/cbor/lib/tinycbor/src/cbortojson.c index 0e669f27e..ed6a16666 100644 --- a/src/cbor/lib/tinycbor/src/cbortojson.c +++ b/src/cbor/lib/tinycbor/src/cbortojson.c @@ -30,8 +30,6 @@ # define __STDC_LIMIT_MACROS 1 #endif -#ifndef __AVR__ - #include "cbor.h" #include "cborjson.h" #include "cborinternal_p.h" @@ -703,6 +701,4 @@ CborError cbor_value_to_json_advance(FILE *out, CborValue *value, int flags) #pragma GCC diagnostic pop -#endif // __AVR__ - /** @} */ diff --git a/src/cbor/lib/tinycbor/src/open_memstream.c b/src/cbor/lib/tinycbor/src/open_memstream.c index 4d79a726e..b3e624d47 100644 --- a/src/cbor/lib/tinycbor/src/open_memstream.c +++ b/src/cbor/lib/tinycbor/src/open_memstream.c @@ -34,10 +34,6 @@ #include -#ifdef __AVR__ -typedef size_t ssize_t; -#endif - typedef ssize_t RetType; typedef size_t LenType; diff --git a/src/nonstd/nonstd.h b/src/nonstd/nonstd.h deleted file mode 100644 index b591919c6..000000000 --- a/src/nonstd/nonstd.h +++ /dev/null @@ -1,235 +0,0 @@ -#pragma once -#ifdef __AVR__ -#include -extern void * operator new(size_t size, void * ptr); -namespace nonstd{ - - templatestruct tag{using type=T;}; - templateusing type_t=typename Tag::type; - - using size_t=decltype(sizeof(int)); - - //move - - template - T&& move(T&t){return static_cast(t);} - - //forward - - template - struct remove_reference:tag{}; - template - struct remove_reference:tag{}; - templateusing remove_reference_t=type_t>; - - template - T&& forward( remove_reference_t& t ) { - return static_cast(t); - } - template - T&& forward( remove_reference_t&& t ) { - return static_cast(t); - } - - //decay - - template - struct remove_const:tag{}; - template - struct remove_const:tag{}; - - template - struct remove_volatile:tag{}; - template - struct remove_volatile:tag{}; - - template - struct remove_cv:remove_const>>{}; - - - template - struct decay3:remove_cv{}; - template - struct decay3:tag{}; - template - struct decay2:decay3{}; - template - struct decay2:tag{}; - - template - struct decay:decay2>{}; - - template - using decay_t=type_t>; - - //is_convertible - - template - T declval(); // no implementation - - template - struct integral_constant{ - static constexpr T value=t; - constexpr integral_constant() {}; - constexpr operator T()const{ return value; } - constexpr T operator()()const{ return value; } - }; - template - using bool_t=integral_constant; - using true_type=bool_t; - using false_type=bool_t; - - templatestruct voider:tag{}; - templateusing void_t=type_t>; - - namespace details { - templateclass Z, class, class...Ts> - struct can_apply:false_type{}; - templateclass Z, class...Ts> - struct can_apply>, Ts...>:true_type{}; - } - templateclass Z, class...Ts> - using can_apply = details::can_apply; - - namespace details { - template - using try_convert = decltype( To{declval()} ); - } - template - struct is_convertible : can_apply< details::try_convert, From, To > {}; - template<> - struct is_convertible:true_type{}; - - //enable_if - - template - struct enable_if {}; - template - struct enable_if:tag{}; - template - using enable_if_t=type_t>; - - //res_of - - namespace details { - template - using invoke_t = decltype( declval()(declval()...) ); - - template - struct res_of {}; - template - struct res_of>>: - tag> - {}; - } - template - using res_of = details::res_of; - template - using res_of_t=type_t>; - - //aligned_storage - - template - struct alignas(align) aligned_storage_t { - char buff[size]; - }; - - //is_same - - template - struct is_same:false_type{}; - template - struct is_same:true_type{}; - - template - struct small_task; - - template - struct small_task{ - struct vtable_t { - void(*mover)(void* src, void* dest); - void(*destroyer)(void*); - R(*invoke)(void const* t, Args&&...args); - template - static vtable_t const* get() { - static const vtable_t table = { - [](void* src, void*dest) { - new(dest) T(move(*static_cast(src))); - }, - [](void* t){ static_cast(t)->~T(); }, - [](void const* t, Args&&...args)->R { - return (*static_cast(t))(forward(args)...); - } - }; - return &table; - } - }; - vtable_t const* table = nullptr; - aligned_storage_t data; - template, - enable_if_t{}>* = nullptr, - enable_if_t, R >{}>* = nullptr - > - small_task( F&& f ): - table( vtable_t::template get() ) - { - static_assert( sizeof(dF) <= sz, "object too large" ); - static_assert( alignof(dF) <= algn, "object too aligned" ); - new(&data) dF(forward(f)); - } - ~small_task() { - if (table) - table->destroyer(&data); - } - small_task(const small_task& o): - table(o.table) - { - data = o.data; - } - small_task(small_task&& o): - table(o.table) - { - if (table) - table->mover(&o.data, &data); - } - small_task(){} - small_task& operator=(const small_task& o){ - this->~small_task(); - new(this) small_task( move(o) ); - return *this; - } - small_task& operator=(small_task&& o){ - this->~small_task(); - new(this) small_task( move(o) ); - return *this; - } - explicit operator bool()const{return table;} - R operator()(Args...args)const{ - return table->invoke(&data, forward(args)...); - } - }; - - template - inline bool operator==(const small_task& __f, nullptr_t) - { return !static_cast(__f); } - - /// @overload - template - inline bool operator==(nullptr_t, const small_task& __f) - { return !static_cast(__f); } - - template - inline bool operator!=(const small_task& __f, nullptr_t) - { return static_cast(__f); } - - /// @overload - template - inline bool operator!=(nullptr_t, const small_task& __f) - { return static_cast(__f); } - - template - using function = small_task; -} - -#endif \ No newline at end of file diff --git a/src/property/Property.cpp b/src/property/Property.cpp index 326e25584..4d4258b28 100644 --- a/src/property/Property.cpp +++ b/src/property/Property.cpp @@ -226,11 +226,7 @@ CborError Property::appendAttribute(String value, String attributeName, CborEnco }, encoder); } -#ifdef __AVR__ -CborError Property::appendAttributeName(String attributeName, nonstd::functionappendValue, CborEncoder *encoder) -#else CborError Property::appendAttributeName(String attributeName, std::functionappendValue, CborEncoder *encoder) -#endif { if (attributeName != "") { // when the attribute name string is not empty, the attribute identifier is incremented in order to be encoded in the message if the _lightPayload flag is set @@ -319,11 +315,7 @@ void Property::setAttribute(String& value, String attributeName) { }); } -#ifdef __AVR__ -void Property::setAttribute(String attributeName, nonstd::functionsetValue) -#else void Property::setAttribute(String attributeName, std::functionsetValue) -#endif { if (attributeName != "") { _attributeIdentifier++; diff --git a/src/property/Property.h b/src/property/Property.h index b0e6ada06..90848b64a 100644 --- a/src/property/Property.h +++ b/src/property/Property.h @@ -32,13 +32,7 @@ #undef max #undef min -#ifdef __AVR__ -# include -# include -#else # include -#endif - #include #include "../cbor/lib/tinycbor/cbor-lib.h" @@ -140,10 +134,6 @@ typedef void(*OnSyncCallbackFunc)(Property &); CLASS DECLARATION ******************************************************************************/ -#ifdef __AVR__ -#include "nonstd/nonstd.h" -#endif - class Property { public: @@ -191,13 +181,8 @@ class Property CborError appendAttribute(unsigned int value, String attributeName = "", CborEncoder *encoder = nullptr); CborError appendAttribute(float value, String attributeName = "", CborEncoder *encoder = nullptr); CborError appendAttribute(String value, String attributeName = "", CborEncoder *encoder = nullptr); -#ifndef __AVR__ CborError appendAttributeName(String attributeName, std::functionf, CborEncoder *encoder); void setAttribute(String attributeName, std::functionsetValue); -#else - CborError appendAttributeName(String attributeName, nonstd::functionf, CborEncoder *encoder); - void setAttribute(String attributeName, nonstd::functionsetValue); -#endif void setAttributesFromCloud(std::list * map_data_list); void setAttribute(bool& value, String attributeName = ""); void setAttribute(int& value, String attributeName = ""); diff --git a/src/property/PropertyContainer.h b/src/property/PropertyContainer.h index 8c254875e..9dc3c86cd 100644 --- a/src/property/PropertyContainer.h +++ b/src/property/PropertyContainer.h @@ -26,10 +26,6 @@ #include "Property.h" -#ifdef __AVR__ -# include -#endif - #undef max #undef min #include diff --git a/src/utility/ota/FlashSHA256.cpp b/src/utility/ota/FlashSHA256.cpp index 85a1b4ebe..d0fc3d532 100644 --- a/src/utility/ota/FlashSHA256.cpp +++ b/src/utility/ota/FlashSHA256.cpp @@ -20,7 +20,7 @@ ******************************************************************************/ #include -#if OTA_ENABLED && !defined(__AVR__) +#if OTA_ENABLED #include "FlashSHA256.h" diff --git a/src/utility/time/TimeService.cpp b/src/utility/time/TimeService.cpp index 23ab0a663..ac0a5eb02 100644 --- a/src/utility/time/TimeService.cpp +++ b/src/utility/time/TimeService.cpp @@ -294,7 +294,6 @@ bool TimeServiceClass::connected() unsigned long TimeServiceClass::getRemoteTime() { if(connected()) { -#ifndef __AVR__ /* At first try to obtain a valid time via NTP. * This is the most reliable time source and it will * ensure a correct behaviour of the library. @@ -303,7 +302,6 @@ unsigned long TimeServiceClass::getRemoteTime() if(isTimeValid(ntp_time)) { return ntp_time; } -#endif /* As fallback if NTP request fails try to obtain the * network time using the connection handler.