Skip to content

Commit 04f2e80

Browse files
committed
Progress [75%] Sms impl
1 parent 9b27bc1 commit 04f2e80

11 files changed

+376
-220
lines changed

src/Adafruit_MQTT.cpp

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static uint8_t *stringprint(uint8_t *p, const char *s, uint16_t maxlen = 0) {
9898

9999
// Adafruit_MQTT Definition ////////////////////////////////////////////////////
100100

101-
Adafruit_MQTT::Adafruit_MQTT(const char *server, uint16_t port, const char *cid,
101+
Adafruit_MQTT::Adafruit_MQTT(const char *server, uint16_t port, char *cid,
102102
const char *user, const char *pass) {
103103
servername = server;
104104
portnum = port;
@@ -845,55 +845,55 @@ bool Adafruit_MQTT_Publish::publish(uint8_t *payload, uint16_t bLen) {
845845
return mqtt->publish(topic, payload, bLen, qos);
846846
}
847847

848-
bool Adafruit_MQTT::readMessage(char* msg)
849-
{
850-
uint16_t i, topiclen, datalen;
848+
// bool Adafruit_MQTT::readMessage(char* msg)
849+
// {
850+
// uint16_t i, topiclen, datalen;
851851

852-
// Check if data is available to read.
853-
uint16_t len =
854-
readFullPacket(buffer, MAXBUFFERSIZE, 6000); // return one full packet
855-
if (!len)
856-
return false; // No data available, just quit.
852+
// // Check if data is available to read.
853+
// uint16_t len =
854+
// readFullPacket(buffer, MAXBUFFERSIZE, 6000); // return one full packet
855+
// if (!len)
856+
// return false; // No data available, just quit.
857857

858-
if (len < 3)
859-
return NULL;
860-
if ((buffer[0] & 0xF0) != (MQTT_CTRL_PUBLISH) << 4)
861-
return NULL;
862-
863-
// Parse out length of packet.
864-
topiclen = buffer[3];
865-
866-
uint8_t packet_id_len = 0;
867-
uint16_t packetid = 0;
868-
// Check if it is QoS 1, TODO: we dont support QoS 2
869-
if ((buffer[0] & 0x6) == 0x2) {
870-
packet_id_len = 2;
871-
packetid = buffer[topiclen + 4];
872-
packetid <<= 8;
873-
packetid |= buffer[topiclen + 5];
874-
}
875-
876-
// zero out the old data
877-
memset(msg, 0, SUBSCRIPTIONDATALEN);
878-
879-
datalen = len - topiclen - packet_id_len - 4;
880-
if (datalen > SUBSCRIPTIONDATALEN) {
881-
datalen = SUBSCRIPTIONDATALEN - 1; // cut it off
882-
}
883-
// extract out just the data, into the subscription object itself
884-
memmove(msg, buffer + 4 + topiclen + packet_id_len,
885-
datalen);
886-
887-
return true;
888-
}
889-
890-
bool Adafruit_MQTT::subscribeTopic(char* topic)
891-
{
892-
uint8_t len = subscribePacket(buffer, topic,
893-
0);
894-
if (!sendPacket(buffer, len))
895-
return -1;
896-
}
858+
// if (len < 3)
859+
// return NULL;
860+
// if ((buffer[0] & 0xF0) != (MQTT_CTRL_PUBLISH) << 4)
861+
// return NULL;
862+
863+
// // Parse out length of packet.
864+
// topiclen = buffer[3];
865+
866+
// uint8_t packet_id_len = 0;
867+
// uint16_t packetid = 0;
868+
// // Check if it is QoS 1, TODO: we dont support QoS 2
869+
// if ((buffer[0] & 0x6) == 0x2) {
870+
// packet_id_len = 2;
871+
// packetid = buffer[topiclen + 4];
872+
// packetid <<= 8;
873+
// packetid |= buffer[topiclen + 5];
874+
// }
875+
876+
// // zero out the old data
877+
// memset(msg, 0, SUBSCRIPTIONDATALEN);
878+
879+
// datalen = len - topiclen - packet_id_len - 4;
880+
// if (datalen > SUBSCRIPTIONDATALEN) {
881+
// datalen = SUBSCRIPTIONDATALEN - 1; // cut it off
882+
// }
883+
// // extract out just the data, into the subscription object itself
884+
// memmove(msg, buffer + 4 + topiclen + packet_id_len,
885+
// datalen);
886+
887+
// return true;
888+
// }
889+
890+
// bool Adafruit_MQTT::subscribeTopic(char* topic)
891+
// {
892+
// uint8_t len = subscribePacket(buffer, topic,
893+
// 0);
894+
// if (!sendPacket(buffer, len))
895+
// return -1;
896+
// }
897897

898898
// Adafruit_MQTT_Subscribe Definition //////////////////////////////////////////
899899

src/Adafruit_MQTT.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
// If using something like Zero or Due, change the above to SerialUSB
4444

4545
// Define actual debug output functions when necessary.
46+
#define MQTT_DEBUG
4647
#ifdef MQTT_DEBUG
4748
#define DEBUG_PRINT(...) \
4849
{ DEBUG_PRINTER.print(__VA_ARGS__); }
@@ -145,7 +146,7 @@ class Adafruit_MQTT_Subscribe; // forward decl
145146

146147
class Adafruit_MQTT {
147148
public:
148-
Adafruit_MQTT(const char *server, uint16_t port, const char *cid,
149+
Adafruit_MQTT(const char *server, uint16_t port, char *cid,
149150
const char *user, const char *pass);
150151

151152
Adafruit_MQTT(const char *server, uint16_t port, const char *user = "",
@@ -212,8 +213,8 @@ class Adafruit_MQTT {
212213
bool ping(uint8_t n = 1);
213214
void setClientID(char* id);
214215
void setPort(uint16_t port);
215-
bool readMessage(char* msg);
216-
bool subscribeTopic(char* topic);
216+
//bool readMessage(char* msg);
217+
//bool subscribeTopic(char* topic);
217218
protected:
218219
// Interface that subclasses need to implement:
219220

src/Adafruit_MQTT_Client.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
// The MIT License (MIT)
23
//
34
// Copyright (c) 2015 Adafruit Industries

src/Adafruit_MQTT_Client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
class Adafruit_MQTT_Client : public Adafruit_MQTT {
3535
public:
3636
Adafruit_MQTT_Client(Client *client, const char *server, uint16_t port,
37-
const char *cid, const char *user, const char *pass)
37+
char *cid, const char *user, const char *pass)
3838
: Adafruit_MQTT(server, port, cid, user, pass), client(client) {}
3939

4040
Adafruit_MQTT_Client(Client *client, const char *server, uint16_t port,

src/Adafruit_MQTT_FONA.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
class Adafruit_MQTT_FONA : public Adafruit_MQTT {
3636
public:
3737
Adafruit_MQTT_FONA(Adafruit_FONA *f, const char *server, uint16_t port,
38-
const char *cid, const char *user, const char *pass)
38+
char *cid, const char *user, const char *pass)
3939
: Adafruit_MQTT(server, port, cid, user, pass), fona(f) {}
4040

4141
Adafruit_MQTT_FONA(Adafruit_FONA *f, const char *server, uint16_t port,

src/LiveObjects.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
Adafruit FONA
2929
******************************************************************************/
3030
#ifdef ARDUINO_AVR_FEATHER32U4
31-
#include "LiveObjectsAVRFona.h"
31+
#define FONAHD
32+
#include "LiveObjectsFona.h"
3233
#endif
3334

3435

src/LiveObjectsAVRFona.cpp

Lines changed: 0 additions & 153 deletions
This file was deleted.

src/LiveObjectsBase.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
#include "LiveObjectsBase.h"
3-
43
LiveObjectsBase::LiveObjectsBase()
54
:
65
lastKeepAliveNetwork(10000)
@@ -391,6 +390,7 @@ void LiveObjectsBase::setDecoder(String s)
391390

392391
void LiveObjectsBase::addTimestamp(time_t timestamp)
393392
{
393+
#ifndef ARDUINO_ARCH_AVR
394394
char bufer[sizeof("2011-10-08T07:07:09Z")];
395395
strftime(bufer, sizeof(bufer), "%Y-%m-%dT%H:%M:%SZ",gmtime(&timestamp));
396396
if(m_Protocol == MQTT && m_Encoding==TEXT) easyDataPayload["timestamp"]=bufer;
@@ -399,6 +399,7 @@ void LiveObjectsBase::addTimestamp(time_t timestamp)
399399
String s = bufer;
400400
addToStringPayload(s);
401401
}
402+
#endif
402403
}
403404
void LiveObjectsBase::addLocation(double lat, double lon, double alt)
404405
{

src/LiveObjectsBase.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
/******************************************************************************
55
DEFAULT VALUES FOR LIVEOBJECTS
66
******************************************************************************/
7-
#ifdef ARDUINO_ARCH_AVR
8-
#define PAYLOAD_DATA_SIZE 256
9-
#else
107
#define PAYLOAD_DATA_SIZE 1024
11-
#endif
128
#define KEEP_ALIVE_NETWORK 1000
139
#define SW_REVISION "1.8.0"
1410

@@ -40,7 +36,11 @@
4036
******************************************************************************/
4137
#include <Arduino.h>
4238
#include <ArduinoJson.h>
43-
#include <time.h>
39+
#ifndef ARDUINO_ARCH_AVR
40+
#include <ctime>
41+
#else
42+
typedef long long time_t;
43+
#endif
4444
#include "LiveObjectsCert.h"
4545
#include "Utils.h"
4646

@@ -410,4 +410,4 @@ void LiveObjectsBase::addToStringPayload(T val, Args ... args)
410410
addToStringPayload(args...);
411411
}
412412

413-
extern const String SECRET_LIVEOBJECTS_API_KEY;
413+
extern const String SECRET_LIVEOBJECTS_API_KEY;

0 commit comments

Comments
 (0)