Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: LoRaBaseStation LoRaTerminal
ControPacket/ControlPacket.cpp
- Committer:
- rba90
- Date:
- 2016-06-29
- Revision:
- 0:f32c0e562e9a
- Child:
- 2:f4f46b04ab8a
File content as of revision 0:f32c0e562e9a:
#include "ControlPacket.h"
ControlPacket::ControlPacket()
: BasicPacket()
{
}
ControlPacket::ControlPacket(uint8_t *data)
: BasicPacket(data)
{
}
ControlPacket::~ControlPacket()
{
}
void ControlPacket::setSequenceID(uint8_t seqid)
{
setField1(seqid);
}
void ControlPacket::setSourceID(uint8_t sid)
{
uint8_t pattern = getField2();
// clear upper 4 bits
pattern &= 0x0f;
// set bits
pattern |= sid << 4;
// write back to bit field
setField2(pattern);
}
void ControlPacket::setDestinationID(uint8_t did)
{
uint8_t pattern = getField2();
// clear lower 4 bits
pattern &= 0xf0;
// set bits
pattern |= did & 0x0f;
// write back to bit field
setField2(pattern);
}
void ControlPacket::setCommand(uint8_t cmd)
{
uint8_t pattern = getField3();
// clear upper 4 bits
pattern &= 0x0f;
// set bits
pattern |= cmd << 4;
// write back to bit field
setField3(pattern);
}
uint8_t ControlPacket::getSequenceID()
{
return getField1();
}
uint8_t ControlPacket::getSourceID()
{
return (getField2() & 0xf0) >> 4;
}
uint8_t ControlPacket::getDestinationID()
{
return getField2() & 0x0f;
}
uint8_t ControlPacket::getCommand()
{
return (getField3() & 0xf0) >> 4;
}