Skip to content

Commit

Permalink
renamed to gea instead of gea3
Browse files Browse the repository at this point in the history
  • Loading branch information
KaitlynAnn99 committed Nov 25, 2024
1 parent f1dea7e commit 687bb17
Show file tree
Hide file tree
Showing 12 changed files with 340 additions and 340 deletions.
6 changes: 3 additions & 3 deletions include/i_tiny_gea_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@

#include <stdbool.h>
#include "i_tiny_event.h"
#include "tiny_gea3_packet.h"
#include "tiny_gea_packet.h"

typedef struct {
const tiny_gea3_packet_t* packet;
const tiny_gea_packet_t* packet;
} tiny_gea3_interface_on_receive_args_t;

typedef void (*tiny_gea3_interface_send_callback_t)(void* context, tiny_gea3_packet_t* packet);
typedef void (*tiny_gea3_interface_send_callback_t)(void* context, tiny_gea_packet_t* packet);

struct i_tiny_gea_interface_api_t;

Expand Down
20 changes: 0 additions & 20 deletions include/tiny_gea3_constants.h

This file was deleted.

20 changes: 20 additions & 0 deletions include/tiny_gea_constants.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*!
* @file
* @brief
*/

#ifndef tiny_gea_constants_h
#define tiny_gea_constants_h

enum {
tiny_gea_esc = 0xE0,
tiny_gea_ack = 0xE1,
tiny_gea_stx = 0xE2,
tiny_gea_etx = 0xE3,

tiny_gea_broadcast_address = 0xFF,

tiny_gea_crc_seed = 0x1021
};

#endif
24 changes: 12 additions & 12 deletions include/tiny_gea3_packet.h → include/tiny_gea_packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @brief GEA3 packet definition.
*/

#ifndef tiny_gea3_packet_h
#define tiny_gea3_packet_h
#ifndef tiny_gea_packet_h
#define tiny_gea_packet_h

#include <stddef.h>
#include <stdint.h>
Expand All @@ -14,21 +14,21 @@ typedef struct {
uint8_t payload_length;
uint8_t source;
uint8_t payload[1];
} tiny_gea3_packet_t;
} tiny_gea_packet_t;

enum {
// STX, ETX, CRC (MSB + LSB), source, destination, length
tiny_gea3_packet_transmission_overhead = 7,
tiny_gea3_packet_overhead = offsetof(tiny_gea3_packet_t, payload),
tiny_gea3_packet_max_payload_length = 255 - tiny_gea3_packet_transmission_overhead,
tiny_gea_packet_transmission_overhead = 7,
tiny_gea_packet_overhead = offsetof(tiny_gea_packet_t, payload),
tiny_gea_packet_max_payload_length = 255 - tiny_gea_packet_transmission_overhead,
};

/*!
* Macro for allocating a GEA3 packet with a given payload size on the stack. Payload size is set automatically.
*/
#define tiny_gea3_STACK_ALLOC_PACKET(_name, _payloadLength) \
uint8_t _name##Storage[_payloadLength + tiny_gea3_packet_overhead] = { 0, _payloadLength }; \
tiny_gea3_packet_t* const _name = (tiny_gea3_packet_t*)_name##Storage
#define tiny_gea3_STACK_ALLOC_PACKET(_name, _payloadLength) \
uint8_t _name##Storage[_payloadLength + tiny_gea_packet_overhead] = { 0, _payloadLength }; \
tiny_gea_packet_t* const _name = (tiny_gea_packet_t*)_name##Storage

/*!
* Macro for allocating a GEA3 packet with with a provided payload type. This sets the payload length
Expand All @@ -45,8 +45,8 @@ enum {
/*!
* Macro for statically allocating a GEA3 packet with a given payload size. Payload size is set automatically.
*/
#define tiny_gea3_STATIC_ALLOC_PACKET(_name, _payloadLength) \
static uint8_t _name##Storage[_payloadLength + tiny_gea3_packet_overhead] = { 0, _payloadLength }; \
static tiny_gea3_packet_t* const _name = (tiny_gea3_packet_t*)_name##Storage
#define tiny_gea3_STATIC_ALLOC_PACKET(_name, _payloadLength) \
static uint8_t _name##Storage[_payloadLength + tiny_gea_packet_overhead] = { 0, _payloadLength }; \
static tiny_gea_packet_t* const _name = (tiny_gea_packet_t*)_name##Storage

#endif
44 changes: 22 additions & 22 deletions src/tiny_erd_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <stddef.h>
#include <string.h>
#include "tiny_erd_client.h"
#include "tiny_gea3_constants.h"
#include "tiny_gea3_erd_api.h"
#include "tiny_gea_constants.h"
#include "tiny_stack_allocator.h"
#include "tiny_utils.h"

Expand Down Expand Up @@ -55,12 +55,12 @@ typedef struct {
read_request_t* request;
} read_request_worker_context_t;

static bool valid_read_request(const tiny_gea3_packet_t* packet)
static bool valid_read_request(const tiny_gea_packet_t* packet)
{
return packet->payload_length == sizeof(tiny_gea3_erd_api_read_request_payload_t);
}

static bool valid_read_response(const tiny_gea3_packet_t* packet)
static bool valid_read_response(const tiny_gea_packet_t* packet)
{
reinterpret(payload, packet->payload, const tiny_gea3_erd_api_read_response_payload_t*);

Expand All @@ -71,17 +71,17 @@ static bool valid_read_response(const tiny_gea3_packet_t* packet)
return (packet->payload_length >= sizeof(tiny_gea3_erd_api_read_response_payload_header_t)) && (packet->payload_length == (sizeof(tiny_gea3_erd_api_read_response_payload_header_t) + payload->header.data_size));
}

static bool valid_write_request(const tiny_gea3_packet_t* packet)
static bool valid_write_request(const tiny_gea_packet_t* packet)
{
return (packet->payload_length >= 5) && (packet->payload_length == (5 + packet->payload[4]));
}

static bool valid_write_response(const tiny_gea3_packet_t* packet)
static bool valid_write_response(const tiny_gea_packet_t* packet)
{
return packet->payload_length == sizeof(tiny_gea3_erd_api_write_response_payload_t);
}

static bool valid_subscribe_all_request(const tiny_gea3_packet_t* packet)
static bool valid_subscribe_all_request(const tiny_gea_packet_t* packet)
{
reinterpret(payload, packet->payload, const tiny_gea3_erd_api_subscribe_all_request_payload_t*);

Expand All @@ -101,7 +101,7 @@ static bool valid_subscribe_all_request(const tiny_gea3_packet_t* packet)
return true;
}

static bool valid_subscribe_all_response(const tiny_gea3_packet_t* packet)
static bool valid_subscribe_all_response(const tiny_gea_packet_t* packet)
{
reinterpret(payload, packet->payload, const tiny_gea3_erd_api_subscribe_all_response_payload_t*);

Expand All @@ -121,7 +121,7 @@ static bool valid_subscribe_all_response(const tiny_gea3_packet_t* packet)
return true;
}

static bool valid_subscription_publication(const tiny_gea3_packet_t* packet)
static bool valid_subscription_publication(const tiny_gea_packet_t* packet)
{
if(packet->payload_length < 4) {
return false;
Expand Down Expand Up @@ -149,17 +149,17 @@ static bool valid_subscription_publication(const tiny_gea3_packet_t* packet)
return actual_count == claimed_count;
}

static bool valid_subscription_publication_acknowledgment(const tiny_gea3_packet_t* packet)
static bool valid_subscription_publication_acknowledgment(const tiny_gea_packet_t* packet)
{
return packet->payload_length == sizeof(tiny_gea3_erd_api_publication_acknowledgement_payload_t);
}

static bool valid_subscription_host_startup(const tiny_gea3_packet_t* packet)
static bool valid_subscription_host_startup(const tiny_gea_packet_t* packet)
{
return packet->payload_length == 1;
}

static bool packet_is_valid(const tiny_gea3_packet_t* packet)
static bool packet_is_valid(const tiny_gea_packet_t* packet)
{
if(packet->payload_length < 1) {
return false;
Expand Down Expand Up @@ -197,7 +197,7 @@ static bool packet_is_valid(const tiny_gea3_packet_t* packet)
return false;
}

static void send_read_request_worker(void* _context, tiny_gea3_packet_t* packet)
static void send_read_request_worker(void* _context, tiny_gea_packet_t* packet)
{
read_request_worker_context_t* context = _context;
self_t* self = context->self;
Expand Down Expand Up @@ -227,7 +227,7 @@ static void send_read_request(self_t* self)
&context);
}

static void send_write_request_worker(void* _context, tiny_gea3_packet_t* packet)
static void send_write_request_worker(void* _context, tiny_gea_packet_t* packet)
{
reinterpret(self, _context, self_t*);

Expand Down Expand Up @@ -263,7 +263,7 @@ typedef struct {
subscribe_request_t* request;
} subscribe_request_worker_context_t;

static void send_subscribe_request_worker(void* _context, tiny_gea3_packet_t* packet)
static void send_subscribe_request_worker(void* _context, tiny_gea_packet_t* packet)
{
subscribe_request_worker_context_t* context = _context;
self_t* self = context->self;
Expand Down Expand Up @@ -468,7 +468,7 @@ static void resend_request(self_t* self)
}
}

static void handle_read_response_packet(self_t* self, const tiny_gea3_packet_t* packet)
static void handle_read_response_packet(self_t* self, const tiny_gea_packet_t* packet)
{
if(request_type(self) == request_type_read) {
read_request_t request;
Expand All @@ -480,7 +480,7 @@ static void handle_read_response_packet(self_t* self, const tiny_gea3_packet_t*
tiny_gea3_erd_api_read_result_t result = payload->header.result;

if((self->request_id == request_id) &&
((request.address == packet->source) || (request.address == tiny_gea3_broadcast_address)) && (request.erd == erd)) {
((request.address == packet->source) || (request.address == tiny_gea_broadcast_address)) && (request.erd == erd)) {
if(result == tiny_gea3_erd_api_read_result_success) {
tiny_erd_client_on_activity_args_t args;
args.address = packet->source;
Expand Down Expand Up @@ -527,7 +527,7 @@ static void handle_write_response_packet_worker(void* _context, void* allocated_
tiny_event_publish(&context->self->on_activity, &args);
}

static void handle_write_response_packet(self_t* self, const tiny_gea3_packet_t* packet)
static void handle_write_response_packet(self_t* self, const tiny_gea_packet_t* packet)
{
if(request_type(self) == request_type_write) {
write_request_t request;
Expand All @@ -539,7 +539,7 @@ static void handle_write_response_packet(self_t* self, const tiny_gea3_packet_t*
tiny_gea3_erd_api_write_result_t result = payload->result;

if((self->request_id == request_id) &&
((request.address == packet->source) || (request.address == tiny_gea3_broadcast_address)) &&
((request.address == packet->source) || (request.address == tiny_gea_broadcast_address)) &&
(request.erd == erd)) {
if(result == tiny_gea3_erd_api_write_result_success) {
handle_write_response_packet_context_t context = { self, .clientAddress = packet->source };
Expand All @@ -555,7 +555,7 @@ static void handle_write_response_packet(self_t* self, const tiny_gea3_packet_t*
}
}

static void handle_subscribe_all_response_packet(self_t* self, const tiny_gea3_packet_t* packet)
static void handle_subscribe_all_response_packet(self_t* self, const tiny_gea_packet_t* packet)
{
if(request_type(self) == request_type_subscribe) {
subscribe_request_t request;
Expand Down Expand Up @@ -588,7 +588,7 @@ typedef struct {
uint8_t request_id;
} subscription_publication_acknowledgment_worker_context_t;

static void send_subscription_publication_acknowledgment_worker(void* _context, tiny_gea3_packet_t* packet)
static void send_subscription_publication_acknowledgment_worker(void* _context, tiny_gea_packet_t* packet)
{
subscription_publication_acknowledgment_worker_context_t* context = _context;
reinterpret(payload, packet->payload, tiny_gea3_erd_api_publication_acknowledgement_payload_t*);
Expand All @@ -610,7 +610,7 @@ static void send_subscription_publication_acknowledgment(self_t* self, uint8_t a
&context);
}

static void handle_subscription_publication_packet(self_t* self, const tiny_gea3_packet_t* packet)
static void handle_subscription_publication_packet(self_t* self, const tiny_gea_packet_t* packet)
{
reinterpret(payload, packet->payload, const tiny_gea3_erd_api_publication_header_t*);

Expand Down Expand Up @@ -640,7 +640,7 @@ static void handle_subscription_publication_packet(self_t* self, const tiny_gea3
send_subscription_publication_acknowledgment(self, address, context, request_id);
}

static void handle_subscription_host_startup_packet(self_t* self, const tiny_gea3_packet_t* packet)
static void handle_subscription_host_startup_packet(self_t* self, const tiny_gea_packet_t* packet)
{
tiny_erd_client_on_activity_args_t args;
args.address = packet->source;
Expand Down
Loading

0 comments on commit 687bb17

Please sign in to comment.