Skip to content

Commit

Permalink
Merge pull request #311 from pennam/remove_avr
Browse files Browse the repository at this point in the history
Remove __AVR__ compile options to improve code clarity
  • Loading branch information
pennam authored Oct 9, 2023
2 parents 8e654f9 + 8373e90 commit 6a9acc2
Show file tree
Hide file tree
Showing 13 changed files with 2 additions and 304 deletions.
15 changes: 1 addition & 14 deletions src/ArduinoIoTCloudTCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
}

Expand Down
4 changes: 0 additions & 4 deletions src/cbor/CBORDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@

#include <Arduino.h>

#ifdef __AVR__
# include <Arduino_AVRSTL.h>
#endif

#undef max
#undef min
#include <list>
Expand Down
4 changes: 0 additions & 4 deletions src/cbor/CBOREncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@

#include <Arduino.h>

#ifdef __AVR__
# include <Arduino_AVRSTL.h>
#endif

#undef max
#undef min
#include <list>
Expand Down
5 changes: 0 additions & 5 deletions src/cbor/lib/tinycbor/src/cbor.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@
#ifndef CBOR_H
#define CBOR_H

#ifdef __AVR__
#define FP_NAN NAN
#define FP_INFINITE INFINITY
#endif

#ifndef assert
#include <assert.h>
#endif
Expand Down
4 changes: 0 additions & 4 deletions src/cbor/lib/tinycbor/src/cborpretty.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
# define __STDC_LIMIT_MACROS 1
#endif

#ifndef __AVR__

#include "cbor.h"
#include "cborinternal_p.h"
#include "compilersupport_p.h"
Expand Down Expand Up @@ -582,6 +580,4 @@ CborError cbor_value_to_pretty_stream(CborStreamFunction streamFunction, void *t

#pragma GCC diagnostic pop

#endif // __AVR__

/** @} */
4 changes: 0 additions & 4 deletions src/cbor/lib/tinycbor/src/cbortojson.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
# define __STDC_LIMIT_MACROS 1
#endif

#ifndef __AVR__

#include "cbor.h"
#include "cborjson.h"
#include "cborinternal_p.h"
Expand Down Expand Up @@ -703,6 +701,4 @@ CborError cbor_value_to_json_advance(FILE *out, CborValue *value, int flags)

#pragma GCC diagnostic pop

#endif // __AVR__

/** @} */
4 changes: 0 additions & 4 deletions src/cbor/lib/tinycbor/src/open_memstream.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@

#include <unistd.h>

#ifdef __AVR__
typedef size_t ssize_t;
#endif

typedef ssize_t RetType;
typedef size_t LenType;

Expand Down
235 changes: 0 additions & 235 deletions src/nonstd/nonstd.h

This file was deleted.

8 changes: 0 additions & 8 deletions src/property/Property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,7 @@ CborError Property::appendAttribute(String value, String attributeName, CborEnco
}, encoder);
}

#ifdef __AVR__
CborError Property::appendAttributeName(String attributeName, nonstd::function<CborError (CborEncoder& mapEncoder)>appendValue, CborEncoder *encoder)
#else
CborError Property::appendAttributeName(String attributeName, std::function<CborError (CborEncoder& mapEncoder)>appendValue, 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
Expand Down Expand Up @@ -319,11 +315,7 @@ void Property::setAttribute(String& value, String attributeName) {
});
}

#ifdef __AVR__
void Property::setAttribute(String attributeName, nonstd::function<void (CborMapData & md)>setValue)
#else
void Property::setAttribute(String attributeName, std::function<void (CborMapData & md)>setValue)
#endif
{
if (attributeName != "") {
_attributeIdentifier++;
Expand Down
Loading

0 comments on commit 6a9acc2

Please sign in to comment.