diff --git a/.codio b/.codio new file mode 100644 index 0000000..da0c4bf --- /dev/null +++ b/.codio @@ -0,0 +1,22 @@ +{ + // This file is used to configure the three buttons along Codio's top menu. + // Run button configuration + "commands": { + "Run": "python3 {{filepath}}" + }, + // Preview button configuration + "preview": { + "Project Index (static)": "https://{{domain}}/{{index}}", + "Current File (static)": "https://{{domain}}/{{filepath}}", + "Box URL": "http://{{domain3000}}/", + "Box URL SSL": "https://{{domain3000}}/" + }, + // Debugger target button configuration + "debugger": [{ + "type": "PYTHON3", + "command": "{{filepath}}", + "before": "", + "uuid": "6c228c3f-596c-c44a-399f-5d86a7e17bf9", + "name": "Debug" + }] +} \ No newline at end of file diff --git a/.settings b/.settings new file mode 100644 index 0000000..bbc7660 --- /dev/null +++ b/.settings @@ -0,0 +1,64 @@ +[editor] +tab_size = 2 +; enter your editor preferences here... + +[ide] +; enter your ide preferences here... + +[code-beautifier] +; enter your code-beautifier preferences here... + +[codio-filetree] +; enter your codio-filetree preferences here... + +[codio-lsp] +; enter your codio-lsp preferences here... + +[junit] +; enter your junit preferences here... + +[git] +; enter your git preferences here... + +[terminal] +; enter your terminal preferences here... + +[preview] +; enter your preview preferences here... + +[emmet] +; enter your emmet preferences here... + +[search] +; enter your search preferences here... + +[guides] +; enter your guides preferences here... + +[settings] +; enter your settings preferences here... + +[account] +; enter your account preferences here... + +[project] +; enter your project preferences here... + +[install-software] +; enter your install-software preferences here... + +[education] +; enter your education preferences here... + +[deployment] +; enter your deployment preferences here... + +[container] +; enter your container preferences here... + +[sync-structure] +; enter your sync-structure preferences here... + +[Codio Lexikon] +; enter your Codio Lexikon preferences here... + diff --git a/4005CMD_Introduction_to_MQTT.pdf b/4005CMD_Introduction_to_MQTT.pdf new file mode 100644 index 0000000..ca52e25 Binary files /dev/null and b/4005CMD_Introduction_to_MQTT.pdf differ diff --git a/4005CMD_W1-Setting-Up-Codio.pdf b/4005CMD_W1-Setting-Up-Codio.pdf new file mode 100644 index 0000000..79263e5 Binary files /dev/null and b/4005CMD_W1-Setting-Up-Codio.pdf differ diff --git a/owntracks-subscribe_for_ever_loop b/owntracks-subscribe_for_ever_loop new file mode 100644 index 0000000..064319a --- /dev/null +++ b/owntracks-subscribe_for_ever_loop @@ -0,0 +1,62 @@ +import paho.mqtt.client as mqtt #necessary imports +import json, os +from datetime import date, datetime +import time + +print("Hello, Visual Studio") + +""" callback function for connection """ +def on_connect(client, userdata, flags, rc): #client method to connect + if rc==0: + client.connected_flag = True #set flag + print("connected OK Returned code=",rc) #let us know we connected to the broker + client.subscribe("owntracks/KS/#") #we are connected, so subscribe to the topic. wildcard means any device + print("rc") + else: + print("Bad connection Returned code=",rc) #if we can't connect + + +""" callback function for messages received """ +def on_message( client, userdata, msg ): #client method to get messages from topic + topic = msg.topic #for use when we can't decode + try: + data = json.loads(msg.payload.decode("utf8")) #decode message + day = date.today() #time functions + clock = datetime.now() + time = datetime.time(clock) + print ("TID = {0} is currently at {1}, {2},{3},{4}".format(data['tid'], data['lat'], data['lon'], str(day), str(time))) + #print device, latitude and longitude from the message; add time data + print(str(data)) #print the entire message just for fun + except: + print ("Cannot decode data on topic {0}".format(topic)) #cannot decode; print the topic for the non-decodable message + +client = mqtt.Client() +client.on_connect = on_connect +client.on_message = on_message + +client.username_pw_set("KS", "mqttBROKER") #associate authentication details with the client + +#client.tls_set("mqtt.coventry.ac.uk.crt") #certificate for client. needs to be in the same directory as this script +client.connect("broker.hivemq.com", 1883) #connect to the broker on an appropriate port + +client.loop_forever() #keep looping forever (allows realtime subscription) +print("Here we are") + +#def on_connect(client, userdata, flags, rc): + # print("Connected with result code "+str(rc)) + # Subscribing in on_connect() means that if we lose the connection and + # reconnect then subscriptions will be renewed. + # client.subscribe("$SYS/#") + # The callback for when a PUBLISH message is received from the server. +#def on_message(client, userdata, msg): + # print(msg.topic+" "+str(msg.payload)) + # client = mqtt.Client() +#client.on_connect = on_connect +#mqttBroker ="mqtt.eclipseprojects.io" + +#client = mqtt.Client("Temperature_Inside") +#client.connect(mqttBroker) +#client.on_connect = on_connect +#client.on_message = on_message +print("message") +