mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-25 06:22:11 +03:00
Run new astyle formatter against libs Bridge, SpacebrewYun and Temboo
This commit is contained in:
@ -23,70 +23,80 @@
|
||||
#include <Stream.h>
|
||||
|
||||
class BridgeClass {
|
||||
public:
|
||||
BridgeClass(Stream &_stream);
|
||||
void begin();
|
||||
|
||||
// Methods to handle key/value datastore
|
||||
void put(const char *key, const char *value);
|
||||
void put(const String &key, const String &value)
|
||||
{ put(key.c_str(), value.c_str()); }
|
||||
unsigned int get(const char *key, uint8_t *buff, unsigned int size);
|
||||
unsigned int get(const char *key, char *value, unsigned int maxlen)
|
||||
{ get(key, reinterpret_cast<uint8_t *>(value), maxlen); }
|
||||
|
||||
// Trasnfer a frame (with error correction and response)
|
||||
uint16_t transfer(const uint8_t *buff1, uint16_t len1,
|
||||
const uint8_t *buff2, uint16_t len2,
|
||||
const uint8_t *buff3, uint16_t len3,
|
||||
uint8_t *rxbuff, uint16_t rxlen);
|
||||
// multiple inline versions of the same function to allow efficient frame concatenation
|
||||
uint16_t transfer(const uint8_t *buff1, uint16_t len1)
|
||||
{ return transfer(buff1, len1, NULL, 0); }
|
||||
uint16_t transfer(const uint8_t *buff1, uint16_t len1,
|
||||
uint8_t *rxbuff, uint16_t rxlen)
|
||||
{ return transfer(buff1, len1, NULL, 0, rxbuff, rxlen); }
|
||||
uint16_t transfer(const uint8_t *buff1, uint16_t len1,
|
||||
const uint8_t *buff2, uint16_t len2,
|
||||
uint8_t *rxbuff, uint16_t rxlen)
|
||||
{ return transfer(buff1, len1, buff2, len2, NULL, 0, rxbuff, rxlen); }
|
||||
public:
|
||||
BridgeClass(Stream &_stream);
|
||||
void begin();
|
||||
|
||||
static const int TRANSFER_TIMEOUT = 0xFFFF;
|
||||
// Methods to handle key/value datastore
|
||||
void put(const char *key, const char *value);
|
||||
void put(const String &key, const String &value)
|
||||
{
|
||||
put(key.c_str(), value.c_str());
|
||||
}
|
||||
unsigned int get(const char *key, uint8_t *buff, unsigned int size);
|
||||
unsigned int get(const char *key, char *value, unsigned int maxlen)
|
||||
{
|
||||
get(key, reinterpret_cast<uint8_t *>(value), maxlen);
|
||||
}
|
||||
|
||||
private:
|
||||
uint8_t index;
|
||||
int timedRead(unsigned int timeout);
|
||||
void dropAll();
|
||||
|
||||
private:
|
||||
void crcUpdate(uint8_t c);
|
||||
void crcReset();
|
||||
void crcWrite();
|
||||
bool crcCheck(uint16_t _CRC);
|
||||
uint16_t CRC;
|
||||
|
||||
private:
|
||||
static const char CTRL_C = 3;
|
||||
Stream &stream;
|
||||
bool started;
|
||||
uint8_t max_retries;
|
||||
// Trasnfer a frame (with error correction and response)
|
||||
uint16_t transfer(const uint8_t *buff1, uint16_t len1,
|
||||
const uint8_t *buff2, uint16_t len2,
|
||||
const uint8_t *buff3, uint16_t len3,
|
||||
uint8_t *rxbuff, uint16_t rxlen);
|
||||
// multiple inline versions of the same function to allow efficient frame concatenation
|
||||
uint16_t transfer(const uint8_t *buff1, uint16_t len1)
|
||||
{
|
||||
return transfer(buff1, len1, NULL, 0);
|
||||
}
|
||||
uint16_t transfer(const uint8_t *buff1, uint16_t len1,
|
||||
uint8_t *rxbuff, uint16_t rxlen)
|
||||
{
|
||||
return transfer(buff1, len1, NULL, 0, rxbuff, rxlen);
|
||||
}
|
||||
uint16_t transfer(const uint8_t *buff1, uint16_t len1,
|
||||
const uint8_t *buff2, uint16_t len2,
|
||||
uint8_t *rxbuff, uint16_t rxlen)
|
||||
{
|
||||
return transfer(buff1, len1, buff2, len2, NULL, 0, rxbuff, rxlen);
|
||||
}
|
||||
|
||||
static const int TRANSFER_TIMEOUT = 0xFFFF;
|
||||
|
||||
private:
|
||||
uint8_t index;
|
||||
int timedRead(unsigned int timeout);
|
||||
void dropAll();
|
||||
|
||||
private:
|
||||
void crcUpdate(uint8_t c);
|
||||
void crcReset();
|
||||
void crcWrite();
|
||||
bool crcCheck(uint16_t _CRC);
|
||||
uint16_t CRC;
|
||||
|
||||
private:
|
||||
static const char CTRL_C = 3;
|
||||
Stream &stream;
|
||||
bool started;
|
||||
uint8_t max_retries;
|
||||
};
|
||||
|
||||
// This subclass uses a serial port Stream
|
||||
class SerialBridgeClass : public BridgeClass {
|
||||
public:
|
||||
SerialBridgeClass(HardwareSerial &_serial)
|
||||
: BridgeClass(_serial), serial(_serial) {
|
||||
// Empty
|
||||
}
|
||||
|
||||
void begin(unsigned long baudrate = 250000) {
|
||||
serial.begin(baudrate);
|
||||
BridgeClass::begin();
|
||||
}
|
||||
|
||||
private:
|
||||
HardwareSerial &serial;
|
||||
public:
|
||||
SerialBridgeClass(HardwareSerial &_serial)
|
||||
: BridgeClass(_serial), serial(_serial) {
|
||||
// Empty
|
||||
}
|
||||
|
||||
void begin(unsigned long baudrate = 250000) {
|
||||
serial.begin(baudrate);
|
||||
BridgeClass::begin();
|
||||
}
|
||||
|
||||
private:
|
||||
HardwareSerial &serial;
|
||||
};
|
||||
|
||||
extern SerialBridgeClass Bridge;
|
||||
|
Reference in New Issue
Block a user