zoap

A WiP CoAP implementation for bare-metal constrained devices in Zig

git clone https://git.8pit.net/zoap.git

 1pub const Code = packed struct {
 2    detail: u5,
 3    class: u3,
 4
 5    pub fn equal(self: Code, other: Code) bool {
 6        return self.class == other.class and self.detail == other.detail;
 7    }
 8};
 9
10// See https://datatracker.ietf.org/doc/html/rfc7252#section-12.1
11
12// Requests
13pub const GET = Code{ .class = 0, .detail = 01 };
14pub const POST = Code{ .class = 0, .detail = 02 };
15pub const PUT = Code{ .class = 0, .detail = 03 };
16pub const DELETE = Code{ .class = 0, .detail = 04 };
17
18// Responses
19pub const CREATED = Code{ .class = 2, .detail = 01 };
20pub const DELETED = Code{ .class = 2, .detail = 02 };
21pub const VALID = Code{ .class = 2, .detail = 03 };
22pub const CHANGED = Code{ .class = 2, .detail = 04 };
23pub const CONTENT = Code{ .class = 2, .detail = 05 };
24//
25pub const BAD_REQ = Code{ .class = 4, .detail = 00 };
26pub const UNAUTH = Code{ .class = 4, .detail = 01 };
27pub const BAD_OPT = Code{ .class = 4, .detail = 02 };
28pub const FORBIDDEN = Code{ .class = 4, .detail = 03 };
29pub const NOT_FOUND = Code{ .class = 4, .detail = 04 };
30pub const BAD_METHOD = Code{ .class = 4, .detail = 05 };
31pub const NOT_ACCEPT = Code{ .class = 4, .detail = 06 };
32//
33pub const NOT_IMPL = Code{ .class = 5, .detail = 01 };
34pub const INTERNAL_ERR = Code{ .class = 5, .detail = 00 };