Skip to content

Commit

Permalink
First public commit (version 2.1.16308)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienwarin committed Dec 5, 2016
1 parent 57066b4 commit 0848965
Show file tree
Hide file tree
Showing 15 changed files with 2,390 additions and 201 deletions.
86 changes: 86 additions & 0 deletions BaseDefinitions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**************************************************************************/
/*!
@file BaseDefinitions.h
@author Sebastien Warin (http://sebastien.warin.fr)
@version 2.1.16296
@section LICENSE
Constellation License Agreement
Copyright (c) 2015-2016, Sebastien Warin
All rights reserved.
By receiving, opening the file package, and/or using Constellation 1.8("Software")
containing this software, you agree that this End User User License Agreement(EULA)
is a legally binding and valid contract and agree to be bound by it.
You agree to abide by the intellectual property laws and all of the terms and
conditions of this Agreement.
http://www.myconstellation.io/license.txt
*/
/**************************************************************************/

#ifndef _CONSTELLATION_DEFINITIONS_
#define _CONSTELLATION_DEFINITIONS_

#define HTTP_OK 200
#define HTTP_NO_CONTENT 204

#define WILDCARD "*"

#define MESSAGE_CALLBACK_SIGNATURE void (*msgCallback)(JsonObject&)
#define MESSAGE_CALLBACK_WCONTEXT_SIGNATURE void (*msgCallbackWithContext)(JsonObject&, MessageContext)
#define STATEOBJECT_CALLBACK_SIGNATURE void (*soCallback)(JsonObject&)

enum ScopeType : uint8_t {
None = 0,
Group = 1,
Package = 2,
Sentinel = 3,
Other = 4,
All = 5
};

enum LogLevel : uint8_t {
LevelNone = 0,
LevelInfo = 1,
LevelWarn = 2,
LevelError = 3
};

enum SenderType : uint8_t {
ConsumerHub = 0,
ConsumerHttp = 1,
ConstellationHub = 2,
ConstellationHttp = 3
};

enum DescriptorType : uint8_t {
MessageCallbackType = 1,
StateObjectType = 2
};

enum DebugMode : uint8_t {
Off = 0,
Error = 1,
Info = 2,
Debug = 3,
Trace = 4
};

typedef struct {
SenderType type;
const char* friendlyName;
const char* connectionId;
} MessageSender;

typedef struct {
const char* sagaId;
bool isSaga;
const char* messageKey;
MessageSender sender;
ScopeType scope;
} MessageContext;

#endif
56 changes: 56 additions & 0 deletions BufferedPrint.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**************************************************************************/
/*!
@file BufferedPrint.h
@author Benoît Blanchon (https://github.com/bblanchon/ArduinoJson)
@section LICENSE
Copyright Benoit Blanchon 2014-2016
MIT License
Arduino JSON library
https://github.com/bblanchon/ArduinoJson
*/
/**************************************************************************/

#ifndef _BUFFERED_PRINT_
#define _BUFFERED_PRINT_

#include <Client.h>

template <size_t CAPACITY>
class BufferedPrint : public Print {
public:
BufferedPrint(Print& destination) : _destination(destination), _size(0) {}

~BufferedPrint() { flush(); }

virtual size_t write(uint8_t c) {
_buffer[_size++] = c;

if (_size + 1 == CAPACITY) {
flush();
}
}

void flush() {
_buffer[_size] = '\0';
_destination.print(_buffer);
_size = 0;
if(_debug && Serial) {
Serial.print(_buffer);
}
}

void setDebug(bool debug) {
_debug = debug;
}

private:
Print& _destination;
size_t _size;
char _buffer[CAPACITY];
bool _debug;
};

#endif
Loading

0 comments on commit 0848965

Please sign in to comment.