summaryrefslogtreecommitdiffstats
path: root/door_lock/cmd.c
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2025-04-29 17:04:38 +0800
committerSadeep Madurange <sadeep@asciimx.com>2025-04-29 17:04:38 +0800
commita9ce750c420813b1e7dab5eb4e0340d107a34b20 (patch)
treeb0bab3f5247b3c3cf9cfb2e72dcc4da993c0772a /door_lock/cmd.c
parent775d4a84f36d4d5d0700e9c44dfa4114a0cc022c (diff)
downloadsmart-home-a9ce750c420813b1e7dab5eb4e0340d107a34b20.tar.gz
Delete the old door_lock directory.
Diffstat (limited to 'door_lock/cmd.c')
-rw-r--r--door_lock/cmd.c59
1 files changed, 0 insertions, 59 deletions
diff --git a/door_lock/cmd.c b/door_lock/cmd.c
deleted file mode 100644
index fb9ae9c..0000000
--- a/door_lock/cmd.c
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <string.h>
-
-#include "cmd.h"
-
-#define XORLEN 32
-
-#define KEY "dM>}jdb,6gsnC$J^K 8(I5vyPemPs%;K"
-#define LOCK_CMD "43iqr5$NB8SpN?Z/52{iVl>o|i!.'dsT"
-#define UNLOCK_CMD "R,I7l^E4j]KyLR9'*Q{Jd'zu.~!84}Ij"
-
-static char cmd[XORLEN];
-
-static inline void xor(const char *s, char *d, int n)
-{
- int i;
-
- for (i = 0; i < n && s[i]; i++)
- d[i] = s[i] ^ KEY[i];
-}
-
-int cmd_cmp(const char *s, enum command c)
-{
- int rc;
- char buf[XORLEN + 1];
-
- xor(s, buf, XORLEN);
- buf[XORLEN] = 0;
-
- switch (c) {
- case DOOR_LOCK:
- rc = strcmp(LOCK_CMD, buf) == 0;
- break;
- case DOOR_UNLOCK:
- rc = strcmp(UNLOCK_CMD, buf) == 0;
- break;
- default:
- rc = 0;
- break;
- }
-
- return rc;
-}
-
-char * cmd_hash(enum command c)
-{
- switch (c) {
- case DOOR_LOCK:
- xor(LOCK_CMD, cmd, XORLEN);
- break;
- case DOOR_UNLOCK:
- xor(UNLOCK_CMD, cmd, XORLEN);
- break;
- default:
- cmd[0] = 0;
- break;
- }
-
- return cmd;
-}