mirror of https://github.com/noisymime/Arduino.git
Removed unused Stream interface from Bridge class
This commit is contained in:
parent
8ac5c7c076
commit
fdae2dbb6e
|
@ -31,19 +31,19 @@ void BridgeClass::begin() {
|
||||||
do {
|
do {
|
||||||
dropAll();
|
dropAll();
|
||||||
delay(1100);
|
delay(1100);
|
||||||
} while (available()>0);
|
} while (stream.available()>0);
|
||||||
|
|
||||||
// Bridge startup:
|
// Bridge startup:
|
||||||
// - If the bridge is not running starts it safely
|
// - If the bridge is not running starts it safely
|
||||||
print(CTRL_C);
|
stream.print(CTRL_C);
|
||||||
delay(250);
|
delay(250);
|
||||||
print(F("\n"));
|
stream.print(F("\n"));
|
||||||
delay(500);
|
delay(500);
|
||||||
print(F("\n"));
|
stream.print(F("\n"));
|
||||||
delay(750);
|
delay(750);
|
||||||
// Wait for OpenWRT message
|
// Wait for OpenWRT message
|
||||||
// "Press enter to activate console"
|
// "Press enter to activate console"
|
||||||
print(F("run-bridge\n"));
|
stream.print(F("run-bridge\n"));
|
||||||
delay(500);
|
delay(500);
|
||||||
dropAll();
|
dropAll();
|
||||||
|
|
||||||
|
@ -111,8 +111,8 @@ void BridgeClass::crcReset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void BridgeClass::crcWrite() {
|
void BridgeClass::crcWrite() {
|
||||||
write((char)(CRC >> 8));
|
stream.write((char)(CRC >> 8));
|
||||||
write((char)(CRC & 0xFF));
|
stream.write((char)(CRC & 0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BridgeClass::crcCheck(uint16_t _CRC) {
|
bool BridgeClass::crcCheck(uint16_t _CRC) {
|
||||||
|
@ -128,24 +128,24 @@ uint16_t BridgeClass::transfer(const uint8_t *buff1, uint16_t len1,
|
||||||
for ( ; ; delay(100), dropAll() /* Delay for retransmission */) {
|
for ( ; ; delay(100), dropAll() /* Delay for retransmission */) {
|
||||||
// Send packet
|
// Send packet
|
||||||
crcReset();
|
crcReset();
|
||||||
write((char)0xFF); // Start of packet (0xFF)
|
stream.write((char)0xFF); // Start of packet (0xFF)
|
||||||
crcUpdate(0xFF);
|
crcUpdate(0xFF);
|
||||||
write((char)index); // Message index
|
stream.write((char)index); // Message index
|
||||||
crcUpdate(index);
|
crcUpdate(index);
|
||||||
write((char)((len >> 8) & 0xFF)); // Message length (hi)
|
stream.write((char)((len >> 8) & 0xFF)); // Message length (hi)
|
||||||
crcUpdate((len >> 8) & 0xFF);
|
crcUpdate((len >> 8) & 0xFF);
|
||||||
write((char)(len & 0xFF)); // Message length (lo)
|
stream.write((char)(len & 0xFF)); // Message length (lo)
|
||||||
crcUpdate(len & 0xFF);
|
crcUpdate(len & 0xFF);
|
||||||
for (uint16_t i=0; i<len1; i++) { // Payload
|
for (uint16_t i=0; i<len1; i++) { // Payload
|
||||||
write((char)buff1[i]);
|
stream.write((char)buff1[i]);
|
||||||
crcUpdate(buff1[i]);
|
crcUpdate(buff1[i]);
|
||||||
}
|
}
|
||||||
for (uint16_t i=0; i<len2; i++) { // Payload
|
for (uint16_t i=0; i<len2; i++) { // Payload
|
||||||
write((char)buff2[i]);
|
stream.write((char)buff2[i]);
|
||||||
crcUpdate(buff2[i]);
|
crcUpdate(buff2[i]);
|
||||||
}
|
}
|
||||||
for (uint16_t i=0; i<len3; i++) { // Payload
|
for (uint16_t i=0; i<len3; i++) { // Payload
|
||||||
write((char)buff3[i]);
|
stream.write((char)buff3[i]);
|
||||||
crcUpdate(buff3[i]);
|
crcUpdate(buff3[i]);
|
||||||
}
|
}
|
||||||
crcWrite(); // CRC
|
crcWrite(); // CRC
|
||||||
|
@ -209,15 +209,15 @@ int BridgeClass::timedRead(unsigned int timeout) {
|
||||||
int c;
|
int c;
|
||||||
unsigned long _startMillis = millis();
|
unsigned long _startMillis = millis();
|
||||||
do {
|
do {
|
||||||
c = read();
|
c = stream.read();
|
||||||
if (c >= 0) return c;
|
if (c >= 0) return c;
|
||||||
} while(millis() - _startMillis < timeout);
|
} while(millis() - _startMillis < timeout);
|
||||||
return -1; // -1 indicates timeout
|
return -1; // -1 indicates timeout
|
||||||
}
|
}
|
||||||
|
|
||||||
void BridgeClass::dropAll() {
|
void BridgeClass::dropAll() {
|
||||||
while (available() > 0) {
|
while (stream.available() > 0) {
|
||||||
read();
|
stream.read();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <Stream.h>
|
#include <Stream.h>
|
||||||
|
|
||||||
class BridgeClass: public Stream {
|
class BridgeClass {
|
||||||
public:
|
public:
|
||||||
BridgeClass(Stream &_stream);
|
BridgeClass(Stream &_stream);
|
||||||
void begin();
|
void begin();
|
||||||
|
@ -40,17 +40,6 @@ public:
|
||||||
unsigned int get(const char *key, char *value, unsigned int maxlen)
|
unsigned int get(const char *key, char *value, unsigned int maxlen)
|
||||||
{ get(key, reinterpret_cast<uint8_t *>(value), maxlen); }
|
{ get(key, reinterpret_cast<uint8_t *>(value), maxlen); }
|
||||||
|
|
||||||
// Print methods (proxy to "stream" object) [CM: are these really needed?]
|
|
||||||
size_t write(uint8_t c) { return stream.write(c); }
|
|
||||||
size_t write(const uint8_t *buffer, size_t size)
|
|
||||||
{ return stream.write(buffer, size); }
|
|
||||||
|
|
||||||
// Stream methods (proxy to "stream" object) [CM: are these really needed?]
|
|
||||||
int available() { return stream.available(); }
|
|
||||||
int read() { return stream.read(); }
|
|
||||||
int peek() { return stream.peek(); }
|
|
||||||
void flush() { stream.flush(); }
|
|
||||||
|
|
||||||
// Trasnfer a frame (with error correction and response)
|
// Trasnfer a frame (with error correction and response)
|
||||||
uint16_t transfer(const uint8_t *buff1, uint16_t len1,
|
uint16_t transfer(const uint8_t *buff1, uint16_t len1,
|
||||||
const uint8_t *buff2, uint16_t len2,
|
const uint8_t *buff2, uint16_t len2,
|
||||||
|
|
Loading…
Reference in New Issue