const uint8_t para_B[5][8] = {
{43,43,45,49,43,43,45,49},/UCM 601/
{43,43,45,49,43,43,45,49},/UCM 601C/
{43,43,45,49,43,43,45,49},/UCM 601B/
{53,53,48,43,49,45,43,43}, /UCM602/
{47,47,47,47,46,43,43,43} /UCM608/
};
const int para_C[5][8] = {
{43,43,45,49,43,43,45,49},/UCM 601/
{43,43,45,49,43,43,45,49},/UCM 601C/
{43,43,45,49,43,43,45,49},/UCM 601B/
{-283,-283,-283,-283,-283,-283,-283,-283}, /UCM602/
{-303,-283,-253,-238,-304,-313,-280,-266} /UCM608/
};
int general_func_file::Calculate_Rssi(char data,uint8_t len){
uint8_t rssi_mode = 0;
uint8_t hardware_mode = 0;
int B=0,C=0,D=0;
int RssiVal = 0;
uint8_t epc_len = 0;
float A = 1.0f;
float rssi_temp = 0.0f;
union{
uint32_t u32;
uint8_t chr[4];
}UNION;
epc_len = (len-3);
if(epc_len == 0){
epc_len = 1;
// //LOG(INFO) << “EPC len = 0 rssi error”;
}
rssi_mode = (data[0]&0xE0) >> 5;
hardware_mode = (data[0]&0x1E) >> 1;
UNION.chr[3] = data[0] & 0x01;
UNION.chr[2] = data[1];
UNION.chr[1] = data[2];
UNION.chr[0] = data[3];
B = para_B[hardware_mode][rssi_mode];
C = para_C[hardware_mode][rssi_mode];
rssi_temp = (UNION.u32/epc_len)*A;
RssiVal = (B * log10(rssi_temp)) + C + D;
if(RssiVal > 0 || RssiVal == 0){
// //LOG(INFO) << "rssi > 0 , original value is “<<int(UNION.u32)<<” mode is “<<int(rssi_mode)<<” hard mode is "<<int(hardware_mode);
RssiVal = -30;
}
else if(RssiVal < -90 || RssiVal == -90){
// //LOG(INFO) << "rssi > 0 , original value is “<<int(UNION.u32)<<” mode is “<<int(rssi_mode)<<” hard mode is "<<int(hardware_mode);
RssiVal = -90;
}
return RssiVal;
}