-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5afb444
commit 00d64bc
Showing
5 changed files
with
70 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,46 @@ | ||
#ifndef __UART_DEVICE_H__ | ||
#define __UART_DEVICE_H__ | ||
#ifndef __UART_DEVICE_GPRS_H__ | ||
#define __UART_DEVICE_GPRS_H__ | ||
#include <Arduino.h> | ||
|
||
// miliseconds | ||
#define DEFAULT_TIMEOUT 1000 | ||
// miliseconds | ||
#define DEFAULT_INTERCHAR_TIMEOUT 1000 | ||
|
||
// using namespace for GPS | ||
namespace GPSNAME { | ||
|
||
enum dataType { | ||
CMD = 0, | ||
DATA = 1, | ||
}; | ||
|
||
void uartDeviceInit(void* uartDevice); | ||
int uartDeviceAvailable(); | ||
int uartDeviceAvailable(int waitTime); | ||
void uartDeviceFlushSerial(); | ||
int uartDeviceReadSerial(); | ||
void uartDeviceReadBuffer(char* buffer,int count, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int charTimeout = DEFAULT_INTERCHAR_TIMEOUT); | ||
void uartDeviceCleanBuffer(char* buffer, int count); | ||
void uartDeviceSendByte(uint8_t data); | ||
void uartDeviceSendChar(const char c); | ||
void uartDeviceSendCMD(const char* cmd); | ||
void uartDeviceSendCMD(const __FlashStringHelper* cmd); | ||
void uartDeviceSendCMDP(const char* cmd); | ||
void uartDeviceSendAT(void); | ||
void uartDeviceSendEndMark(void); | ||
bool uartDeviceWaitForResp(const char* resp, dataType type, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int charTimeout = DEFAULT_INTERCHAR_TIMEOUT); | ||
bool uartDeviceCheckWithCMD(const char* cmd, const char *resp, dataType type, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int charTimeout = DEFAULT_INTERCHAR_TIMEOUT); | ||
bool uartDeviceCheckWithCMD(const __FlashStringHelper* cmd, const char *resp, dataType type, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int charTimeout = DEFAULT_INTERCHAR_TIMEOUT); | ||
// abstract base class | ||
class UARTDevice | ||
{ | ||
public: | ||
UARTDevice(Stream* uartDevice); | ||
virtual ~UARTDevice() = 0; | ||
int uartDeviceAvailable(); | ||
int uartDeviceAvailable(int waitTime); | ||
void uartDeviceFlushSerial(); | ||
int uartDeviceReadSerial(); | ||
void uartDeviceReadBuffer(char* buffer, int count, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int charTimeout = DEFAULT_INTERCHAR_TIMEOUT); | ||
void uartDeviceCleanBuffer(char* buffer, int count); | ||
void uartDeviceSendByte(uint8_t data); | ||
void uartDeviceSendChar(const char c); | ||
void uartDeviceSendCMD(const char* cmd); | ||
void uartDeviceSendCMD(const __FlashStringHelper* cmd); | ||
void uartDeviceSendCMDP(const char* cmd); | ||
void uartDeviceSendAT(); | ||
void uartDeviceSendEndMark(); | ||
bool uartDeviceWaitForResp(const char* resp, dataType type, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int charTimeout = DEFAULT_INTERCHAR_TIMEOUT); | ||
bool uartDeviceCheckWithCMD(const char* cmd, const char* resp, dataType type, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int charTimeout = DEFAULT_INTERCHAR_TIMEOUT); | ||
bool uartDeviceCheckWithCMD(const __FlashStringHelper* cmd, const char* resp, dataType type, unsigned int timeout = DEFAULT_TIMEOUT, unsigned int charTimeout = DEFAULT_INTERCHAR_TIMEOUT); | ||
private: | ||
Stream* _uartDevice; | ||
}; | ||
|
||
} | ||
|
||
#endif |