Move print helpers to Hotdog.ino
This commit is contained in:
@@ -166,18 +166,3 @@ void calculateCRC() { // must be called after the buffer has been filled
|
||||
buf[length + 2] = checksum1; // Checksum
|
||||
buf[length + 3] = checksum2; // Checksum
|
||||
}
|
||||
|
||||
void printHex(uint8_t num) { //print a byte as two hex chars
|
||||
char hexCar[3];
|
||||
sprintf(hexCar, "%02X", num);
|
||||
Serial.print(hexCar);
|
||||
}
|
||||
|
||||
void printBuffer() //print a byte array as hex chars
|
||||
{
|
||||
uint8_t bytecount = buf[0] + 3;
|
||||
for (int i = 0; i < bytecount; i++) {
|
||||
printHex(buf[i]);
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
26
Hotdog.ino
26
Hotdog.ino
@@ -54,17 +54,17 @@ void onConnectionEstablished() {
|
||||
uint16_t shadeID = 0x0400;
|
||||
if (payload == "OPEN") {
|
||||
constructUpPacket(shadeID);
|
||||
printByteArray(buf);
|
||||
printPacket(buf);
|
||||
Serial.println();
|
||||
sendCommand(buf);
|
||||
} else if (payload == "CLOSE") {
|
||||
constructDownPacket(shadeID);
|
||||
printByteArray(buf);
|
||||
printPacket(buf);
|
||||
Serial.println();
|
||||
sendCommand(buf);
|
||||
} else if (payload == "STOP") {
|
||||
constructStopPacket(shadeID);
|
||||
printByteArray(buf);
|
||||
printPacket(buf);
|
||||
Serial.println();
|
||||
sendCommand(buf);
|
||||
}
|
||||
@@ -121,4 +121,22 @@ void sendCommand(byte * byteArray) //transmit a command
|
||||
|
||||
rollingCode1++;
|
||||
rollingCode2++;
|
||||
}
|
||||
}
|
||||
|
||||
void printHex(const uint8_t num) { //print a byte as two hex chars
|
||||
if (num < 0x10) {
|
||||
Serial.print("0");
|
||||
}
|
||||
Serial.print(num, HEX);
|
||||
}
|
||||
|
||||
void printByteArray(const uint8_t * byteArray, const int arraySize) { //print a byte array as hex chars
|
||||
for (int i = 0; i < arraySize; i++) {
|
||||
printHex(byteArray[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void printPacket(const uint8_t *buffer) {
|
||||
uint8_t length = buffer[1] + 4;
|
||||
printByteArray(buffer, length);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user