Commit Graph

182 Commits

Author SHA1 Message Date
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