You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.0 KiB
75 lines
2.0 KiB
#include "protocolAT.h"
|
|
|
|
#define LOG( X ) m_pLog->Log( "pAT", this, X )
|
|
|
|
#ifdef DEBUG
|
|
#define LOG_ERROR( X ) {\
|
|
char _tBfrErrMSG2w34[256];\
|
|
sprintf( _tBfrErrMSG2w34, "In file %s[%d] in func:%s %s",__FILE__, __LINE__, __func__, X );\
|
|
m_pLog->Log( "pAT", this, _LOG_ERROR, _tBfrErrMSG2w34 );\
|
|
}
|
|
#else
|
|
#define LOG_ERROR( X ) m_pLog->Log( "pAT", this, _LOG_ERROR, X );
|
|
#endif
|
|
|
|
protocolAT::protocolAT(){
|
|
|
|
};
|
|
|
|
protocolAT::~protocolAT(){
|
|
|
|
};
|
|
|
|
bool protocolAT::create(void) {
|
|
if ( m_oDataTransport ) {
|
|
if( m_oDataTransport->getConnectionStatus() == CS_CONNECTED ){
|
|
// Turn Off Echo
|
|
m_oDataTransport->sendData( (unsigned char*)AT_BEG "E" AT_EOL, 5 );
|
|
waitResponce();
|
|
m_oDataTransport->sendData( (unsigned char*)AT_BEG "I" AT_EOL, 5 );
|
|
waitResponce();
|
|
};
|
|
};
|
|
return false;
|
|
};
|
|
|
|
int protocolAT::packetChecker(U8 *Buffer, size_t BufferSize){
|
|
if ( BufferSize ) {
|
|
if( Buffer[0] < 0x20 ) return -1;
|
|
if( Buffer[BufferSize-1] == 0x0A ) return 0;
|
|
};
|
|
return 1;
|
|
};
|
|
|
|
bool protocolAT::packetHandler(protocolPackage *Package) {
|
|
};
|
|
|
|
protocolPackage *protocolAT::packetExtractor(U8 *Buffer, size_t BufferSize) {
|
|
protocolPackage *tVal=NULL;
|
|
if( BufferSize ){
|
|
int idx = 0;
|
|
tVal = (protocolPackage *) malloc( sizeof(protocolPackage) );
|
|
if ( tVal ) {
|
|
memset( tVal, 0, sizeof(protocolPackage));
|
|
for (idx = 0; idx < BufferSize; idx++) {
|
|
if( Buffer[idx]==0x0D ) break;
|
|
};
|
|
tVal->m_nCode = 200;
|
|
if( idx < (BufferSize-2) ){
|
|
// Must be fetched OK status
|
|
|
|
};
|
|
} else {
|
|
LOG_ERROR("pkg malloc!");
|
|
}
|
|
};
|
|
return tVal;
|
|
};
|
|
|
|
void protocolAT::waitResponce( uint32_t TO ){
|
|
while( TO--) SLEEP(50);
|
|
};
|
|
|
|
#undef LOG
|
|
#undef LOG_ERROR
|
|
|