LOM2M  0.8.0
Typedefs | Enumerations | Functions | Variables
bsp.h File Reference
#include <WString.h>
#include <ArduinoJson.h>
#include "ResponsePrimitive.h"

Go to the source code of this file.

Typedefs

typedef uint64_t utime_t
 
using printfmt = std::function< void(int level, const char *tag, const char *data)>
 
using Millis = decltype(millis())
 

Enumerations

enum  HTTPCode {
  H000 = 0 , H200_OK = 200 , H201_Created = 201 , H204_NoContent = 204 ,
  H400_BadRequest = 400 , H401_Unauthorized = 401 , H403_Forbidden = 403 , H404_NotFound = 404 ,
  H405_NotAllowed = 405 , H406_NotAcceptable = 406 , H408_RequestTimeout = 408 , H409_Conflict = 409 ,
  H415_Unsupported = 415 , H500_InternalError = 500 , H501_NotImplemented = 501 , H503_Maintenance = 503
}
 
enum  Encoding { ENC_NONE = -1 , ENC_JSON }
 

Functions

const String HTTPCode2Human (HTTPCode code)
 
HTTPMethod method ()
 
const char * method (HTTPMethod m)
 
void sendReply (HTTPCode code, const String &contentType, const String &message)
 
void sendReply (ResponsePrimitive &resp, const String &contentType, const String &message)
 
void sendReply (ResponsePrimitive &resp, const String &message)
 
const String & HTTPContent ()
 
template<typename T >
const String & HTTPHeader (const T &attribute)
 
template<typename T >
const String & HTTPArg (const T &key)
 
template<typename T >
bool HTTPHasArg (const T &key)
 
utime_t get_utime ()
 
String get_ctime (time_t t)
 
utime_t getTimeFromString (String t)
 
void log_setup ()
 
void log (const char *fmt,...)
 
void logStream (Stream *in)
 
void printHuman (Stream &to, int level, const char *tag, const char *data)
 
void printHumanSerial (int level, const char *tag, const char *data)
 
String getMac ()
 
bool FSOpen ()
 
void FSClose ()
 
int persistenceStore (JsonObject toStore, const char *name=defaultPersistenceName)
 
DeserializationError persistenceLoad (JsonDocument &toStore, const char *name=defaultPersistenceName)
 

Variables

const String emptyString
 
utime_t default_expiration_duration
 
constexpr char listSeparator = '#'
 
const char * defaultPersistenceName
 

Typedef Documentation

◆ Millis

using Millis = decltype(millis())

◆ printfmt

using printfmt = std::function<void(int level, const char* tag, const char* data)>

◆ utime_t

typedef uint64_t utime_t

Enumeration Type Documentation

◆ Encoding

enum Encoding
Enumerator
ENC_NONE 
ENC_JSON 

◆ HTTPCode

enum HTTPCode
Enumerator
H000 
H200_OK 
H201_Created 
H204_NoContent 
H400_BadRequest 
H401_Unauthorized 
H403_Forbidden 
H404_NotFound 
H405_NotAllowed 
H406_NotAcceptable 
H408_RequestTimeout 
H409_Conflict 
H415_Unsupported 
H500_InternalError 
H501_NotImplemented 
H503_Maintenance 

Function Documentation

◆ FSClose()

void FSClose ( )

Enable to close the file system

Returns
true if success, false if failure

◆ FSOpen()

bool FSOpen ( )

Enable to open the file system

Returns
true if success, false if failure

◆ get_ctime()

String get_ctime ( time_t  t)

◆ get_utime()

utime_t get_utime ( )

◆ getMac()

String getMac ( )

◆ getTimeFromString()

utime_t getTimeFromString ( String  t)

Get the time given in parameter. Use the oneM2M format %04d%02d%02dT%02d%02d%02d

Parameters
t- time as String in oneM2M format
Returns
time in the used structure

◆ HTTPArg()

template<typename T >
const String& HTTPArg ( const T &  key)
inline

◆ HTTPCode2Human()

const String HTTPCode2Human ( HTTPCode  code)
inline

◆ HTTPContent()

const String& HTTPContent ( )
inline

◆ HTTPHasArg()

template<typename T >
bool HTTPHasArg ( const T &  key)
inline

◆ HTTPHeader()

template<typename T >
const String& HTTPHeader ( const T &  attribute)
inline

◆ log()

void log ( const char *  fmt,
  ... 
)

◆ log_setup()

void log_setup ( )

◆ logStream()

void logStream ( Stream *  in)
inline

◆ method() [1/2]

HTTPMethod method ( )
inline

◆ method() [2/2]

const char* method ( HTTPMethod  m)

◆ persistenceLoad()

DeserializationError persistenceLoad ( JsonDocument &  toStore,
const char *  name = defaultPersistenceName 
)

Enable to load data from a file into a jsondocument (provided) This open and close file system to do so

Returns
errorCode (see src/ArduinoJson/Deserialization/DeserializationError.hpp)
  • DeserializationError::Ok
  • DeserializationError::IncompleteInput
  • DeserializationError::InvalidInput
  • DeserializationError::NoMemory
  • DeserializationError::NotSupported <– + file or filesystem error
  • DeserializationError::TooDeep

◆ persistenceStore()

int persistenceStore ( JsonObject  toStore,
const char *  name = defaultPersistenceName 
)

Enable to store in a json file the whole json object provided This open and close file system to do so

Parameters
toStorejson object to store in the file
name(optional) name of the file where the data will be stored
Returns
error code, -1: error, >= 0 size of written data

◆ printHuman()

void printHuman ( Stream &  to,
int  level,
const char *  tag,
const char *  data 
)

◆ printHumanSerial()

void printHumanSerial ( int  level,
const char *  tag,
const char *  data 
)

◆ sendReply() [1/3]

void sendReply ( HTTPCode  code,
const String &  contentType,
const String &  message 
)
inline

◆ sendReply() [2/3]

void sendReply ( ResponsePrimitive resp,
const String &  contentType,
const String &  message 
)

◆ sendReply() [3/3]

void sendReply ( ResponsePrimitive resp,
const String &  message 
)
inline

Variable Documentation

◆ default_expiration_duration

utime_t default_expiration_duration
extern

◆ defaultPersistenceName

const char* defaultPersistenceName
extern

◆ emptyString

const String emptyString
extern

◆ listSeparator

constexpr char listSeparator = '#'
constexpr