Changed src folder structure
This commit is contained in:
parent
be079c5ddc
commit
331d96979a
15 changed files with 54 additions and 258 deletions
142
src/HC05.cpp
142
src/HC05.cpp
|
@ -1,142 +0,0 @@
|
|||
#include "HC05.h"
|
||||
|
||||
HC05::HC05(Module* module) {
|
||||
_mod = module;
|
||||
}
|
||||
|
||||
void HC05::begin(long speed) {
|
||||
_mod->baudrate = speed;
|
||||
_mod->init(USE_UART, INT_NONE);
|
||||
}
|
||||
|
||||
bool HC05::listen() {
|
||||
return(_mod->ModuleSerial->listen());
|
||||
}
|
||||
|
||||
void HC05::end() {
|
||||
_mod->ModuleSerial->end();
|
||||
}
|
||||
|
||||
bool HC05::isListening() {
|
||||
return(_mod->ModuleSerial->isListening());
|
||||
}
|
||||
|
||||
bool HC05::stopListening() {
|
||||
return(_mod->ModuleSerial->stopListening());
|
||||
}
|
||||
|
||||
bool HC05::overflow() {
|
||||
return(_mod->ModuleSerial->overflow());
|
||||
}
|
||||
|
||||
int HC05::peek() {
|
||||
return(_mod->ModuleSerial->peek());
|
||||
}
|
||||
|
||||
size_t HC05::write(uint8_t b) {
|
||||
return(_mod->ModuleSerial->write(b));
|
||||
}
|
||||
|
||||
int HC05::read() {
|
||||
return(_mod->ModuleSerial->read());
|
||||
}
|
||||
|
||||
int HC05::available() {
|
||||
return(_mod->ModuleSerial->available());
|
||||
}
|
||||
|
||||
void HC05::flush() {
|
||||
_mod->ModuleSerial->flush();
|
||||
}
|
||||
|
||||
size_t HC05::print(const __FlashStringHelper *ifsh) {
|
||||
return(_mod->ModuleSerial->print(ifsh));
|
||||
}
|
||||
|
||||
size_t HC05::print(const String &s) {
|
||||
return(_mod->ModuleSerial->print(s));
|
||||
}
|
||||
|
||||
size_t HC05::print(const char str[]) {
|
||||
return(_mod->ModuleSerial->print(str));
|
||||
}
|
||||
|
||||
size_t HC05::print(char c) {
|
||||
return(_mod->ModuleSerial->print(c));
|
||||
}
|
||||
|
||||
size_t HC05::print(unsigned char b, int base) {
|
||||
return(_mod->ModuleSerial->print(b, base));
|
||||
}
|
||||
|
||||
size_t HC05::print(int n, int base) {
|
||||
return(_mod->ModuleSerial->print(n, base));
|
||||
}
|
||||
|
||||
size_t HC05::print(unsigned int n, int base) {
|
||||
return(_mod->ModuleSerial->print(n, base));
|
||||
}
|
||||
|
||||
size_t HC05::print(long n, int base) {
|
||||
return(_mod->ModuleSerial->print(n, base));
|
||||
}
|
||||
|
||||
size_t HC05::print(unsigned long n, int base) {
|
||||
return(_mod->ModuleSerial->print(n, base));
|
||||
}
|
||||
|
||||
size_t HC05::print(double n, int digits) {
|
||||
return(_mod->ModuleSerial->print(n, digits));
|
||||
}
|
||||
|
||||
size_t HC05::print(const Printable& x) {
|
||||
return(_mod->ModuleSerial->print(x));
|
||||
}
|
||||
|
||||
size_t HC05::println(const __FlashStringHelper *ifsh) {
|
||||
return(_mod->ModuleSerial->println(ifsh));
|
||||
}
|
||||
|
||||
size_t HC05::println(const String &s) {
|
||||
return(_mod->ModuleSerial->println(s));
|
||||
}
|
||||
|
||||
size_t HC05::println(const char str[]) {
|
||||
return(_mod->ModuleSerial->println(str));
|
||||
}
|
||||
|
||||
size_t HC05::println(char c) {
|
||||
return(_mod->ModuleSerial->println(c));
|
||||
}
|
||||
|
||||
size_t HC05::println(unsigned char b, int base) {
|
||||
return(_mod->ModuleSerial->println(b, base));
|
||||
}
|
||||
|
||||
size_t HC05::println(int n, int base) {
|
||||
return(_mod->ModuleSerial->println(n, base));
|
||||
}
|
||||
|
||||
size_t HC05::println(unsigned int n, int base) {
|
||||
return(_mod->ModuleSerial->println(n, base));
|
||||
}
|
||||
|
||||
size_t HC05::println(long n, int base) {
|
||||
return(_mod->ModuleSerial->println(n, base));
|
||||
}
|
||||
|
||||
size_t HC05::println(unsigned long n, int base) {
|
||||
return(_mod->ModuleSerial->println(n, base));
|
||||
}
|
||||
|
||||
size_t HC05::println(double n, int digits) {
|
||||
return(_mod->ModuleSerial->println(n, digits));
|
||||
}
|
||||
|
||||
size_t HC05::println(const Printable& x) {
|
||||
return(_mod->ModuleSerial->println(x));
|
||||
}
|
||||
|
||||
size_t HC05::println(void) {
|
||||
return(_mod->ModuleSerial->println());
|
||||
}
|
56
src/HC05.h
56
src/HC05.h
|
@ -1,56 +0,0 @@
|
|||
#ifndef _KITELIB_HC05_H
|
||||
#define _KITELIB_HC05_H
|
||||
|
||||
#include "Module.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "WString.h"
|
||||
#include "Printable.h"
|
||||
|
||||
class HC05 {
|
||||
public:
|
||||
HC05(Module* module);
|
||||
|
||||
void begin(long speed);
|
||||
bool listen();
|
||||
void end();
|
||||
bool isListening();
|
||||
bool stopListening();
|
||||
bool overflow();
|
||||
int peek();
|
||||
size_t write(uint8_t);
|
||||
int read();
|
||||
int available();
|
||||
void flush();
|
||||
|
||||
size_t print(const __FlashStringHelper *);
|
||||
size_t print(const String &);
|
||||
size_t print(const char[]);
|
||||
size_t print(char);
|
||||
size_t print(unsigned char, int = DEC);
|
||||
size_t print(int, int = DEC);
|
||||
size_t print(unsigned int, int = DEC);
|
||||
size_t print(long, int = DEC);
|
||||
size_t print(unsigned long, int = DEC);
|
||||
size_t print(double, int = 2);
|
||||
size_t print(const Printable&);
|
||||
|
||||
size_t println(const __FlashStringHelper *);
|
||||
size_t println(const String &s);
|
||||
size_t println(const char[]);
|
||||
size_t println(char);
|
||||
size_t println(unsigned char, int = DEC);
|
||||
size_t println(int, int = DEC);
|
||||
size_t println(unsigned int, int = DEC);
|
||||
size_t println(long, int = DEC);
|
||||
size_t println(unsigned long, int = DEC);
|
||||
size_t println(double, int = 2);
|
||||
size_t println(const Printable&);
|
||||
size_t println(void);
|
||||
|
||||
private:
|
||||
Module* _mod;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -4,12 +4,12 @@
|
|||
#include "TypeDef.h"
|
||||
#include "Module.h"
|
||||
|
||||
#include "ESP8266.h"
|
||||
#include "SX1278.h"
|
||||
#include "SX1272.h"
|
||||
#include "HC05.h"
|
||||
#include "XBee.h"
|
||||
#include "RF69.h"
|
||||
#include "modules/ESP8266.h"
|
||||
#include "modules/SX1278.h"
|
||||
#include "modules/SX1272.h"
|
||||
#include "modules/HC05.h"
|
||||
#include "modules/XBee.h"
|
||||
#include "modules/RF69.h"
|
||||
|
||||
#define KITE_CS_A 10
|
||||
#define KITE_TX_A 9
|
||||
|
|
10
src/modules/HC05.cpp
Normal file
10
src/modules/HC05.cpp
Normal file
|
@ -0,0 +1,10 @@
|
|||
#include "HC05.h"
|
||||
|
||||
HC05::HC05(Module* module) {
|
||||
_mod = module;
|
||||
}
|
||||
|
||||
void HC05::begin(long speed) {
|
||||
_mod->baudrate = speed;
|
||||
_mod->init(USE_UART, INT_NONE);
|
||||
}
|
13
src/modules/HC05.h
Normal file
13
src/modules/HC05.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#ifndef _KITELIB_HC05_H
|
||||
#define _KITELIB_HC05_H
|
||||
|
||||
#include "ISerial.h"
|
||||
|
||||
class HC05: public ISerial {
|
||||
public:
|
||||
HC05(Module* module);
|
||||
|
||||
void begin(long speed);
|
||||
};
|
||||
|
||||
#endif
|
|
@ -57,13 +57,6 @@ uint8_t XBee::setDestinationAddress(const char destinationAddressHigh[], const c
|
|||
return(ERR_CMD_MODE_FAILED);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
Serial.println("Setting PAN ID to 1 ...");
|
||||
#endif
|
||||
if(!_mod->ATsendCommand("ATID1")) {
|
||||
return(ERR_AT_FAILED);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
Serial.println("Setting address (high) ...");
|
||||
#endif
|
||||
|
@ -92,39 +85,7 @@ uint8_t XBee::setDestinationAddress(const char destinationAddressHigh[], const c
|
|||
return(ERR_NONE);
|
||||
}
|
||||
|
||||
size_t XBee::println(const char str[]) {
|
||||
return(_mod->ModuleSerial->println(str));
|
||||
}
|
||||
|
||||
size_t XBee::write(uint8_t b) {
|
||||
return(_mod->ModuleSerial->write(b));
|
||||
}
|
||||
|
||||
int XBee::available() {
|
||||
return(_mod->ModuleSerial->available());
|
||||
}
|
||||
|
||||
int XBee::read() {
|
||||
return(_mod->ModuleSerial->read());
|
||||
}
|
||||
|
||||
/*uint8_t XBee::transmit(Packet& pack) {
|
||||
|
||||
#ifdef DEBUG
|
||||
Serial.println("Writing packet data ...");
|
||||
#endif
|
||||
for(uint8_t i = 0; i < pack.length - 16; i++) {
|
||||
#ifdef DEBUG
|
||||
Serial.println(pack.data[i]);
|
||||
#endif
|
||||
_mod->ModuleSerial->write(pack.data[i]);
|
||||
}
|
||||
_mod->ModuleSerial->write('\n');
|
||||
|
||||
return(ERR_NONE);
|
||||
}
|
||||
|
||||
uint8_t XBee::receive(Packet& pack) {
|
||||
uint8_t XBee::setPanId(const char panId[]) {
|
||||
#ifdef DEBUG
|
||||
Serial.println("Entering command mode ...");
|
||||
#endif
|
||||
|
@ -132,8 +93,24 @@ uint8_t XBee::receive(Packet& pack) {
|
|||
return(ERR_CMD_MODE_FAILED);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
Serial.println("Setting PAN ID ...");
|
||||
#endif
|
||||
String panIdCmd = "ATID";
|
||||
panIdCmd += panId;
|
||||
if(!_mod->ATsendCommand(panIdCmd)) {
|
||||
return(ERR_AT_FAILED);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
Serial.println("Exiting command mode ...");
|
||||
#endif
|
||||
if(!_mod->ATsendCommand("ATCN")) {
|
||||
return(ERR_AT_FAILED);
|
||||
}
|
||||
|
||||
return(ERR_NONE);
|
||||
}*/
|
||||
}
|
||||
|
||||
bool XBee::enterCmdMode() {
|
||||
for(uint8_t i = 0; i < 10; i++) {
|
||||
|
@ -161,7 +138,7 @@ bool XBee::enterCmdMode() {
|
|||
|
||||
if(i == 9) {
|
||||
#ifdef DEBUG
|
||||
Serial.println("Terminated, check your wiring.");
|
||||
Serial.println("Terminated, check your wiring. Is AT FW uploaded?");
|
||||
#endif
|
||||
return(false);
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
#ifndef _KITELIB_XBEE_H
|
||||
#define _KITELIB_XBEE_H
|
||||
|
||||
#include "Module.h"
|
||||
#include "ISerial.h"
|
||||
#include "TypeDef.h"
|
||||
#include "Packet.h"
|
||||
|
||||
/*//API reserved characters
|
||||
//API reserved characters
|
||||
#define XBEE_API_START 0x7E
|
||||
#define XBEE_API_ESCAPE 0x7D
|
||||
#define XBEE_API_XON 0x11
|
||||
|
@ -32,7 +32,7 @@
|
|||
#define XBEE_API_FRAME_ROUTE_RECORD 0xA1
|
||||
#define XBEE_API_FRAME_MANY_TO_ONE_ROUTE_REQUEST 0xA3
|
||||
|
||||
#define XBEE_API_DEFAULT_FRAME_ID 0x01*/
|
||||
#define XBEE_API_DEFAULT_FRAME_ID 0x01
|
||||
|
||||
class XBeeApiFrame {
|
||||
public:
|
||||
|
@ -48,22 +48,16 @@ class XBeeApiFrame {
|
|||
uint8_t* _data;
|
||||
};
|
||||
|
||||
class XBee {
|
||||
class XBee: public ISerial {
|
||||
public:
|
||||
XBee(Module* module);
|
||||
|
||||
uint8_t begin(long speed);
|
||||
//uint8_t transmit(uint32_t destinationAddressHigh, uint32_t destinationAddressLow, const char* data, uint8_t length);
|
||||
|
||||
uint8_t setDestinationAddress(const char destinationAddressHigh[], const char destinationAddressLow[]);
|
||||
/*uint8_t transmit(Packet& pack);
|
||||
uint8_t receive(Packet& pack);*/
|
||||
size_t println(const char str[]);
|
||||
size_t write(uint8_t b);
|
||||
int available();
|
||||
int read();
|
||||
uint8_t setPanId(const char panId[]);
|
||||
|
||||
private:
|
||||
Module* _mod;
|
||||
bool enterCmdMode();
|
||||
//void sendApiFrame(uint8_t id, uint8_t* data, uint16_t length);
|
||||
//uint8_t readApiFrame(uint16_t timeout);
|
Loading…
Add table
Reference in a new issue