Murata RF modules are designed to simplify wireless development and certification by minimizing the amount of RF expertise you need to wirelessly enable a wide range of applications.
UARTFrame.cpp
00001 #include "UARTFrame.h" 00002 00003 using namespace SmartLabMuRata; 00004 00005 char UARTFrame::GetL0() 00006 { 00007 return l0; 00008 } 00009 00010 void UARTFrame::SetL0(const int value) 00011 { 00012 l0 = value & 0x7F; 00013 } 00014 00015 char UARTFrame::GetL1() 00016 { 00017 return l1; 00018 } 00019 00020 void UARTFrame::SetL1(const int value) 00021 { 00022 l1 = value & 0x3F; 00023 00024 if ((value & 0x40) == 0x40) 00025 needACK = true; 00026 else needACK = false; 00027 } 00028 00029 int UARTFrame::GetPayloadLength() 00030 { 00031 return (l1 << 7) | l0; 00032 } 00033 00034 void UARTFrame::SetPayloadLength(const int length) 00035 { 00036 SetL0(length); 00037 SetL1(length >> 7); 00038 } 00039 00040 // ack 00041 bool UARTFrame::GetACKRequired() 00042 { 00043 return needACK; 00044 } 00045 00046 void UARTFrame::SetACKRequired(const bool ack) 00047 { 00048 needACK = ack; 00049 } 00050 00051 //command id 00052 CommandID UARTFrame::GetCommandID() 00053 { 00054 return commandid; 00055 } 00056 00057 void UARTFrame::SetCommandID(const CommandID id) 00058 { 00059 SetCommandID ((int)id); 00060 } 00061 00062 void UARTFrame::SetCommandID(const int value) 00063 { 00064 commandid = (CommandID)(value & 0x7F); 00065 } 00066 00067 // payload 00068 void UARTFrame::SetPayload(Payload * payload) 00069 { 00070 this->payload = payload; 00071 SetPayloadLength(payload->GetPosition()); 00072 SetChecksum(l0 + (needACK ? l1 | 0x40 : l1) + commandid); 00073 } 00074 00075 Payload * UARTFrame::GetPayload() 00076 { 00077 return payload; 00078 } 00079 00080 // checksum 00081 char UARTFrame::GetChecksum() 00082 { 00083 return checksum; 00084 } 00085 00086 void UARTFrame::SetChecksum(const int checksum) 00087 { 00088 this->checksum = checksum & 0x7F; 00089 } 00090 00091 bool UARTFrame::VerifyChecksum() 00092 { 00093 if (((l0 + (needACK ? l1 | 0x40 : l1) + commandid) & 0x7F) == checksum) 00094 return true; 00095 return false; 00096 }
Generated on Fri Jul 15 2022 01:02:11 by 1.7.2