Commit Graph

48 Commits

Author SHA1 Message Date
ccda78ed6d CoapPacket
- Cleared up code
2023-09-21 21:01:38 +02:00
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
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
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
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
e4ba2dd0da CoapPacket
- Space out debug prints in `fromBytes(ubyte[])`
2023-09-18 15:29:47 +02:00
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
d497494eeb Client (unit test)
- Neatened up
2023-09-18 15:09:58 +02:00
54c1fe0ba3
Update d.yml 2023-09-18 14:00:34 +02:00
a51cc61c86
Update d.yml 2023-09-18 13:56:21 +02:00
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
456d8918ee CoapClient
- Added client class
2023-09-14 17:01:03 +02:00
ce3f6240a6 CoapRequestBuilder
- Added a `get()` method
2023-09-14 16:55:50 +02:00
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
0fefd27666 CoapPacket
- Added `getToken()` method
2023-09-14 16:34:03 +02:00
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
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
aa343cae7f CoapPacket
- Added `getMessageId()`

Packet (unit tests)

- Added check for the message id
2023-09-14 09:31:55 +02:00
c78c6f3bab CoapPacket
- `fromBytes(ubyte[])` now decodes the token according to the tkl (token length) field
2023-09-14 09:26:55 +02:00
fe30ac29cb CoapPacket
- Added `toString()`
- `fromBytes(ubyte[])` now decodes the message ID
2023-09-14 09:25:33 +02:00
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
025758aa66 CoapPacket
- Removed debug prints
2023-09-13 21:19:53 +02:00
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
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
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
b24c840b9b CoapPackrt
- Added a stub `setOptions()`
- Implemented `setPayload(ubyte[])`
2023-09-12 19:43:25 +02:00
3f23b4b2c8 CoapPacket
- Added note about options encoding is missing
- Added payload marker encoding
- Added payload encoding
2023-09-12 19:42:27 +02:00
8c30637c1f CoapPacket
- `getBytes()` now encodes the token

Packet (unit tests)

- Check the encoding of the token
2023-09-12 19:23:20 +02:00
0e450556be Packet (unit tests)
- Ensure the message ID is encoded properly in big endian format
2023-09-12 18:47:50 +02:00
edf7de3839
Update README.md 2023-09-12 18:43:55 +02:00
774de746f1
Create d.yml 2023-09-12 18:42:57 +02:00
1cb57e781e - Added WIP for USAGE 2023-09-12 18:41:11 +02:00
d03e52da2a - Added README 2023-09-12 18:40:43 +02:00
589196d000 - Added LICENSE 2023-09-12 18:39:35 +02:00
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
8a11f3d405 Package
- Added missing imports
2023-09-12 17:55:37 +02:00
809ef394a0 Packet
- Added `setCode(Code)`

Packet (unit tests)

- Test the encoding of the request/response code
2023-09-12 11:52:13 +02:00
23994bb75b Packet (unit tests)
- Test encoding of the token length (tkl)
2023-09-12 11:12:07 +02:00
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
64e22741dd Packet (unit tests)
- Removed print statements
2023-09-12 10:48:32 +02:00
d3ffdd46db Packet
- Added `setType(MessageType)` which sets the messagr type
- The `type` field is no longer a `ubyte` but rather a `MessageType`

Packet (unit tests)

- Test the encoding of the type field

Types

- Added new module
- Added `MessageType` enum
2023-09-12 10:48:01 +02:00
8e8d1d2ba1 Packet (unit tests)
- Added a unit test which tests the encoding
- So far it just checks that the version is encoded correctly
2023-09-12 10:33:11 +02:00
3a3febc61e Packet
- `getByte()` now tacks on the calculated first byte
- `getBytes()` encodes the rquest/response code now as well
2023-09-11 22:26:29 +02:00
d6a9f7d329 Packet
- Defined `CoapPacket` to represent a CoAP packet
- Added the required fields
- Constructor sets the version to `1` (the only version available)
- `getBytes()` no encodes the first byte of the CoAP header (versio, type and token length)
2023-09-11 22:18:19 +02:00
ec4f57af5d Codes
- Added the codes for messages
- These are 8-bits
2023-09-11 21:39:31 +02:00
d9a6eb3280 - Fixed .gitignore 2023-09-11 21:37:05 +02:00
c3e29c41d0 Dub
- Added dub package descriptor
- Set `"targetType"` to `"library"`
2023-09-11 21:36:19 +02:00
718ef2833e - Added .gitignore 2023-09-11 21:35:18 +02:00