Skip to content

Commit

Permalink
Merge pull request #35 from technyon/main
Browse files Browse the repository at this point in the history
add lockactionToString() for opener
  • Loading branch information
Bascy authored Feb 23, 2023
2 parents 0ccb839 + 34e0405 commit 048469e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/NukiBle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1201,8 +1201,7 @@ uint32_t NukiBle::getLastHeartbeat() {
return lastHeartbeat;
}

const BLEAddress NukiBle::getBleAddress() const
{
const BLEAddress NukiBle::getBleAddress() const {
return bleAddress;
}

Expand Down
2 changes: 2 additions & 0 deletions src/NukiLock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Nuki::CmdResult NukiLock::requestBatteryReport(BatteryReport* retrievedBatteryRe
Nuki::CmdResult NukiLock::requestConfig(Config* retrievedConfig) {
Action action;

memset(&action, 0, sizeof(action));
action.cmdType = Nuki::CommandType::CommandWithChallenge;
action.command = Command::RequestConfig;

Expand All @@ -90,6 +91,7 @@ Nuki::CmdResult NukiLock::requestConfig(Config* retrievedConfig) {
Nuki::CmdResult NukiLock::requestAdvancedConfig(AdvancedConfig* retrievedAdvancedConfig) {
Action action;

memset(&action, 0, sizeof(action));
action.cmdType = Nuki::CommandType::CommandWithChallenge;
action.command = Command::RequestAdvancedConfig;

Expand Down
4 changes: 4 additions & 0 deletions src/NukiOpener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Nuki::CmdResult NukiOpener::requestOpenerState(OpenerState* state) {
Action action;
uint16_t payload = (uint16_t)Command::KeyturnerStates;

memset(&action, 0, sizeof(action));
action.cmdType = Nuki::CommandType::Command;
action.command = Command::RequestData;
memcpy(&action.payload[0], &payload, sizeof(payload));
Expand All @@ -62,6 +63,7 @@ Nuki::CmdResult NukiOpener::requestBatteryReport(BatteryReport* retrievedBattery
Action action;
uint16_t payload = (uint16_t)Command::BatteryReport;

memset(&action, 0, sizeof(action));
action.cmdType = Nuki::CommandType::Command;
action.command = Command::RequestData;
memcpy(&action.payload[0], &payload, sizeof(payload));
Expand All @@ -78,6 +80,7 @@ Nuki::CmdResult NukiOpener::requestBatteryReport(BatteryReport* retrievedBattery
Nuki::CmdResult NukiOpener::requestConfig(Config* retrievedConfig) {
Action action;

memset(&action, 0, sizeof(action));
action.cmdType = Nuki::CommandType::CommandWithChallenge;
action.command = Command::RequestConfig;

Expand All @@ -91,6 +94,7 @@ Nuki::CmdResult NukiOpener::requestConfig(Config* retrievedConfig) {
Nuki::CmdResult NukiOpener::requestAdvancedConfig(AdvancedConfig* retrievedAdvancedConfig) {
Action action;

memset(&action, 0, sizeof(action));
action.cmdType = Nuki::CommandType::CommandWithChallenge;
action.command = Command::RequestAdvancedConfig;

Expand Down
32 changes: 32 additions & 0 deletions src/NukiOpenerConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,38 @@ struct __attribute__((packed)) LogEntry {
uint8_t data[8];
};

inline void lockactionToString(const LockAction action, char* str) {
switch (action) {
case LockAction::ActivateRTO:
strcpy(str, "ActivateRTO");
break;
case LockAction::DeactivateRTO:
strcpy(str, "DeactivateRTO");
break;
case LockAction::ElectricStrikeActuation:
strcpy(str, "ElectricStrikeActuation");
break;
case LockAction::ActivateCM:
strcpy(str, "ActivateCM");
break;
case LockAction::DeactivateCM:
strcpy(str, "DeactivateCM");
break;
case LockAction::FobAction1:
strcpy(str, "FobAction1");
break;
case LockAction::FobAction2:
strcpy(str, "FobAction2");
break;
case LockAction::FobAction3:
strcpy(str, "FobAction3");
break;
default:
strcpy(str, "Unknown");
break;
}
}

inline void lockstateToString(const LockState state, char* str) {
switch (state) {
case LockState::Uncalibrated:
Expand Down

0 comments on commit 048469e

Please sign in to comment.