Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
- Update README.md
- tweak fix
  • Loading branch information
takkaO committed Dec 20, 2019
1 parent 6ba6696 commit 8e78f2a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
1 change: 0 additions & 1 deletion GUI/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"author": "",
"license": "ISC",
"devDependencies": {
"config": "^3.2.4",
"electron": "^7.1.5",
"electron-packager": "^14.1.1",
"electron-rebuild": "^1.8.8"
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ payload: {"mac": "AA-BB-CC-DD-EE-FF"}
payload: {"mac": "77 88 99 AA BB CC"}
```

### Nickname Resolution Service
You can send nickname instead of MAC address if you were register pair of nicknames and MAC addresses beforehand.
Open ```nrs.ini``` file in server side.
If you want to add pair of nickname ```mypc``` and MAC address ```aa:aa:aa:aa:aa:aa``` , add pair as described below.
```
[NicknameResolutionService]
nick_name = xx:xx:xx:xx:xx:xx
mypc = aa:aa:aa:aa:aa:aa
```

After register pair of nickname and MAC address, you can use not only MAC address but also nickname as a trigger of WOL.
```
payload: {"mac": "mypc"}
```

## Reference
- [Raspberry PiからPythonでWEB経由でWoLしてみる](https://code-life.hatenablog.com/entry/raspberry-pi-wol)
Expand Down
8 changes: 4 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ def __init__(self):
self.wol = WakeOnLan()
self.wol.select_network_interface()
self.topic = "takkaO/wol"
self.mnlookup_file = "./mns.ini"
self.mnlookup_file = "./nrs.ini"

if not os.path.isfile(self.mnlookup_file):
config = configparser.ConfigParser()
config["mns"] = {"nick_name" : "xx:xx:xx:xx:xx:xx"}
config["NicknameResolutionService"] = {"nick_name" : "xx:xx:xx:xx:xx:xx"}
with open(self.mnlookup_file, 'w') as configfile:
config.write(configfile)

Expand All @@ -30,7 +30,7 @@ def on_message(self, client, userdata, msg):
if not self.wol.is_mac_address(mac):
config = configparser.ConfigParser()
config.read(self.mnlookup_file)
mac = config["mns"][mac]
mac = config["NicknameResolutionService"][mac]
#print("Load mac from config")

if self.wol.is_mac_address(mac):
Expand All @@ -52,4 +52,4 @@ def main():
time.sleep(5)

if __name__ == "__main__":
main()
main()

0 comments on commit 8e78f2a

Please sign in to comment.