Fix authName
This commit is contained in:
@@ -20,6 +20,9 @@ NetworkLock::NetworkLock(Network* network, Preferences* preferences, char* buffe
|
||||
_configTopics.push_back(mqtt_topic_config_auto_unlock);
|
||||
_configTopics.push_back(mqtt_topic_config_auto_lock);
|
||||
_configTopics.push_back(mqtt_topic_config_single_lock);
|
||||
|
||||
memset(_authName, 0, sizeof(_authName));
|
||||
_authName[0] = '\0';
|
||||
|
||||
_network->registerMqttReceiver(this);
|
||||
}
|
||||
@@ -224,7 +227,7 @@ void NetworkLock::onMqttDataReceived(const char* topic, byte* payload, const uns
|
||||
|
||||
publishString(mqtt_topic_keypad_json_action, "--");
|
||||
}
|
||||
|
||||
|
||||
if(comparePrefixedPath(topic, mqtt_topic_timecontrol_action))
|
||||
{
|
||||
if(strcmp(value, "") == 0 || strcmp(value, "--") == 0) return;
|
||||
@@ -325,7 +328,7 @@ void NetworkLock::publishKeyTurnerState(const NukiLock::KeyTurnerState& keyTurne
|
||||
|
||||
json["auth_id"] = _authId;
|
||||
json["auth_name"] = _authName;
|
||||
|
||||
|
||||
serializeJson(json, _buffer, _bufferSize);
|
||||
publishString(mqtt_topic_lock_json, _buffer);
|
||||
|
||||
@@ -371,7 +374,8 @@ void NetworkLock::publishAuthorizationInfo(const std::list<NukiLock::LogEntry>&
|
||||
char str[50];
|
||||
|
||||
_authId = 0;
|
||||
_authName = "";
|
||||
memset(_authName, 0, sizeof(_authName));
|
||||
_authName[0] = '\0';
|
||||
_authFound = false;
|
||||
|
||||
JsonDocument json;
|
||||
@@ -388,14 +392,16 @@ void NetworkLock::publishAuthorizationInfo(const std::list<NukiLock::LogEntry>&
|
||||
{
|
||||
_authFound = true;
|
||||
_authId = log.authId;
|
||||
_authName = (char*)log.name;
|
||||
int sizeName = sizeof(log.name);
|
||||
memcpy(_authName, log.name, sizeName);
|
||||
if(_authName[sizeName - 1] != '\0') _authName[sizeName] = '\0';
|
||||
}
|
||||
|
||||
auto entry = json.add();
|
||||
|
||||
entry["index"] = log.index;
|
||||
entry["authorizationId"] = log.authId;
|
||||
entry["authorizationName"] = log.name;
|
||||
entry["authorizationName"] = _authName;
|
||||
entry["timeYear"] = log.timeStampYear;
|
||||
entry["timeMonth"] = log.timeStampMonth;
|
||||
entry["timeDay"] = log.timeStampDay;
|
||||
|
||||
@@ -86,7 +86,7 @@ private:
|
||||
int _keypadCommandEnabled = 1;
|
||||
uint8_t _queryCommands = 0;
|
||||
uint32_t _authId = 0;
|
||||
String _authName = "";
|
||||
char _authName[33];
|
||||
bool _authFound = false;
|
||||
|
||||
char* _buffer;
|
||||
|
||||
@@ -16,6 +16,9 @@ NetworkOpener::NetworkOpener(Network* network, Preferences* preferences, char* b
|
||||
_configTopics.push_back(mqtt_topic_config_button_enabled);
|
||||
_configTopics.push_back(mqtt_topic_config_led_enabled);
|
||||
_configTopics.push_back(mqtt_topic_config_sound_level);
|
||||
|
||||
memset(_authName, 0, sizeof(_authName));
|
||||
_authName[0] = '\0';
|
||||
|
||||
_network->registerMqttReceiver(this);
|
||||
}
|
||||
@@ -358,7 +361,8 @@ void NetworkOpener::publishAuthorizationInfo(const std::list<NukiOpener::LogEntr
|
||||
char str[50];
|
||||
|
||||
_authId = 0;
|
||||
_authName = "";
|
||||
memset(_authName, 0, sizeof(_authName));
|
||||
_authName[0] = '\0';
|
||||
_authFound = false;
|
||||
|
||||
JsonDocument json;
|
||||
@@ -376,14 +380,16 @@ void NetworkOpener::publishAuthorizationInfo(const std::list<NukiOpener::LogEntr
|
||||
{
|
||||
_authFound = true;
|
||||
_authId = log.authId;
|
||||
_authName = (char*)log.name;
|
||||
int sizeName = sizeof(log.name);
|
||||
memcpy(_authName, log.name, sizeName);
|
||||
if(_authName[sizeName - 1] != '\0') _authName[sizeName] = '\0';
|
||||
}
|
||||
|
||||
auto entry = json.add();
|
||||
|
||||
entry["index"] = log.index;
|
||||
entry["authorizationId"] = log.authId;
|
||||
entry["authorizationName"] = log.name;
|
||||
entry["authorizationName"] = _authName;
|
||||
entry["timeYear"] = log.timeStampYear;
|
||||
entry["timeMonth"] = log.timeStampMonth;
|
||||
entry["timeDay"] = log.timeStampDay;
|
||||
|
||||
@@ -87,7 +87,7 @@ private:
|
||||
unsigned long _resetRingStateTs = 0;
|
||||
uint8_t _queryCommands = 0;
|
||||
uint32_t _authId = 0;
|
||||
String _authName = "";
|
||||
char _authName[33];
|
||||
bool _authFound = false;
|
||||
|
||||
NukiOpener::LockState _currentLockState = NukiOpener::LockState::Undefined;
|
||||
|
||||
Reference in New Issue
Block a user