Skip to content

Commit

Permalink
0.9.6 & Fix mqtt invalid deviceId cause error
Browse files Browse the repository at this point in the history
  • Loading branch information
noahziheng committed Mar 31, 2018
1 parent 6b9a30a commit 361407a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions libfreeiot/adapters/mqtt/Parse/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@

def before_check(d_id):
""" Before Check Function """
if not ObjectId.is_valid(d_id):
print(d_id + " is invalid!")
return
else:
d_id = ObjectId(d_id)
result = mongo.db.devices.find_one({"_id": d_id})
if result is not None:
if "status" not in dict(result).keys():
Expand All @@ -21,14 +26,14 @@ def main(client, topic, payload):
""" Parse Engine Main Function """
print("Parsing ", topic, payload)
if topic[0]=='SYS':
if not before_check(ObjectId(payload["id"])):
if not before_check(payload["id"]):
return
if topic[1]=='online':
sys.online(client, payload)
elif topic[1]=='will':
sys.offline(client, payload)
else:
if not before_check(ObjectId(topic[0])):
if not before_check(topic[0]):
return
res = mongo.db.datas.insert_one({
"device": DBRef("devices", topic[0]),
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

setup(
name = "libfreeiot",
version = "0.9.5",
version = "0.9.6",
description = 'A free, open-source IoT Framework',
author = 'Noah Gao',
author_email = '[email protected]',
url = 'https://github.com/noahziheng/freeiot',
download_url = 'https://github.com/noahziheng/freeiot/archive/0.9.5.tar.gz',
download_url = 'https://github.com/noahziheng/freeiot/archive/0.9.6.tar.gz',
packages = find_packages(),
install_requires=[ # 依赖列表
'Flask>=0.12.2',
Expand Down

0 comments on commit 361407a

Please sign in to comment.