Skip to content

Commit

Permalink
Merge branch 'v1.6.0' of github.com:sidoh/esp8266_milight_hub into st…
Browse files Browse the repository at this point in the history
…ate_persistence
  • Loading branch information
Chris Mullins committed Oct 5, 2017
2 parents 75e43e0 + ff9cefa commit 5831404
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 45 deletions.
35 changes: 35 additions & 0 deletions lib/MiLight/MiLightRemoteConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,38 @@ const MiLightRemoteConfig* MiLightRemoteConfig::fromReceivedPacket(

return NULL;
}

const MiLightRemoteConfig FUT096Config( //rgbw
new RgbwPacketFormatter(),
MiLightRadioConfig::ALL_CONFIGS[0],
REMOTE_TYPE_RGBW,
"rgbw"
);

const MiLightRemoteConfig FUT091Config( //cct
new CctPacketFormatter(),
MiLightRadioConfig::ALL_CONFIGS[1],
REMOTE_TYPE_CCT,
"cct"
);

const MiLightRemoteConfig FUT092Config( //rgb+cct
new RgbCctPacketFormatter(),
MiLightRadioConfig::ALL_CONFIGS[2],
REMOTE_TYPE_RGB_CCT,
"rgb_cct"
);

const MiLightRemoteConfig FUT089Config( //rgb+cct B8 / FUT089
new FUT089PacketFormatter(),
MiLightRadioConfig::ALL_CONFIGS[2],
REMOTE_TYPE_FUT089,
"fut089"
);

const MiLightRemoteConfig FUT098Config( //rgb
new RgbPacketFormatter(),
MiLightRadioConfig::ALL_CONFIGS[3],
REMOTE_TYPE_RGB,
"rgb"
);
39 changes: 5 additions & 34 deletions lib/MiLight/MiLightRemoteConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,10 @@ class MiLightRemoteConfig {
static const MiLightRemoteConfig* ALL_REMOTES[NUM_REMOTES];
};

static const MiLightRemoteConfig FUT096Config( //rgbw
new RgbwPacketFormatter(),
MiLightRadioConfig::ALL_CONFIGS[0],
REMOTE_TYPE_RGBW,
"rgbw"
);

static const MiLightRemoteConfig FUT091Config( //cct
new CctPacketFormatter(),
MiLightRadioConfig::ALL_CONFIGS[1],
REMOTE_TYPE_CCT,
"cct"
);

static const MiLightRemoteConfig FUT092Config( //rgb+cct
new RgbCctPacketFormatter(),
MiLightRadioConfig::ALL_CONFIGS[2],
REMOTE_TYPE_RGB_CCT,
"rgb_cct"
);

static const MiLightRemoteConfig FUT089Config( //rgb+cct B8 / FUT089
new FUT089PacketFormatter(),
MiLightRadioConfig::ALL_CONFIGS[2],
REMOTE_TYPE_FUT089,
"fut089"
);

static const MiLightRemoteConfig FUT098Config( //rgb
new RgbPacketFormatter(),
MiLightRadioConfig::ALL_CONFIGS[3],
REMOTE_TYPE_RGB,
"rgb"
);
extern const MiLightRemoteConfig FUT096Config; //rgbw
extern const MiLightRemoteConfig FUT091Config; //cct
extern const MiLightRemoteConfig FUT092Config; //rgb+cct
extern const MiLightRemoteConfig FUT089Config; //rgb+cct B8 / FUT089
extern const MiLightRemoteConfig FUT098Config; //rgb

#endif
5 changes: 2 additions & 3 deletions lib/MiLight/PacketFormatter.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <PacketFormatter.h>

uint8_t* PacketFormatter::PACKET_BUFFER = new uint8_t[PACKET_FORMATTER_BUFFER_SIZE];
static uint8_t* PACKET_BUFFER = new uint8_t[PACKET_FORMATTER_BUFFER_SIZE];

PacketStream::PacketStream()
: packetStream(NULL),
: packetStream(PACKET_BUFFER),
numPackets(0),
packetLength(0),
currentPacket(0)
Expand All @@ -26,7 +26,6 @@ PacketFormatter::PacketFormatter(const size_t packetLength, const size_t maxPack
held(false)
{
packetStream.packetLength = packetLength;
packetStream.packetStream = PACKET_BUFFER;
}

bool PacketFormatter::canHandle(const uint8_t *packet, const size_t len) {
Expand Down
2 changes: 0 additions & 2 deletions lib/MiLight/PacketFormatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ class PacketFormatter {
size_t getPacketLength() const;

protected:
static uint8_t* PACKET_BUFFER;

uint8_t* currentPacket;
size_t packetLength;
uint16_t deviceId;
Expand Down
12 changes: 6 additions & 6 deletions lib/Udp/V6MiLightUdpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ void V6MiLightUdpServer::handleCommand(
uint32_t cmdArg = readInt<uint32_t>(cmd+5);

#ifdef MILIGHT_UDP_DEBUG
printf_P("Command cmdType: %02X, cmdHeader: %08X, cmdArg: %08X\n", cmdType, cmdHeader, cmdArg);
printf("Command cmdType: %02X, cmdHeader: %08X, cmdArg: %08X\n", cmdType, cmdHeader, cmdArg);
#endif

bool handled = false;
Expand Down Expand Up @@ -232,19 +232,19 @@ void V6MiLightUdpServer::handleCommand(
}

#ifdef MILIGHT_UDP_DEBUG
printf_P("V6MiLightUdpServer - Unhandled command: ");
printf("V6MiLightUdpServer - Unhandled command: ");
for (size_t i = 0; i < V6_COMMAND_LEN; i++) {
printf_P("%02X ", cmd[i]);
printf("%02X ", cmd[i]);
}
printf_P("\n");
printf("\n");
#endif
}

void V6MiLightUdpServer::handleHeartbeat(uint16_t sessionId) {
char header[] = { 0xD8, 0x00, 0x00, 0x00, 0x07 };
memcpy(responseBuffer, header, size(header));
writeMacAddr(responseBuffer + 5);

responseBuffer[11] = 0;

sendResponse(sessionId, responseBuffer, 12);
Expand Down Expand Up @@ -274,7 +274,7 @@ void V6MiLightUdpServer::handlePacket(uint8_t* packet, size_t packetSize) {
uint8_t checksum = packet[21];

#ifdef MILIGHT_UDP_DEBUG
printf_P("session: %04X, sequence: %d, group: %d, checksum: %d\n", sessionId, sequenceNum, group, checksum);
printf("session: %04X, sequence: %d, group: %d, checksum: %d\n", sessionId, sequenceNum, group, checksum);
#endif

handleCommand(sessionId, sequenceNum, cmd, group, checksum);
Expand Down

0 comments on commit 5831404

Please sign in to comment.