Skip to content

Commit

Permalink
添加dc1配网工具
Browse files Browse the repository at this point in the history
  • Loading branch information
morestart committed Sep 17, 2019
1 parent 380c92b commit eea4ac3
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

86 changes: 86 additions & 0 deletions .idea/markdown-navigator.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/tools.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added DC1/__init__.py
Empty file.
11 changes: 11 additions & 0 deletions DC1/dc1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import socket


ssid = input("请输入待连接的WiFi SSID(仅支持2.4G): ")
password = input("请输入待连接的WiFi密码: ")
send_data = "{\"header\":\"phi-plug-0001\",\"uuid\":\"00010\",\"action\":\"wifi=\",\"auth\":\"\",\"params\":{\"ssid\":\""+ssid+"\",\"password\":\""+password+"\"}}\n"
for i in range(5):
udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
udp_socket.sendto(send_data.encode("utf-8"), ("192.168.4.1", 7550))
udp_socket.close()
print("发送配网数据成功...")
18 changes: 18 additions & 0 deletions DC1/servee_udp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from socketserver import BaseRequestHandler, UDPServer
import time


class TimeHandler(BaseRequestHandler):
def handle(self):
print('Got connection from', self.client_address)
# Get message and client socket
msg, sock = self.request
resp = time.ctime()
sock.sendto(resp.encode('ascii'), self.client_address)
print(msg.decode("utf-8"))


if __name__ == '__main__':
serv = UDPServer(('', 7550), TimeHandler)
print("udp server is started...")
serv.serve_forever()

0 comments on commit eea4ac3

Please sign in to comment.