@ -18,6 +18,7 @@ typedef struct {
uint8_t invId ;
uint8_t invId ;
uint32_t ts ;
uint32_t ts ;
uint8_t data [ MAX_PAYLOAD_ENTRIES ] [ MAX_RF_PAYLOAD_SIZE ] ;
uint8_t data [ MAX_PAYLOAD_ENTRIES ] [ MAX_RF_PAYLOAD_SIZE ] ;
int8_t rssi [ MAX_PAYLOAD_ENTRIES ] ;
uint8_t len [ MAX_PAYLOAD_ENTRIES ] ;
uint8_t len [ MAX_PAYLOAD_ENTRIES ] ;
bool complete ;
bool complete ;
uint8_t maxPackId ;
uint8_t maxPackId ;
@ -172,6 +173,7 @@ class HmPayload {
memcpy ( mPayload [ iv - > id ] . data [ ( * pid & 0x7F ) - 1 ] , & p - > packet [ 10 ] , p - > len - 11 ) ;
memcpy ( mPayload [ iv - > id ] . data [ ( * pid & 0x7F ) - 1 ] , & p - > packet [ 10 ] , p - > len - 11 ) ;
mPayload [ iv - > id ] . len [ ( * pid & 0x7F ) - 1 ] = p - > len - 11 ;
mPayload [ iv - > id ] . len [ ( * pid & 0x7F ) - 1 ] = p - > len - 11 ;
mPayload [ iv - > id ] . gotFragment = true ;
mPayload [ iv - > id ] . gotFragment = true ;
mPayload [ iv - > id ] . rssi [ ( * pid & 0x7F ) - 1 ] = p - > rssi ;
}
}
if ( ( * pid & ALL_FRAMES ) = = ALL_FRAMES ) {
if ( ( * pid & ALL_FRAMES ) = = ALL_FRAMES ) {
@ -284,8 +286,8 @@ class HmPayload {
} else { // payload complete
} else { // payload complete
DPRINT ( DBG_INFO , F ( " procPyld: cmd: 0x " ) ) ;
DPRINT ( DBG_INFO , F ( " procPyld: cmd: 0x " ) ) ;
DBGHEXLN ( mPayload [ iv - > id ] . txCmd ) ;
DBGHEXLN ( mPayload [ iv - > id ] . txCmd ) ;
DPRINT ( DBG_INFO , F ( " procPyld: txid: 0x " ) ) ;
//DPRINT(DBG_DEBUG, F("procPyld: txid: 0x"));
DBGHEXLN ( mPayload [ iv - > id ] . txId ) ;
//DBGHEXLN(mPayload[iv->id].txId);
DPRINT ( DBG_DEBUG , F ( " procPyld: max: " ) ) ;
DPRINT ( DBG_DEBUG , F ( " procPyld: max: " ) ) ;
DPRINTLN ( DBG_DEBUG , String ( mPayload [ iv - > id ] . maxPackId ) ) ;
DPRINTLN ( DBG_DEBUG , String ( mPayload [ iv - > id ] . maxPackId ) ) ;
record_t < > * rec = iv - > getRecordStruct ( mPayload [ iv - > id ] . txCmd ) ; // choose the parser
record_t < > * rec = iv - > getRecordStruct ( mPayload [ iv - > id ] . txCmd ) ; // choose the parser
@ -296,6 +298,8 @@ class HmPayload {
memset ( payload , 0 , 150 ) ;
memset ( payload , 0 , 150 ) ;
int8_t rssi = - 127 ;
for ( uint8_t i = 0 ; i < ( mPayload [ iv - > id ] . maxPackId ) ; i + + ) {
for ( uint8_t i = 0 ; i < ( mPayload [ iv - > id ] . maxPackId ) ; i + + ) {
if ( ( mPayload [ iv - > id ] . len [ i ] + payloadLen ) > 150 ) {
if ( ( mPayload [ iv - > id ] . len [ i ] + payloadLen ) > 150 ) {
DPRINTLN ( DBG_ERROR , F ( " payload buffer to small! " ) ) ;
DPRINTLN ( DBG_ERROR , F ( " payload buffer to small! " ) ) ;
@ -303,12 +307,16 @@ class HmPayload {
}
}
memcpy ( & payload [ payloadLen ] , mPayload [ iv - > id ] . data [ i ] , ( mPayload [ iv - > id ] . len [ i ] ) ) ;
memcpy ( & payload [ payloadLen ] , mPayload [ iv - > id ] . data [ i ] , ( mPayload [ iv - > id ] . len [ i ] ) ) ;
payloadLen + = ( mPayload [ iv - > id ] . len [ i ] ) ;
payloadLen + = ( mPayload [ iv - > id ] . len [ i ] ) ;
// get worst RSSI
if ( mPayload [ iv - > id ] . rssi [ i ] > rssi )
rssi = mPayload [ iv - > id ] . rssi [ i ] ;
yield ( ) ;
yield ( ) ;
}
}
payloadLen - = 2 ;
payloadLen - = 2 ;
if ( mSerialDebug ) {
if ( mSerialDebug ) {
DPRINT ( DBG_INFO , F ( " Payload ( " ) ) ;
DPRINT_IVID ( DBG_INFO , iv - > id ) ;
DBGPRINT ( F ( " Payload ( " ) ) ;
DBGPRINT ( String ( payloadLen ) ) ;
DBGPRINT ( String ( payloadLen ) ) ;
DBGPRINT ( F ( " ): " ) ) ;
DBGPRINT ( F ( " ): " ) ) ;
ah : : dumpBuf ( payload , payloadLen ) ;
ah : : dumpBuf ( payload , payloadLen ) ;
@ -325,6 +333,7 @@ class HmPayload {
iv - > addValue ( i , payload , rec ) ;
iv - > addValue ( i , payload , rec ) ;
yield ( ) ;
yield ( ) ;
}
}
iv - > rssi = rssi ;
iv - > doCalculations ( ) ;
iv - > doCalculations ( ) ;
notify ( mPayload [ iv - > id ] . txCmd , iv ) ;
notify ( mPayload [ iv - > id ] . txCmd , iv ) ;
@ -388,8 +397,8 @@ class HmPayload {
}
}
void reset ( uint8_t id ) {
void reset ( uint8_t id ) {
DPRINT_IVID ( DBG_INFO , id ) ;
//DPRINT_IVID(DBG_INFO, id);
DBGPRINTLN ( F ( " resetPayload " ) ) ;
//DBGPRINTLN(F("resetPayload"));
memset ( mPayload [ id ] . len , 0 , MAX_PAYLOAD_ENTRIES ) ;
memset ( mPayload [ id ] . len , 0 , MAX_PAYLOAD_ENTRIES ) ;
mPayload [ id ] . txCmd = 0 ;
mPayload [ id ] . txCmd = 0 ;
mPayload [ id ] . gotFragment = false ;
mPayload [ id ] . gotFragment = false ;