Skip to content

Commit

Permalink
🐛 Fix DeviceId incomplete MAC address (#296)
Browse files Browse the repository at this point in the history
snprintf works with n-1 characters

expected behaviour: DeviceId is 12 characters
behaviour: only 11 characters are returned

(resulting in a "incomplete" mac address)
  • Loading branch information
bertmelis authored and marvinroger committed Feb 18, 2017
1 parent b47195e commit 1d5f228
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Homie/Utils/DeviceId.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ char DeviceId::_deviceId[]; // need to define the static variable
void DeviceId::generate() {
uint8_t mac[6];
WiFi.macAddress(mac);
snprintf(DeviceId::_deviceId, MAX_MAC_STRING_LENGTH , "%02x%02x%02x%02x%02x%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
snprintf(DeviceId::_deviceId, MAX_MAC_STRING_LENGTH+1 , "%02x%02x%02x%02x%02x%02x", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
}

const char* DeviceId::get() {
Expand Down

0 comments on commit 1d5f228

Please sign in to comment.