| | |
| | | |
| | | #pragma anon_unions |
| | | |
| | | typedef struct tagKwStatByte |
| | | { |
| | | uint8_t nSeq :2; |
| | | uint8_t Err1 :1; |
| | | uint8_t Err2 :1; |
| | | uint8_t bHasData :1; |
| | | uint8_t bHeader :1; |
| | | uint8_t bTail :1; |
| | | |
| | | |
| | | }stKwStatByte; |
| | | |
| | | typedef struct tagKwChnStat |
| | | { |
| | | uint32_t DeviceAddr; |
| | | uint8_t Stat; // 状态字节 |
| | | uint8_t nSeq; // 包序列号 |
| | | uint8_t Tx_Power; |
| | | uint8_t RSSI; |
| | | uint8_t SNR; |
| | |
| | | uint16_t CtnLstPkts; |
| | | uint16_t MaxCtnLstPkts; |
| | | |
| | | uchar * pTxBuffer; |
| | | uint16_t sizetosend; |
| | | uint16_t sentsize; |
| | | |
| | | uchar * pRxBuffer; // and buffer max size; |
| | | // uint16_t SizeToRecv; |
| | | uint16_t RecvedSize; |
| | | |
| | | |
| | | }stKwChnStat; |
| | | |
| | | |
| | | |
| | | |
| | | typedef struct tagWLStat |
| | |
| | | uint16_t ErrStat; //错误状态 |
| | | |
| | | uint32_t RF_Freq; //运行频率 |
| | | |
| | | uint16_t nTimeOnAir; |
| | | uint16_t DeviceAddr; |
| | | |
| | | uint8_t nSeq; |
| | | uint8_t NetWorkAddr; |
| | | |
| | | uchar Tx_Power; // dBm 5 - 22 dBm |
| | |
| | | uint32_t targetSentCount; //对方发送数量 |
| | | uint32_t targetRecvdCount; //对方接受数量 |
| | | |
| | | unsigned char ttTxBuf1[256]; |
| | | uint16_t sizetosend; |
| | | uint16_t sentsize; |
| | | uint16_t sizesending; |
| | | |
| | | unsigned char ttRxBuf1[256]; |
| | | uint16_t ttRxSize; |
| | | unsigned char ttRxRecved; |
| | | |
| | | unsigned char ttAirBuf[65]; |
| | | uint16_t ttAirSize; |
| | | unsigned char bttAirHeader; |
| | | unsigned char bttAirTail; |
| | | |
| | | unsigned char bttAirData; |
| | | |
| | | }stWLRunStat,*pstWLRunStat; |
| | | |
| | | enum enKwCMDs |
| | | { |
| | | |
| | | KwcmdNone = 0x00, //Nothing |
| | | |
| | | KwcmdQuery = 0x01, //Query basic Info |
| | | KwcmdQueryRply = 0x81, //Query Info Reply |
| | | |
| | | KwcmdSetCfg = 0x02, // Set Configuration |
| | | KwcmdSetCfgRply = 0x82, // Set Configuration Response |
| | | |
| | | KwcmdToRunMode = 0x03, |
| | | KwcmdToRunModeRply = 0x83, |
| | | |
| | | KwcmdBroadCastCfg = 0x04, // |
| | | |
| | | KwcmdMuExchgData = 0x05, // |
| | | KwcmdMuExchgDataRply = 0x85, // |
| | | |
| | | KwcmdToSafeMode = 0x06, |
| | | |
| | | KwcmdHeartBeat = 0x07, // |
| | | KwcmdReHeartBeat = 0x87, // |
| | | }; |
| | | |
| | | |
| | | enum { |
| | | enReqSign = 0x55, |
| | |
| | | |
| | | }; |
| | | |
| | | typedef struct tagKLPacket |
| | | typedef struct tagKwPktStatByte |
| | | { |
| | | uchar STSign; |
| | | uchar DstAddr; |
| | | uchar Func; |
| | | uchar Stat; |
| | | uchar Data[1]; |
| | | uchar nSeq :2 ; |
| | | uchar bErr1 :1 ; |
| | | uchar bErr2 :1 ; |
| | | uchar bHasData :1; |
| | | uchar bHead :1; |
| | | uchar bTail :1; |
| | | |
| | | }stKLPacket, *pstKLPacket; |
| | | |
| | | }stKwPktStatByte; |
| | | |
| | | typedef struct tagKwPacket |
| | | { |
| | | uchar STSign; // 包开始标记 |
| | | uchar DstAddr; // 子机组合地址, 包括 频道 和 子机地址 |
| | | uchar Func; // 功能码 |
| | | union{ |
| | | uchar Stat; // 状态字 |
| | | stKwPktStatByte; |
| | | }; |
| | | uchar Data[1]; // 数据 |
| | | |
| | | }stKwPacket, *pstKwPacket; |
| | | |
| | | int LoadKwConfig(void); |
| | | int SaveKwConfig(void); |
| | |
| | | |
| | | int KWLMasterSendReqPkt(int nChn); |
| | | int KWLSlaveSendRplyPkt(int nChn); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | int KWMasterProc(void); |