Commit Graph

208 Commits

Author SHA1 Message Date
Tristan B. Velloza Kildaire a28166dcb1 CoapMessagingLayer
- Added future `select()`-based code
2023-09-22 16:54:28 +02:00
Tristan B. Velloza Kildaire b069a03ab4 CoapClient
- Added TODO to move the `Socket` into the messaging layer
2023-09-22 16:49:55 +02:00
Tristan B. Velloza Kildaire cb3b5a35b5 CoapMessagingLayer
- Added information about the `select()`-based + I/O timed `receive()` I want to implement
2023-09-22 16:44:52 +02:00
Tristan B. Velloza Kildaire e98eb83bad CoapClient
- Added new `onNoNewMessages()`
- Removed `watch()`
2023-09-22 16:40:12 +02:00
Tristan B. Velloza Kildaire f25066900a CoapMessaging
- When a matched packet is found in `handlePacket(CoapPacket)` then print the elapsed time since the original request (thus far)
2023-09-22 16:27:11 +02:00
Tristan B. Velloza Kildaire 07c1cb90cc CapRequest
- Added `getElapsedTime()`
2023-09-22 16:26:41 +02:00
Tristan B. Velloza Kildaire ed97a2a3b4 CoapRequest
- Removed `getAndReset()`, replaced it with `hasTimedOut(Duration)`

CoapClient

- The `watch()` now uses `CoapRequest`'s new `hasTimedOut(Duration)` method
2023-09-22 16:22:27 +02:00
Tristan B. Velloza Kildaire 31b5d13943 CoapClient
- Added a `Condition` variable for the `requestsLock` mutex
- Added `transmitRequest(CoapRequest request)` which will take in the `CoapRequest`, yank the `CoapPacket` from it, encode it, send it over the underlying transport and then start the request's timer
- Added some code for a future "watcher" routine

CoapRequest

- Added a `StopWatch` timer which does not auto start
- Added `startTime()` which starts the timer
- Added `getAndReset()` which gets the elapsed time and resets it
2023-09-22 16:19:24 +02:00
Tristan B. Velloza Kildaire 2716fd3986 CoapRequest
- Now takes in the original request packet, `CoapPacket` instead of the token
- Added `getToken()` to fetch the token (for matching purposes)
- Added `getRequestPacket()` to obtain the original request

CoapClient

- Use `getToken()`
- Pass the `CoapPacket` in rather
2023-09-22 15:40:11 +02:00
Tristan B. Velloza Kildaire 497dabf6bf Utils
- Made new module with all the utility functions and types in it

CoapPacket

- Use the new `utils` module
2023-09-21 21:04:11 +02:00
Tristan B. Velloza Kildaire ccda78ed6d CoapPacket
- Cleared up code
2023-09-21 21:01:38 +02:00
Tristan B. Velloza Kildaire 6dfd908184 CoapPacket
- If we are in the 16-bit extended option delta mode and we come across a non 4bit length, then assert falsely
2023-09-21 17:23:53 +02:00
Tristan B. Velloza Kildaire 71c0781ff6 CoapPacket
- For option delta type 14. Once we compute the delta, add missing 269 and the current delta; that's our option id
- BUT it is als the NEW delta
2023-09-21 17:21:51 +02:00
Tristan B. Velloza Kildaire 74f287ad9d CoapPacket
- On the beginning of each loop print out the `data` buffer from the `idx` till the end of the array
- When handling an extended option delta (16bits) we now extract it, add missing 269, add the current delta.
- THEN we jump over that 16bit entity, now we check the option length type based on previously available information
- So far we support ZERO_TO_TWELVE
- WIP: What to do with the new delta? Do we increment it? If so, how?!?
2023-09-21 17:20:00 +02:00
Tristan B. Velloza Kildaire f85b33a5b1 CoapPacket
- Fixed bug in `fromBytes(ubyte[])` whereby we would parse the delta 0-12 option value correctly in the 0-12 length case but would never jump over it idx-wise
- This effectively left us on the starting byte of the option value for the next round, instead of starting on the next `(option delta | option length)`
2023-09-21 16:25:26 +02:00
Tristan B. Velloza Kildaire e4ba2dd0da CoapPacket
- Space out debug prints in `fromBytes(ubyte[])`
2023-09-18 15:29:47 +02:00
Tristan B. Velloza Kildaire 2c65c61c0a Packet
- Added `flip!(T)(T  integral)` for byteswapping
- Added `order!(T)(T integral, Order)` for byte swapping dependent on current system configuration
- Added `CoapOption` for storing options
- `CoapPacket`'s `options` field is now an array of `CoapOption` structs
- `fromBytes(ubyte[])` now prints the partially decoded packet befor message ID and options processing
- Added initial options support
- Options are still not decoding all correctly
- Added `OptionLenType`
- Added `getOptionLenType(ubyte)` which determins the length type based on the 4 bits in the header (lower)
- The `toString()` method now includes the `CoapOptions[]` in its output

Packet (unit tests)

- Added example CoAP packet to play with
2023-09-18 15:18:25 +02:00
Tristan B. Velloza Kildaire d497494eeb Client (unit test)
- Neatened up
2023-09-18 15:09:58 +02:00
Tristan B. Velloza Kildaire 54c1fe0ba3
Update d.yml 2023-09-18 14:00:34 +02:00
Tristan B. Velloza Kildaire a51cc61c86
Update d.yml 2023-09-18 13:56:21 +02:00
Tristan B. Velloza Kildaire 1e50540e75 CoapClient
- Added new constructor `this(string host, ushort port)`
-This constructor provided name resolution on the host part.

Client (unit tests)

- Updated unit test to use the new `CoapClient` name-resolution-based constructor
2023-09-14 17:05:44 +02:00
Tristan B. Velloza Kildaire 456d8918ee CoapClient
- Added client class
2023-09-14 17:01:03 +02:00
Tristan B. Velloza Kildaire ce3f6240a6 CoapRequestBuilder
- Added a `get()` method
2023-09-14 16:55:50 +02:00
Tristan B. Velloza Kildaire 02aa1988be CoapMessagingLayer
- Added new class
- This is stateful management of responses for  previously made requests.
- Handles the actual sending and receiving of datagrams and issueing of callbacks etc.
2023-09-14 16:55:31 +02:00
Tristan B. Velloza Kildaire 0fefd27666 CoapPacket
- Added `getToken()` method
2023-09-14 16:34:03 +02:00
Tristan B. Velloza Kildaire ae8462ef9a CoapRequestBuilder
- Added new class
- This allows one to build up a new CoAP request of some form in a method-call-by-method-call manner.
- In order to instantiate one of these please do so via the `CoapClient`.
2023-09-14 16:32:06 +02:00
Tristan B. Velloza Kildaire a9d809bea5 CoapRequest
- Added new class
- This represents a request that has been made. This is normally stored inside the `CoapClient` and used to find matching responses that come through in the messaging layer.
- It is composed of the `token` and the future which was created. Therefore when the messaging layer receives a new CoAP packet it can then try match it to one of these requests, in the event it finds a match it can retrieve the future, place the received `CoapPacket` into it and then wake up anyone doing a blocking `get()` on it.
2023-09-14 16:31:14 +02:00
Tristan B. Velloza Kildaire aa343cae7f CoapPacket
- Added `getMessageId()`

Packet (unit tests)

- Added check for the message id
2023-09-14 09:31:55 +02:00
Tristan B. Velloza Kildaire c78c6f3bab CoapPacket
- `fromBytes(ubyte[])` now decodes the token according to the tkl (token length) field
2023-09-14 09:26:55 +02:00
Tristan B. Velloza Kildaire fe30ac29cb CoapPacket
- Added `toString()`
- `fromBytes(ubyte[])` now decodes the message ID
2023-09-14 09:25:33 +02:00
Tristan B. Velloza Kildaire 36254da902 CoapPacket
- `fromBytes(ubyte[])` now extracts the request/response code
- `fromBytes(ubyte[])` also throws an exception on message size underflow
- Added `getCode()`

Packet (unit tests)

- Added request/response code tests
- Padded message (for now) to make tests pass
2023-09-13 21:34:02 +02:00
Tristan B. Velloza Kildaire 025758aa66 CoapPacket
- Removed debug prints
2023-09-13 21:19:53 +02:00
Tristan B. Velloza Kildaire 69a0fa12c5 CoapPacket
- Added `getType()`
- Added `getTokenLength()`
- Added `getVersion()`
- Added `fromBytes(ubyte[])` which decodes the provided bytes and produces a `CoapPacket` at the end
Packet (unit tests)

- Added initial decode tests
2023-09-13 21:19:24 +02:00
Tristan B. Velloza Kildaire 09ac0f0f20 Packet
- Defined `PAYLOAD_MARKER` as a global

Package structure

- Placed all packet-encoding related code into a `doap.protocol` sub-package
2023-09-13 21:03:31 +02:00
Tristan B. Velloza Kildaire 5a203ba69a Packet (unit tests)
- Added note to set the options (when supported)
- Set the payload
- Added note to check for encoded options (and offset everything beneath it respectively)
- Check for payload marker
- Check payload
2023-09-12 19:55:08 +02:00
Tristan B. Velloza Kildaire b24c840b9b CoapPackrt
- Added a stub `setOptions()`
- Implemented `setPayload(ubyte[])`
2023-09-12 19:43:25 +02:00
Tristan B. Velloza Kildaire 3f23b4b2c8 CoapPacket
- Added note about options encoding is missing
- Added payload marker encoding
- Added payload encoding
2023-09-12 19:42:27 +02:00
Tristan B. Velloza Kildaire 8c30637c1f CoapPacket
- `getBytes()` now encodes the token

Packet (unit tests)

- Check the encoding of the token
2023-09-12 19:23:20 +02:00
Tristan B. Velloza Kildaire 0e450556be Packet (unit tests)
- Ensure the message ID is encoded properly in big endian format
2023-09-12 18:47:50 +02:00
Tristan B. Velloza Kildaire edf7de3839
Update README.md 2023-09-12 18:43:55 +02:00
Tristan B. Velloza Kildaire 774de746f1
Create d.yml 2023-09-12 18:42:57 +02:00
Tristan B. Velloza Kildaire 1cb57e781e - Added WIP for USAGE 2023-09-12 18:41:11 +02:00
Tristan B. Velloza Kildaire d03e52da2a - Added README 2023-09-12 18:40:43 +02:00
Tristan B. Velloza Kildaire 589196d000 - Added LICENSE 2023-09-12 18:39:35 +02:00
Tristan B. Velloza Kildaire 4e99ab50d8 CoapPacket
- Now encodes the message ID in a platform independent manner. We will encode it into big endian seeing as it feels like it could be used in a number like fashion
- Added `setMessageId(ushort)` to set the message id
2023-09-12 18:37:57 +02:00
Tristan B. Velloza Kildaire 8a11f3d405 Package
- Added missing imports
2023-09-12 17:55:37 +02:00
Tristan B. Velloza Kildaire 809ef394a0 Packet
- Added `setCode(Code)`

Packet (unit tests)

- Test the encoding of the request/response code
2023-09-12 11:52:13 +02:00
Tristan B. Velloza Kildaire 23994bb75b Packet (unit tests)
- Test encoding of the token length (tkl)
2023-09-12 11:12:07 +02:00
Tristan B. Velloza Kildaire f7f928023d Packet
- Added `setTokenLength(ulong)` which returns `false` if the token length is above 15, else sets the token length (<=15) and returns `true`
- Added `setToken(ubyte[])` which sets the token (and length) and checks that the length is fine

Exceptions

- Added new exception time `CoapException`
2023-09-12 11:09:14 +02:00
Tristan B. Velloza Kildaire 64e22741dd Packet (unit tests)
- Removed print statements
2023-09-12 10:48:32 +02:00