本文整理汇总了C++中sDecodeRXMessage函数的典型用法代码示例。如果您正苦于以下问题:C++ sDecodeRXMessage函数的具体用法?C++ sDecodeRXMessage怎么用?C++ sDecodeRXMessage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sDecodeRXMessage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
bool RFXComTCP::onInternalMessage(const unsigned char *pBuffer, const size_t Len)
{
if (!m_bEnableReceive)
return true; //receiving not enabled
size_t ii = 0;
while (ii < Len)
{
if (m_rxbufferpos == 0) //1st char of a packet received
{
if (pBuffer[ii] == 0) //ignore first char if 00
return true;
}
m_rxbuffer[m_rxbufferpos] = pBuffer[ii];
m_rxbufferpos++;
if (m_rxbufferpos >= sizeof(m_rxbuffer))
{
//something is out of sync here!!
//restart
_log.Log(LOG_ERROR, "input buffer out of sync, going to restart!....");
m_rxbufferpos = 0;
return false;
}
if (m_rxbufferpos > m_rxbuffer[0])
{
if (!m_bReceiverStarted)
{
if (m_rxbuffer[1] == pTypeInterfaceMessage)
{
const tRBUF *pResponse = (tRBUF *)&m_rxbuffer;
if (pResponse->IRESPONSE.subtype == cmdStartRec)
{
m_bReceiverStarted = strstr((char*)&pResponse->IRESPONSE.msg1, "Copyright RFXCOM") != NULL;
}
else
{
_log.Log(LOG_STATUS, "RFXCOM: Please upgrade your RFXTrx Firmware!...");
m_bReceiverStarted = true;
}
}
}
else
sDecodeRXMessage(this, (const unsigned char *)&m_rxbuffer);//decode message
m_rxbufferpos = 0; //set to zero to receive next message
}
ii++;
}
return true;
}
示例2: memset
void CDomoticzHardwareBase::SendUVSensor(const int NodeID, const int ChildID, const int BatteryLevel, const float UVI)
{
RBUF tsen;
memset(&tsen, 0, sizeof(RBUF));
tsen.UV.packetlength = sizeof(tsen.UV) - 1;
tsen.UV.packettype = pTypeUV;
tsen.UV.subtype = sTypeUV1;
tsen.UV.battery_level = BatteryLevel;
tsen.UV.rssi = 12;
tsen.UV.id1 = (unsigned char)NodeID;
tsen.UV.id2 = (unsigned char)ChildID;
tsen.UV.uv = (BYTE)round(UVI * 10);
sDecodeRXMessage(this, (const unsigned char *)&tsen.UV);
}
示例3: memset
void Meteostick::SendUVSensor(const unsigned char Idx, const float UV, const std::string &defaultname)
{
RBUF tsen;
memset(&tsen, 0, sizeof(RBUF));
tsen.UV.packetlength = sizeof(tsen.UV) - 1;
tsen.UV.packettype = pTypeUV;
tsen.UV.subtype = sTypeUV1;
tsen.UV.battery_level = 9;
tsen.UV.rssi = 12;
tsen.UV.id1 = 0;
tsen.UV.id2 = Idx;
tsen.UV.uv = (BYTE)round(UV * 10);
sDecodeRXMessage(this, (const unsigned char *)&tsen.UV, defaultname.c_str());
}
示例4: int
void CSterbox::UpdateSwitch(const unsigned char Idx, const int SubUnit, const bool bOn, const double Level, const std::string &defaultname)
{
double rlevel = (15.0 / 100)*Level;
int level = int(rlevel);
char szIdx[10];
sprintf(szIdx, "%X%02X%02X%02X", 0, 0, 0, Idx);
std::vector<std::vector<std::string> > result;
result = m_sql.safe_query("SELECT Name,nValue,sValue FROM DeviceStatus WHERE (HardwareID==%d) AND (DeviceID=='%q') AND (Unit==%d)", m_HwdID, szIdx, SubUnit);
if (!result.empty())
{
//check if we have a change, if not do not update it
int nvalue = atoi(result[0][1].c_str());
if ((!bOn) && (nvalue == 0))
return;
if ((bOn && (nvalue != 0)))
{
//Check Level
int slevel = atoi(result[0][2].c_str());
if (slevel == level)
return;
}
}
//Send as Lighting 2
tRBUF lcmd;
memset(&lcmd, 0, sizeof(RBUF));
lcmd.LIGHTING2.packetlength = sizeof(lcmd.LIGHTING2) - 1;
lcmd.LIGHTING2.packettype = pTypeLighting2;
lcmd.LIGHTING2.subtype = sTypeAC;
lcmd.LIGHTING2.id1 = 0;
lcmd.LIGHTING2.id2 = 0;
lcmd.LIGHTING2.id3 = 0;
lcmd.LIGHTING2.id4 = Idx;
lcmd.LIGHTING2.unitcode = SubUnit;
if (!bOn)
{
lcmd.LIGHTING2.cmnd = light2_sOff;
}
else
{
lcmd.LIGHTING2.cmnd = light2_sOn;
}
lcmd.LIGHTING2.level = level;
lcmd.LIGHTING2.filler = 0;
lcmd.LIGHTING2.rssi = 12;
sDecodeRXMessage(this, (const unsigned char *)&lcmd.LIGHTING2, defaultname.c_str(), 255);
}
示例5: sprintf
void CDomoticzHardwareBase::SendTempHumBaroSensorFloat(const int NodeID, const int BatteryLevel, const float temperature, const int humidity, const float pressure, int forecast, const std::string &defaultname)
{
char szIdx[10];
sprintf(szIdx, "%d", NodeID & 0xFFFF);
int Unit = NodeID & 0xFF;
std::vector<std::vector<std::string> > result;
bool bDeviceExits = true;
result = m_sql.safe_query("SELECT Name FROM DeviceStatus WHERE (HardwareID==%d) AND (DeviceID=='%q') AND (Unit == %d) AND (Type==%d) AND (Subtype==%d)",
m_HwdID, szIdx, Unit, int(pTypeTEMP_HUM_BARO), int(sTypeTHBFloat));
if (result.size() < 1)
{
bDeviceExits = false;
}
RBUF tsen;
memset(&tsen, 0, sizeof(RBUF));
tsen.TEMP_HUM_BARO.packetlength = sizeof(tsen.TEMP_HUM_BARO) - 1;
tsen.TEMP_HUM_BARO.packettype = pTypeTEMP_HUM_BARO;
tsen.TEMP_HUM_BARO.subtype = sTypeTHBFloat;
tsen.TEMP_HUM_BARO.battery_level = 9;
tsen.TEMP_HUM_BARO.rssi = 12;
tsen.TEMP_HUM_BARO.id1 = (NodeID & 0xFF00) >> 8;
tsen.TEMP_HUM_BARO.id2 = NodeID & 0xFF;
tsen.TEMP_HUM_BARO.tempsign = (temperature >= 0) ? 0 : 1;
int at10 = round(abs(temperature*10.0f));
tsen.TEMP_HUM_BARO.temperatureh = (BYTE)(at10 / 256);
at10 -= (tsen.TEMP_HUM_BARO.temperatureh * 256);
tsen.TEMP_HUM_BARO.temperaturel = (BYTE)(at10);
tsen.TEMP_HUM_BARO.humidity = (BYTE)humidity;
tsen.TEMP_HUM_BARO.humidity_status = Get_Humidity_Level(tsen.TEMP_HUM.humidity);
int ab10 = round(pressure*10.0f);
tsen.TEMP_HUM_BARO.baroh = (BYTE)(ab10 / 256);
ab10 -= (tsen.TEMP_HUM_BARO.baroh * 256);
tsen.TEMP_HUM_BARO.barol = (BYTE)(ab10);
tsen.TEMP_HUM_BARO.forecast = forecast;
sDecodeRXMessage(this, (const unsigned char *)&tsen.TEMP_HUM_BARO);
if (!bDeviceExits)
{
//Assign default name for device
m_sql.safe_query("UPDATE DeviceStatus SET Name='%q' WHERE (HardwareID==%d) AND (DeviceID=='%q') AND (Unit == %d) AND (Type==%d) AND (Subtype==%d)",
defaultname.c_str(), m_HwdID, szIdx, Unit, int(pTypeTEMP_HUM_BARO), int(sTypeTHBFloat));
}
}
示例6: int
void CDomoticzHardwareBase::SendRGBWSwitch(const int NodeID, const int ChildID, const int BatteryLevel, const double Level, const bool bIsRGBW, const std::string &defaultname)
{
int level = int(Level);
int subType = (bIsRGBW == true) ? sTypeLimitlessRGBW : sTypeLimitlessRGB;
//Send as LimitlessLight
_tLimitlessLights lcmd;
lcmd.id = NodeID;
lcmd.subtype = subType;
if (level == 0)
lcmd.command = Limitless_LedOff;
else
lcmd.command = Limitless_LedOn;
lcmd.dunit = ChildID;
lcmd.value = level;
sDecodeRXMessage(this, (const unsigned char *)&lcmd, defaultname.c_str(), BatteryLevel);
}
示例7: sDecodeRXMessage
void CGpio::UpdateSwitch(const int pin, const bool value)
{
value ? IOPinStatusPacket.LIGHTING1.cmnd = light1_sOn : IOPinStatusPacket.LIGHTING1.cmnd = light1_sOff;
IOPinStatusPacket.LIGHTING1.seqnbr++;
IOPinStatusPacket.LIGHTING1.unitcode = pin;
sDecodeRXMessage(this, (const unsigned char *)&IOPinStatusPacket, NULL, 255);
for(std::vector<CGpioPin>::iterator it = pins.begin(); it != pins.end(); ++it)
{
if (it->GetPin() == pin)
{
it->SetDBState(value);
break;
}
}
}
示例8: memset
void C1Wire::ReportVoltage(int unit,int voltage)
{
if (voltage == -1000.0)
return;
RBUF tsen;
memset(&tsen,0,sizeof(RBUF));
tsen.RFXSENSOR.packetlength=sizeof(tsen.RFXSENSOR)-1;
tsen.RFXSENSOR.packettype=pTypeRFXSensor;
tsen.RFXSENSOR.subtype=sTypeRFXSensorVolt;
tsen.RFXSENSOR.rssi=12;
tsen.RFXSENSOR.id=unit+1;
tsen.RFXSENSOR.msg1 = (BYTE)(voltage/256);
tsen.RFXSENSOR.msg2 = (BYTE)(voltage-(tsen.RFXSENSOR.msg1*256));
sDecodeRXMessage(this, (const unsigned char *)&tsen.RFXSENSOR, NULL, 255);
}
示例9: atoi
void CHarmonyHub::UpdateSwitch(unsigned char idx,const char * realID, const bool bOn, const std::string &defaultname)
{
std::stringstream hexId ;
hexId << std::setw(7) << std::setfill('0') << std::hex << std::uppercase << (int)( atoi(realID) );
//char szIdx[10];
//sprintf(szIdx, "%X%02X%02X%02X", 0, 0, 0, idx);
std::vector<std::vector<std::string> > result;
result = m_sql.safe_query("SELECT Name,nValue,sValue FROM DeviceStatus WHERE (HardwareID==%d) AND (DeviceID=='%q')", m_HwdID, hexId.str().c_str());
if (!result.empty())
{
//check if we have a change, if not do not update it
int nvalue = atoi(result[0][1].c_str());
if ((!bOn) && (nvalue == light2_sOff))
return;
if ((bOn && (nvalue != light2_sOff)))
return;
}
int i_Id = atoi( realID);
//Send as Lighting 2
tRBUF lcmd;
memset(&lcmd, 0, sizeof(RBUF));
lcmd.LIGHTING2.packetlength = sizeof(lcmd.LIGHTING2) - 1;
lcmd.LIGHTING2.packettype = pTypeLighting2;
lcmd.LIGHTING2.subtype = sTypeAC;
lcmd.LIGHTING2.id1 = (i_Id>> 24) & 0xFF;
lcmd.LIGHTING2.id2 = (i_Id>> 16) & 0xFF;
lcmd.LIGHTING2.id3 = (i_Id>> 8) & 0xFF;
lcmd.LIGHTING2.id4 = (i_Id) & 0xFF;
lcmd.LIGHTING2.unitcode = 1;
int level = 15;
if (!bOn)
{
level = 0;
lcmd.LIGHTING2.cmnd = light2_sOff;
}
else
{
level = 15;
lcmd.LIGHTING2.cmnd = light2_sOn;
}
lcmd.LIGHTING2.level = level;
lcmd.LIGHTING2.filler = 0;
lcmd.LIGHTING2.rssi = 12;
sDecodeRXMessage(this, (const unsigned char *)&lcmd.LIGHTING2, defaultname.c_str(), 255);
}
示例10: defined
void C1Wire::ReportLightState(const std::string& deviceId, const int unit, const bool state)
{
#if defined(_DEBUG)
_log.Log(LOG_STATUS, "device '%s' unit %d state is %s", deviceId.c_str(), unit, (state) ? "on" : "off");
#endif
// check - is state changed ?
char num[16];
sprintf(num, "%s/%d", deviceId.c_str(), unit);
const std::string id(num);
std::map<std::string, bool>::iterator it;
it = m_LastSwitchState.find(id);
if (it != m_LastSwitchState.end())
{
if (m_LastSwitchState[id] == state)
{
return;
}
}
#if defined(_DEBUG)
_log.Log(LOG_STATUS, "device '%s' unit %d changed state to %s", deviceId.c_str(), unit, (state) ? "on" : "off");
#endif
m_LastSwitchState[id] = state;
unsigned char deviceIdByteArray[DEVICE_ID_SIZE]={0};
DeviceIdToByteArray(deviceId,deviceIdByteArray);
RBUF tsen;
memset(&tsen,0,sizeof(RBUF));
tsen.LIGHTING2.packetlength=sizeof(tsen.LIGHTING2)-1;
tsen.LIGHTING2.packettype=pTypeLighting2;
tsen.LIGHTING2.subtype=sTypeAC;
tsen.LIGHTING2.seqnbr=0;
tsen.LIGHTING2.id1=(BYTE)deviceIdByteArray[0];
tsen.LIGHTING2.id2=(BYTE)deviceIdByteArray[1];
tsen.LIGHTING2.id3=(BYTE)deviceIdByteArray[2];
tsen.LIGHTING2.id4=(BYTE)deviceIdByteArray[3];
tsen.LIGHTING2.unitcode=unit;
tsen.LIGHTING2.cmnd=state?light2_sOn:light2_sOff;
tsen.LIGHTING2.level=0;
tsen.LIGHTING2.rssi=12;
sDecodeRXMessage(this, (const unsigned char *)&tsen.LIGHTING2, NULL, 255);
}
示例11: WHERE
void Meteostick::SendTempBaroSensor(const unsigned char Idx, const float Temp, const float Baro, const std::string &defaultname)
{
bool bDeviceExits = true;
std::vector<std::vector<std::string> > result;
result = m_sql.safe_query("SELECT Name FROM DeviceStatus WHERE (HardwareID==%d) AND (DeviceID==%d) AND (Type==%d) AND (Subtype==%d)", m_HwdID, int(Idx), int(pTypeTEMP_BARO), int(sTypeBMP085));
if (result.size() < 1)
{
bDeviceExits = false;
}
//Calculate Pressure
float altitude = 188.0f; //Should be custom defined for each user
float dTempGradient = 0.0065f;
float dTempAtSea = (Temp - (-273.15f)) + dTempGradient * altitude;
float dBasis = 1 - dTempGradient * altitude / dTempAtSea;
float dExponent = 0.03416f / dTempGradient;
float dPressure = Baro / pow(dBasis,dExponent);
_tTempBaro tsensor;
tsensor.id1 = Idx;
tsensor.temp = Temp;
tsensor.baro = dPressure;
tsensor.altitude = float(altitude);
//this is probably not good, need to take the rising/falling of the pressure into account?
//any help would be welcome!
tsensor.forecast = baroForecastNoInfo;
if (tsensor.baro < 1000)
tsensor.forecast = baroForecastRain;
else if (tsensor.baro < 1020)
tsensor.forecast = baroForecastCloudy;
else if (tsensor.baro < 1030)
tsensor.forecast = baroForecastPartlyCloudy;
else
tsensor.forecast = baroForecastSunny;
sDecodeRXMessage(this, (const unsigned char *)&tsensor);
if (!bDeviceExits)
{
//Assign default name for device
m_sql.safe_query("UPDATE DeviceStatus SET Name='%q' WHERE (HardwareID==%d) AND (DeviceID==%d) AND (Type==%d) AND (Subtype==%d)", defaultname.c_str(), m_HwdID, int(Idx), int(pTypeTEMP_BARO), int(sTypeBMP085));
}
}
示例12: sprintf
void CJabloDongle::SendSetPointSensor(int NodeID, const int BatteryLevel, const float Temp, const std::string &defaultname)
{
bool bDeviceExits=true;
std::stringstream szQuery;
NodeID &= 0xFFFF; //To be consistent with TEMP packet, which has only 2 bytes for ID.
//make device ID
unsigned char ID1 = (unsigned char)((NodeID & 0xFF000000) >> 24);
unsigned char ID2 = (unsigned char)((NodeID & 0xFF0000) >> 16);
unsigned char ID3 = (unsigned char)((NodeID & 0xFF00) >> 8);
unsigned char ID4 = (unsigned char)NodeID & 0xFF;
char szIdx[30];
sprintf(szIdx, "%X%02X%02X%02X", ID1, ID2, ID3, ID4);
std::vector<std::vector<std::string> > result;
szQuery << "SELECT Name FROM DeviceStatus WHERE (HardwareID==" << m_HwdID << ") AND (DeviceID=='" << szIdx << "')";
result=m_sql.query(szQuery.str());
if (result.size()<1)
{
bDeviceExits=false;
}
_tThermostat thermos;
thermos.subtype=sTypeThermSetpoint;
thermos.id1=ID1;
thermos.id2=ID2;
thermos.id3=ID3;
thermos.id4=ID4;
thermos.dunit=0;
thermos.battery_level = (unsigned char)BatteryLevel;
thermos.temp=Temp;
sDecodeRXMessage(this, (const unsigned char *)&thermos);
if (!bDeviceExits)
{
//Assign default name for device
szQuery.clear();
szQuery.str("");
szQuery << "UPDATE DeviceStatus SET Name='" << defaultname << "' WHERE (HardwareID==" << m_HwdID << ") AND (DeviceID=='" << szIdx << "')";
result=m_sql.query(szQuery.str());
}
}
示例13: sprintf
void CYouLess::GetMeterDetails()
{
std::string sResult;
char szURL[200];
if(m_Password.size() == 0)
{
sprintf(szURL,"http://%s:%d/a",m_szIPAddress.c_str(), m_usIPPort);
}
else
{
sprintf(szURL,"http://%s:%d/a&w=%s",m_szIPAddress.c_str(), m_usIPPort, m_Password.c_str());
}
if (!HTTPClient::GET(szURL,sResult))
{
_log.Log(LOG_ERROR,"YouLess: Error connecting to: %s", m_szIPAddress.c_str());
return;
}
std::vector<std::string> results;
StringSplit(sResult, "\n", results);
if (results.size()<2)
{
_log.Log(LOG_ERROR,"YouLess: Error connecting to: %s", m_szIPAddress.c_str());
return;
}
int fpos;
std::string pusage=stdstring_trim(results[0]);
fpos=pusage.find_first_of(" ");
if (fpos!=std::string::npos)
pusage=pusage.substr(0,fpos);
stdreplace(pusage,",","");
std::string pcurrent=stdstring_trim(results[1]);
fpos=pcurrent.find_first_of(" ");
if (fpos!=std::string::npos)
pcurrent=pcurrent.substr(0,fpos);
stdreplace(pcurrent,",","");
m_meter.powerusage=atol(pusage.c_str());
m_meter.usagecurrent=atol(pcurrent.c_str());
sDecodeRXMessage(this, (const unsigned char *)&m_meter);//decode message
}
示例14: sprintf
void CToonThermostat::UpdateSwitch(const unsigned char Idx, const bool bOn, const std::string &defaultname)
{
bool bDeviceExits = true;
char szIdx[10];
sprintf(szIdx, "%X%02X%02X%02X", 0, 0, 0, Idx);
std::vector<std::vector<std::string> > result;
result = m_sql.safe_query("SELECT Name,nValue,sValue FROM DeviceStatus WHERE (HardwareID==%d) AND (Type==%d) AND (SubType==%d) AND (DeviceID=='%q')",
m_HwdID, pTypeLighting2, sTypeAC, szIdx);
if (!result.empty())
{
//check if we have a change, if not do not update it
int nvalue = atoi(result[0][1].c_str());
if ((!bOn) && (nvalue == 0))
return;
if ((bOn && (nvalue != 0)))
return;
}
//Send as Lighting 2
tRBUF lcmd;
memset(&lcmd, 0, sizeof(RBUF));
lcmd.LIGHTING2.packetlength = sizeof(lcmd.LIGHTING2) - 1;
lcmd.LIGHTING2.packettype = pTypeLighting2;
lcmd.LIGHTING2.subtype = sTypeAC;
lcmd.LIGHTING2.id1 = 0;
lcmd.LIGHTING2.id2 = 0;
lcmd.LIGHTING2.id3 = 0;
lcmd.LIGHTING2.id4 = Idx;
lcmd.LIGHTING2.unitcode = 1;
int level = 15;
if (!bOn)
{
level = 0;
lcmd.LIGHTING2.cmnd = light2_sOff;
}
else
{
level = 15;
lcmd.LIGHTING2.cmnd = light2_sOn;
}
lcmd.LIGHTING2.level = level;
lcmd.LIGHTING2.filler = 0;
lcmd.LIGHTING2.rssi = 12;
sDecodeRXMessage(this, (const unsigned char *)&lcmd.LIGHTING2, defaultname.c_str(), 255);
}
示例15: memset
void CDomoticzHardwareBase::SendMeterSensor(const int NodeID, const int ChildID, const int BatteryLevel, const float metervalue, const std::string &defaultname)
{
unsigned long counter = (unsigned long)(metervalue*1000.0f);
RBUF tsen;
memset(&tsen, 0, sizeof(RBUF));
tsen.RFXMETER.packetlength = sizeof(tsen.RFXMETER) - 1;
tsen.RFXMETER.packettype = pTypeRFXMeter;
tsen.RFXMETER.subtype = sTypeRFXMeterCount;
tsen.RFXMETER.rssi = 12;
tsen.RFXMETER.id1 = (BYTE)NodeID;
tsen.RFXMETER.id2 = (BYTE)ChildID;
tsen.RFXMETER.count1 = (BYTE)((counter & 0xFF000000) >> 24);
tsen.RFXMETER.count2 = (BYTE)((counter & 0x00FF0000) >> 16);
tsen.RFXMETER.count3 = (BYTE)((counter & 0x0000FF00) >> 8);
tsen.RFXMETER.count4 = (BYTE)(counter & 0x000000FF);
sDecodeRXMessage(this, (const unsigned char *)&tsen.RFXMETER, defaultname.c_str(), BatteryLevel);
}