You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
2.3 KiB
C++
111 lines
2.3 KiB
C++
//
|
|
// ±êÖ¾ÎïͨÐÅ - ÓïÒô²¥±¨ - ZigBee
|
|
//
|
|
|
|
#include "VoiceReportCommand.h"
|
|
|
|
VoiceReportCommand::VoiceReportCommand()
|
|
{
|
|
SetDevice(CommandData::Devices::VoiceReport);
|
|
}
|
|
|
|
byte* VoiceReportCommand::CMD_ReportSpecVoice(VoiceCmd type)
|
|
{
|
|
SetCommand(0x10, (byte)type);
|
|
return GetCommandArray();
|
|
}
|
|
|
|
byte* VoiceReportCommand::CMD_ReportRandomVoice()
|
|
{
|
|
SetCommand(0x20, 0x01);
|
|
return GetCommandArray();
|
|
}
|
|
|
|
byte* VoiceReportCommand::CMD_SetRTCStartDate(uint16_t year, byte month, byte day)
|
|
{
|
|
byte two_bit_year = year - 2000;
|
|
SetCommand(0x30, two_bit_year, month, day);
|
|
return GetCommandArray();
|
|
}
|
|
|
|
byte* VoiceReportCommand::CMD_ReadRTCDate()
|
|
{
|
|
SetCommand(0x31, 0x01);
|
|
return GetCommandArray();
|
|
}
|
|
|
|
byte* VoiceReportCommand::CMD_SetRTCStartTime(byte hour, byte minute, byte second)
|
|
{
|
|
SetCommand(0x40, hour, minute, second);
|
|
return GetCommandArray();
|
|
}
|
|
|
|
byte* VoiceReportCommand::CMD_ReadRTCTime()
|
|
{
|
|
SetCommand(0x41, 0x01);
|
|
return GetCommandArray();
|
|
}
|
|
|
|
byte* VoiceReportCommand::CMD_SetWeatherAndTemperature(WeatherCmd weather, byte temp)
|
|
{
|
|
SetCommand(0x42, (byte)weather, temp);
|
|
return GetCommandArray();
|
|
}
|
|
|
|
byte* VoiceReportCommand::CMD_QueryWeatherAndTemperator()
|
|
{
|
|
SetCommand(0x43);
|
|
return GetCommandArray();
|
|
}
|
|
|
|
bool VoiceReportCommand::IsVoiceCommand(byte* cmd)
|
|
{
|
|
return ((cmd[1] == CommandData::Devices::VoiceReport) && (cmd[2] == RT_VoiceCommand));
|
|
}
|
|
|
|
bool VoiceReportCommand::IsVoiceAvailable(byte* cmd)
|
|
{
|
|
if (!IsVoiceCommand(cmd))
|
|
return false;
|
|
return (cmd[3] == 0x4F);
|
|
}
|
|
|
|
bool VoiceReportCommand::ReadRTCDate(byte* cmd, uint16_t& year, byte& month, byte& day)
|
|
{
|
|
if ((cmd[1] == CommandData::Devices::VoiceReport) && (cmd[2] == RT_DateCommand))
|
|
{
|
|
year = 2000 + cmd[3];
|
|
month = cmd[4];
|
|
day = cmd[5];
|
|
return true;
|
|
}
|
|
else
|
|
return false;
|
|
}
|
|
|
|
bool VoiceReportCommand::ReadRTCTime(byte* cmd, byte& hour, byte& minute, byte& second)
|
|
{
|
|
if ((cmd[1] == CommandData::Devices::VoiceReport) && (cmd[2] == RT_TimeCommand))
|
|
{
|
|
hour = cmd[3];
|
|
minute = cmd[4];
|
|
second = cmd[5];
|
|
return true;
|
|
}
|
|
else
|
|
return false;
|
|
}
|
|
|
|
bool VoiceReportCommand::ReadWeatherAndTemperature(byte* cmd, WeatherCmd& weather, byte& temp)
|
|
{
|
|
if ((cmd[1] == CommandData::Devices::VoiceReport) && (cmd[2] == RT_WeatherTempCommand))
|
|
{
|
|
weather = (WeatherCmd)cmd[3];
|
|
temp = cmd[4];
|
|
return true;
|
|
}
|
|
else
|
|
return false;
|
|
}
|
|
|