diff --git a/plido-tp4/aiocoap/__pycache__/__init__.cpython-314.pyc b/plido-tp4/aiocoap/__pycache__/__init__.cpython-314.pyc new file mode 100644 index 0000000..3e6ec80 Binary files /dev/null and b/plido-tp4/aiocoap/__pycache__/__init__.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/__pycache__/credentials.cpython-314.pyc b/plido-tp4/aiocoap/__pycache__/credentials.cpython-314.pyc new file mode 100644 index 0000000..3389e91 Binary files /dev/null and b/plido-tp4/aiocoap/__pycache__/credentials.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/__pycache__/defaults.cpython-314.pyc b/plido-tp4/aiocoap/__pycache__/defaults.cpython-314.pyc new file mode 100644 index 0000000..cfca989 Binary files /dev/null and b/plido-tp4/aiocoap/__pycache__/defaults.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/__pycache__/error.cpython-314.pyc b/plido-tp4/aiocoap/__pycache__/error.cpython-314.pyc new file mode 100644 index 0000000..4e2125a Binary files /dev/null and b/plido-tp4/aiocoap/__pycache__/error.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/__pycache__/interfaces.cpython-314.pyc b/plido-tp4/aiocoap/__pycache__/interfaces.cpython-314.pyc new file mode 100644 index 0000000..5bbcb10 Binary files /dev/null and b/plido-tp4/aiocoap/__pycache__/interfaces.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/__pycache__/message.cpython-314.pyc b/plido-tp4/aiocoap/__pycache__/message.cpython-314.pyc new file mode 100644 index 0000000..179d672 Binary files /dev/null and b/plido-tp4/aiocoap/__pycache__/message.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/__pycache__/messagemanager.cpython-314.pyc b/plido-tp4/aiocoap/__pycache__/messagemanager.cpython-314.pyc new file mode 100644 index 0000000..21ae256 Binary files /dev/null and b/plido-tp4/aiocoap/__pycache__/messagemanager.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/__pycache__/meta.cpython-314.pyc b/plido-tp4/aiocoap/__pycache__/meta.cpython-314.pyc new file mode 100644 index 0000000..2182ca2 Binary files /dev/null and b/plido-tp4/aiocoap/__pycache__/meta.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/__pycache__/options.cpython-314.pyc b/plido-tp4/aiocoap/__pycache__/options.cpython-314.pyc new file mode 100644 index 0000000..d5582c4 Binary files /dev/null and b/plido-tp4/aiocoap/__pycache__/options.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/__pycache__/optiontypes.cpython-314.pyc b/plido-tp4/aiocoap/__pycache__/optiontypes.cpython-314.pyc new file mode 100644 index 0000000..5fe44ed Binary files /dev/null and b/plido-tp4/aiocoap/__pycache__/optiontypes.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/__pycache__/protocol.cpython-314.pyc b/plido-tp4/aiocoap/__pycache__/protocol.cpython-314.pyc new file mode 100644 index 0000000..0531aba Binary files /dev/null and b/plido-tp4/aiocoap/__pycache__/protocol.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/__pycache__/resource.cpython-314.pyc b/plido-tp4/aiocoap/__pycache__/resource.cpython-314.pyc new file mode 100644 index 0000000..c3fcc3c Binary files /dev/null and b/plido-tp4/aiocoap/__pycache__/resource.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/__pycache__/tokenmanager.cpython-314.pyc b/plido-tp4/aiocoap/__pycache__/tokenmanager.cpython-314.pyc new file mode 100644 index 0000000..3b03263 Binary files /dev/null and b/plido-tp4/aiocoap/__pycache__/tokenmanager.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/numbers/__pycache__/__init__.cpython-314.pyc b/plido-tp4/aiocoap/numbers/__pycache__/__init__.cpython-314.pyc new file mode 100644 index 0000000..8f8ffd4 Binary files /dev/null and b/plido-tp4/aiocoap/numbers/__pycache__/__init__.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/numbers/__pycache__/codes.cpython-314.pyc b/plido-tp4/aiocoap/numbers/__pycache__/codes.cpython-314.pyc new file mode 100644 index 0000000..d349a20 Binary files /dev/null and b/plido-tp4/aiocoap/numbers/__pycache__/codes.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/numbers/__pycache__/constants.cpython-314.pyc b/plido-tp4/aiocoap/numbers/__pycache__/constants.cpython-314.pyc new file mode 100644 index 0000000..efca46d Binary files /dev/null and b/plido-tp4/aiocoap/numbers/__pycache__/constants.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/numbers/__pycache__/optionnumbers.cpython-314.pyc b/plido-tp4/aiocoap/numbers/__pycache__/optionnumbers.cpython-314.pyc new file mode 100644 index 0000000..e1b4ae3 Binary files /dev/null and b/plido-tp4/aiocoap/numbers/__pycache__/optionnumbers.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/numbers/__pycache__/types.cpython-314.pyc b/plido-tp4/aiocoap/numbers/__pycache__/types.cpython-314.pyc new file mode 100644 index 0000000..7ff9401 Binary files /dev/null and b/plido-tp4/aiocoap/numbers/__pycache__/types.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/transports/__pycache__/__init__.cpython-314.pyc b/plido-tp4/aiocoap/transports/__pycache__/__init__.cpython-314.pyc new file mode 100644 index 0000000..f395f7e Binary files /dev/null and b/plido-tp4/aiocoap/transports/__pycache__/__init__.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/transports/__pycache__/generic_udp.cpython-314.pyc b/plido-tp4/aiocoap/transports/__pycache__/generic_udp.cpython-314.pyc new file mode 100644 index 0000000..dc1385f Binary files /dev/null and b/plido-tp4/aiocoap/transports/__pycache__/generic_udp.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/transports/__pycache__/simple6.cpython-314.pyc b/plido-tp4/aiocoap/transports/__pycache__/simple6.cpython-314.pyc new file mode 100644 index 0000000..877d27c Binary files /dev/null and b/plido-tp4/aiocoap/transports/__pycache__/simple6.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/transports/__pycache__/simplesocketserver.cpython-314.pyc b/plido-tp4/aiocoap/transports/__pycache__/simplesocketserver.cpython-314.pyc new file mode 100644 index 0000000..2c3d352 Binary files /dev/null and b/plido-tp4/aiocoap/transports/__pycache__/simplesocketserver.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/transports/__pycache__/tcp.cpython-314.pyc b/plido-tp4/aiocoap/transports/__pycache__/tcp.cpython-314.pyc new file mode 100644 index 0000000..0f6e560 Binary files /dev/null and b/plido-tp4/aiocoap/transports/__pycache__/tcp.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/transports/__pycache__/tls.cpython-314.pyc b/plido-tp4/aiocoap/transports/__pycache__/tls.cpython-314.pyc new file mode 100644 index 0000000..7f6e7c6 Binary files /dev/null and b/plido-tp4/aiocoap/transports/__pycache__/tls.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/util/__pycache__/__init__.cpython-314.pyc b/plido-tp4/aiocoap/util/__pycache__/__init__.cpython-314.pyc new file mode 100644 index 0000000..bd29299 Binary files /dev/null and b/plido-tp4/aiocoap/util/__pycache__/__init__.cpython-314.pyc differ diff --git a/plido-tp4/aiocoap/util/__pycache__/uri.cpython-314.pyc b/plido-tp4/aiocoap/util/__pycache__/uri.cpython-314.pyc new file mode 100644 index 0000000..84476ff Binary files /dev/null and b/plido-tp4/aiocoap/util/__pycache__/uri.cpython-314.pyc differ diff --git a/plido-tp4/coap_basic_server1.py b/plido-tp4/coap_basic_server1.py index 14eaa7a..69bca39 100755 --- a/plido-tp4/coap_basic_server1.py +++ b/plido-tp4/coap_basic_server1.py @@ -24,7 +24,7 @@ class TimeResource(resource.Resource): async def render_get(self, request): - await asyncio.sleep(5) + # await asyncio.sleep(5) payload = datetime.datetime.now().\ strftime("%Y-%m-%d %H:%M").encode('ascii') @@ -35,7 +35,7 @@ async def render_get(self, request): logging.basicConfig(level=logging.INFO) logging.getLogger("coap-server").setLevel(logging.DEBUG) -def main(): +async def main(): # Resource tree creation with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s: s.connect(("8.8.8.8", 80)) # connect outside to get local IP address @@ -48,11 +48,13 @@ def main(): root.add_resource(['time'], TimeResource()) - asyncio.Task( - aiocoap.Context.create_server_context(root, - bind=(ip_addr, port))) - asyncio.get_event_loop().run_forever() + await aiocoap.Context.create_server_context(root,bind=(ip_addr, port)) + + await asyncio.Future() # run forever if __name__ == "__main__": - main() + try: + asyncio.run(main()) + except KeyboardInterrupt: + print("\nServer stopped by user") #graceful exit on Ctrl+C \ No newline at end of file diff --git a/pycom/__pycache__/CoAP.cpython-314.pyc b/pycom/__pycache__/CoAP.cpython-314.pyc new file mode 100644 index 0000000..22fd94e Binary files /dev/null and b/pycom/__pycache__/CoAP.cpython-314.pyc differ diff --git a/pycom/coap_empty_msg.py b/pycom/coap_empty_msg.py index bb9a6ad..661587e 100644 --- a/pycom/coap_empty_msg.py +++ b/pycom/coap_empty_msg.py @@ -1,7 +1,7 @@ import CoAP import socket -SERVER = "192.168.1.XX" # change to your server's IP address +SERVER = "192.168.11.109" # change to your server's IP address PORT = 5683 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) diff --git a/pycom/coap_get_time1.py b/pycom/coap_get_time1.py index a519463..24a851b 100755 --- a/pycom/coap_get_time1.py +++ b/pycom/coap_get_time1.py @@ -1,7 +1,7 @@ import CoAP import socket -SERVER = "192.168.1.XX" # change to your server's IP address +SERVER = "192.168.11.109" # change to your server's IP address PORT = 5683 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) diff --git a/pycom/coap_get_time2.py b/pycom/coap_get_time2.py index cc2878b..57a8911 100755 --- a/pycom/coap_get_time2.py +++ b/pycom/coap_get_time2.py @@ -1,7 +1,7 @@ import CoAP import socket -SERVER = "192.168.1.XX" # change to your server's IP address +SERVER = "192.168.11.109" # change to your server's IP address PORT = 5683 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) diff --git a/pycom/coap_get_time3.py b/pycom/coap_get_time3.py index 4fe8905..597d2e1 100755 --- a/pycom/coap_get_time3.py +++ b/pycom/coap_get_time3.py @@ -1,7 +1,7 @@ import CoAP import socket -SERVER = "192.168.1.XX" # change to your server's IP address +SERVER = "192.168.11.109" # change to your server's IP address PORT = 5683 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) diff --git a/pycom/coap_get_time4.py b/pycom/coap_get_time4.py index 8837eb9..1ba2454 100755 --- a/pycom/coap_get_time4.py +++ b/pycom/coap_get_time4.py @@ -1,7 +1,7 @@ import CoAP import socket -SERVER = "192.168.1.XX" # change to your server's IP address +SERVER = "192.168.11.109" # change to your server's IP address PORT = 5683 s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) @@ -18,13 +18,4 @@ answer = CoAP.Message(resp) answer.dump() -s.settimeout(10) -resp,addr = s.recvfrom(2000) -answer = CoAP.Message(resp) -answer.dump() -mid = answer.get_mid() -ack = CoAP.Message() -ack.new_header(mid=mid, type=CoAP.ACK) -ack.dump() -s.sendto (ack.to_byte(), (SERVER, PORT)) diff --git a/pycom/coap_get_time_nonConf.py b/pycom/coap_get_time_nonConf.py new file mode 100644 index 0000000..262c5b8 --- /dev/null +++ b/pycom/coap_get_time_nonConf.py @@ -0,0 +1,21 @@ +import CoAP +import socket + +SERVER = "192.168.11.109" # change to your server's IP address +PORT = 5683 + +s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + +coap = CoAP.Message() +coap.new_header(code=CoAP.GET,type=CoAP.NON , token=0x12345) +coap.add_option (CoAP.Uri_path, "time") +coap.dump() + +s.sendto (coap.to_byte(), (SERVER, PORT)) + +s.settimeout(10) +resp,addr = s.recvfrom(2000) +answer = CoAP.Message(resp) +answer.dump() + +