[XBee] Added Module overrides for all Arduino core functions
This commit is contained in:
parent
41069d0848
commit
123b2f507f
1 changed files with 19 additions and 19 deletions
|
@ -34,7 +34,7 @@ int16_t XBee::begin(long speed) {
|
||||||
RADIOLIB_DEBUG_PRINTLN(state);
|
RADIOLIB_DEBUG_PRINTLN(state);
|
||||||
RADIOLIB_DEBUG_PRINTLN(F("Resetting ..."));
|
RADIOLIB_DEBUG_PRINTLN(F("Resetting ..."));
|
||||||
reset();
|
reset();
|
||||||
delay(10);
|
Module::delay(10);
|
||||||
_mod->ATemptyBuffer();
|
_mod->ATemptyBuffer();
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -51,10 +51,10 @@ int16_t XBee::begin(long speed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void XBee::reset() {
|
void XBee::reset() {
|
||||||
pinMode(_mod->getRst(), OUTPUT);
|
Module::pinMode(_mod->getRst(), OUTPUT);
|
||||||
digitalWrite(_mod->getRst(), LOW);
|
Module::digitalWrite(_mod->getRst(), LOW);
|
||||||
delay(1);
|
Module::delay(1);
|
||||||
digitalWrite(_mod->getRst(), HIGH);
|
Module::digitalWrite(_mod->getRst(), HIGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t XBee::transmit(uint8_t* dest, const char* payload, uint8_t radius) {
|
int16_t XBee::transmit(uint8_t* dest, const char* payload, uint8_t radius) {
|
||||||
|
@ -216,11 +216,11 @@ int16_t XBeeSerial::begin(long speed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void XBeeSerial::reset() {
|
void XBeeSerial::reset() {
|
||||||
pinMode(_mod->getRst(), OUTPUT);
|
Module::pinMode(_mod->getRst(), OUTPUT);
|
||||||
digitalWrite(_mod->getRst(), LOW);
|
Module::digitalWrite(_mod->getRst(), LOW);
|
||||||
delay(1);
|
Module::delay(1);
|
||||||
digitalWrite(_mod->getRst(), HIGH);
|
Module::digitalWrite(_mod->getRst(), HIGH);
|
||||||
pinMode(_mod->getRst(), INPUT);
|
Module::pinMode(_mod->getRst(), INPUT);
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t XBeeSerial::setDestinationAddress(const char* destinationAddressHigh, const char* destinationAddressLow) {
|
int16_t XBeeSerial::setDestinationAddress(const char* destinationAddressHigh, const char* destinationAddressLow) {
|
||||||
|
@ -308,13 +308,13 @@ int16_t XBeeSerial::setPanId(const char* panId) {
|
||||||
|
|
||||||
bool XBeeSerial::enterCmdMode() {
|
bool XBeeSerial::enterCmdMode() {
|
||||||
for(uint8_t i = 0; i < 10; i++) {
|
for(uint8_t i = 0; i < 10; i++) {
|
||||||
delay(1000);
|
Module::delay(1000);
|
||||||
|
|
||||||
_mod->ModuleSerial->write('+');
|
_mod->ModuleSerial->write('+');
|
||||||
_mod->ModuleSerial->write('+');
|
_mod->ModuleSerial->write('+');
|
||||||
_mod->ModuleSerial->write('+');
|
_mod->ModuleSerial->write('+');
|
||||||
|
|
||||||
delay(1000);
|
Module::delay(1000);
|
||||||
|
|
||||||
if(_mod->ATgetResponse()) {
|
if(_mod->ATgetResponse()) {
|
||||||
return(true);
|
return(true);
|
||||||
|
@ -403,10 +403,10 @@ int16_t XBee::readApiFrame(uint8_t frameID, uint8_t codePos, uint16_t timeout) {
|
||||||
numBytes++;
|
numBytes++;
|
||||||
|
|
||||||
// wait until all response bytes are available (5s timeout)
|
// wait until all response bytes are available (5s timeout)
|
||||||
uint32_t start = millis();
|
uint32_t start = Module::millis();
|
||||||
while(_mod->ModuleSerial->available() < (int16_t)numBytes) {
|
while(_mod->ModuleSerial->available() < (int16_t)numBytes) {
|
||||||
yield();
|
Module::yield();
|
||||||
if(millis() - start >= timeout/2) {
|
if(Module::millis() - start >= timeout/2) {
|
||||||
return(ERR_FRAME_MALFORMED);
|
return(ERR_FRAME_MALFORMED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -455,10 +455,10 @@ int16_t XBee::readApiFrame(uint8_t frameID, uint8_t codePos, uint16_t timeout) {
|
||||||
|
|
||||||
uint16_t XBee::getNumBytes(uint32_t timeout, size_t minBytes) {
|
uint16_t XBee::getNumBytes(uint32_t timeout, size_t minBytes) {
|
||||||
// wait for available data
|
// wait for available data
|
||||||
uint32_t start = millis();
|
uint32_t start = Module::millis();
|
||||||
while((size_t)_mod->ModuleSerial->available() < minBytes) {
|
while((size_t)_mod->ModuleSerial->available() < minBytes) {
|
||||||
yield();
|
Module::yield();
|
||||||
if(millis() - start >= timeout) {
|
if(Module::millis() - start >= timeout) {
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -468,7 +468,7 @@ uint16_t XBee::getNumBytes(uint32_t timeout, size_t minBytes) {
|
||||||
uint8_t i = 0;
|
uint8_t i = 0;
|
||||||
RADIOLIB_DEBUG_PRINT(F("reading frame length: "));
|
RADIOLIB_DEBUG_PRINT(F("reading frame length: "));
|
||||||
while(_mod->ModuleSerial->available() > 0) {
|
while(_mod->ModuleSerial->available() > 0) {
|
||||||
yield();
|
Module::yield();
|
||||||
uint8_t b = _mod->ModuleSerial->read();
|
uint8_t b = _mod->ModuleSerial->read();
|
||||||
RADIOLIB_DEBUG_PRINT(b, HEX);
|
RADIOLIB_DEBUG_PRINT(b, HEX);
|
||||||
RADIOLIB_DEBUG_PRINT('\t');
|
RADIOLIB_DEBUG_PRINT('\t');
|
||||||
|
|
Loading…
Add table
Reference in a new issue