Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added GEA2 Communications #4

Merged
merged 32 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9461fa0
progress
KaitlynAnn99 Nov 14, 2024
cf9df1a
wip
KaitlynAnn99 Nov 15, 2024
a2ec043
i think im doing this right
KaitlynAnn99 Nov 21, 2024
f12289e
Merge remote-tracking branch 'upstream/main' into gea2
KaitlynAnn99 Nov 21, 2024
955a6fe
tests passing
KaitlynAnn99 Nov 22, 2024
e247164
renamed some variables
KaitlynAnn99 Nov 25, 2024
2a9d198
made a few formatting changes
KaitlynAnn99 Nov 25, 2024
5086f0f
some renames
KaitlynAnn99 Nov 25, 2024
8ef1b0c
renames
KaitlynAnn99 Nov 25, 2024
048fe3e
renamed again
KaitlynAnn99 Nov 25, 2024
ae111af
fixed reinterprets
KaitlynAnn99 Nov 25, 2024
4b1fe6f
oops
KaitlynAnn99 Nov 25, 2024
f4168c3
fixed doxy
KaitlynAnn99 Nov 25, 2024
8d3c46e
Apply suggestions from code review
KaitlynAnn99 Nov 25, 2024
87f8e0c
fixed
KaitlynAnn99 Nov 25, 2024
8db240d
Merge branch 'gea2' of https://github.com/KaitlynAnn99/tiny-gea3-api …
KaitlynAnn99 Nov 25, 2024
d26fd4e
Update include/tiny_gea2_interface.h
ryanplusplus Nov 25, 2024
f7178ea
Apply suggestions from code review
ryanplusplus Nov 25, 2024
b3bb805
made retries an arg
KaitlynAnn99 Nov 25, 2024
b2472f6
Merge branch 'gea2' of https://github.com/KaitlynAnn99/tiny-gea3-api …
KaitlynAnn99 Nov 25, 2024
1a271d0
Update test/tests/tiny_gea2_interface_test.cpp
ryanplusplus Nov 25, 2024
45eca94
Update test/tests/tiny_gea2_interface_test.cpp
ryanplusplus Nov 25, 2024
a39a031
Update src/tiny_gea2_interface.c
ryanplusplus Nov 25, 2024
715c14c
reinterprets
KaitlynAnn99 Nov 25, 2024
f1dea7e
fixed merge thing
KaitlynAnn99 Nov 25, 2024
687bb17
renamed to gea instead of gea3
KaitlynAnn99 Nov 25, 2024
3bb9564
rename allocation
KaitlynAnn99 Nov 25, 2024
e886f3b
lol one more
KaitlynAnn99 Nov 25, 2024
f033720
comments
KaitlynAnn99 Nov 25, 2024
530096b
swapped context stuff and rename
KaitlynAnn99 Dec 9, 2024
d776468
one more
KaitlynAnn99 Dec 9, 2024
f7e8cf9
Update include/i_tiny_gea_interface.h
ryanplusplus Dec 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"request": "launch",
"preLaunchTask": "Build",
"program": "${workspaceFolder}/build/arduino-gea3-api_tests",
"args": [ ],
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [ ],
"environment": [],
"externalConsole": false,
"linux": {
"MIMode": "gdb"
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ add_library(tiny_gea3 INTERFACE)
target_sources(tiny_gea3 INTERFACE
${CMAKE_CURRENT_LIST_DIR}/src/tiny_erd_client.c
${CMAKE_CURRENT_LIST_DIR}/src/tiny_gea3_interface.c
${CMAKE_CURRENT_LIST_DIR}/src/tiny_gea2_interface.c
)

target_include_directories(tiny_gea3 INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# tiny-gea3-api
[![Tests](https://github.com/geappliances/tiny-gea3-api/actions/workflows/test.yml/badge.svg)](https://github.com/geappliances/tiny-gea3-api/actions/workflows/test.yml)

PlatformIO library for interacting with GE Appliances products supporting the full-duplex GEA3 serial protocol using the [`tiny`](https://github.com/ryanplusplus/tiny) HAL. Note that this does not support older GE Appliances products using the single-wire GEA2 interface.
PlatformIO library for interacting with GE Appliances products supporting the half-duplex GEA2 serial protocol and the full-duplex GEA3 serial protocol using the [`tiny`](https://github.com/ryanplusplus/tiny) HAL.

## Components
### `tiny_gea3_interface`
Provides a simple interface for sending and receiving GEA3 serial packets.

## `tiny_gea2_interface`
Provides a simple interface for sending and receiving GEA2 serial packets on a half duplex setup.

### `tiny_erd_client`
Provides a simple interface for reading and writing addressable data (ERDs) over a GEA3 serial interface.

Expand Down
26 changes: 13 additions & 13 deletions include/i_tiny_gea3_interface.h → include/i_tiny_gea_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* the last send has been completed then the last send will be interrupted.
*/

#ifndef i_tiny_gea3_interface_h
#define i_tiny_gea3_interface_h
#ifndef i_tiny_gea_interface_h
#define i_tiny_gea_interface_h

#include <stdbool.h>
#include "i_tiny_event.h"
Expand All @@ -19,29 +19,29 @@ typedef struct {

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

struct i_tiny_gea3_interface_api_t;
struct i_tiny_gea_interface_api_t;

typedef struct {
const struct i_tiny_gea3_interface_api_t* api;
} i_tiny_gea3_interface_t;
const struct i_tiny_gea_interface_api_t* api;
} i_tiny_gea_interface_t;

typedef struct i_tiny_gea3_interface_api_t {
typedef struct i_tiny_gea_interface_api_t {
bool (*send)(
i_tiny_gea3_interface_t* self,
i_tiny_gea_interface_t* self,
uint8_t destination,
uint8_t payload_length,
tiny_gea3_interface_send_callback_t callback,
void* context);

bool (*forward)(
i_tiny_gea3_interface_t* self,
i_tiny_gea_interface_t* self,
uint8_t destination,
uint8_t payload_length,
tiny_gea3_interface_send_callback_t callback,
void* context);

i_tiny_event_t* (*on_receive)(i_tiny_gea3_interface_t* self);
} i_tiny_gea3_interface_api_t;
i_tiny_event_t* (*on_receive)(i_tiny_gea_interface_t* self);
} i_tiny_gea_interface_api_t;

/*!
* Send a packet by getting direct access to the internal send buffer (given to
Expand All @@ -51,7 +51,7 @@ typedef struct i_tiny_gea3_interface_api_t {
* or activity.
*/
static inline bool tiny_gea3_interface_send(
i_tiny_gea3_interface_t* self,
i_tiny_gea_interface_t* self,
uint8_t destination,
uint8_t payload_length,
tiny_gea3_interface_send_callback_t callback,
Expand All @@ -64,7 +64,7 @@ static inline bool tiny_gea3_interface_send(
* Send a packet without setting source address
ryanplusplus marked this conversation as resolved.
Show resolved Hide resolved
*/
static inline bool tiny_gea3_interface_forward(
i_tiny_gea3_interface_t* self,
i_tiny_gea_interface_t* self,
uint8_t destination,
uint8_t payload_length,
tiny_gea3_interface_send_callback_t callback,
Expand All @@ -76,7 +76,7 @@ static inline bool tiny_gea3_interface_forward(
/*!
* Event raised when a packet is received.
*/
static inline i_tiny_event_t* tiny_gea3_interface_on_receive(i_tiny_gea3_interface_t* self)
static inline i_tiny_event_t* tiny_gea3_interface_on_receive(i_tiny_gea_interface_t* self)
{
return self->api->on_receive(self);
}
Expand Down
6 changes: 3 additions & 3 deletions include/tiny_erd_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#define tiny_erd_client_h

#include "i_tiny_erd_client.h"
#include "i_tiny_gea3_interface.h"
#include "i_tiny_gea_interface.h"
#include "tiny_event.h"
#include "tiny_queue.h"
#include "tiny_ring_buffer.h"
Expand All @@ -23,7 +23,7 @@ typedef struct {

tiny_event_subscription_t packet_received;
tiny_queue_t request_queue;
i_tiny_gea3_interface_t* gea3_interface;
i_tiny_gea_interface_t* gea3_interface;
tiny_timer_group_t* timer_group;
tiny_timer_t request_retry_timer;
tiny_event_t on_activity;
Expand All @@ -40,7 +40,7 @@ typedef struct {
void tiny_erd_client_init(
tiny_erd_client_t* self,
tiny_timer_group_t* timer_group,
i_tiny_gea3_interface_t* gea3_interface,
i_tiny_gea_interface_t* gea3_interface,
uint8_t* queue_buffer,
size_t queue_buffer_size,
const tiny_erd_client_configuration_t* configuration);
Expand Down
98 changes: 98 additions & 0 deletions include/tiny_gea2_interface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*!
* @file
* @brief
*
* This component is interrupt-aware and handles byte transmit/receive in the
* interrupt context. Publication of messages is done via a background task in
* tiny_gea2_interface_run() so the application does not have to do
* anything special.
*
* Additionally, this component does not do any queueing of packets. If a send
* is in progress and another message is sent, then the currently sending message
* is discarded. In order to prevent this, clients can check whether the interface
* is currently sending and wait before attempting to send a packet.
*
* If a message is received, all messages received after will be dropped until
* tiny_gea2_interface_run() is called.
*
* Note: This module requires an interrupt event. This "interrupt" is an event
* that needs to happen in the same context as the `on_receive`.
*/

#ifndef tiny_gea2_interface_h
#define tiny_gea2_interface_h

#include "hal/i_tiny_uart.h"
#include "i_tiny_gea_interface.h"
#include "i_tiny_time_source.h"
#include "tiny_crc16.h"
#include "tiny_event.h"
#include "tiny_fsm.h"
#include "tiny_timer.h"

typedef struct
{
i_tiny_gea_interface_t interface;

struct
{
tiny_fsm_t fsm;
tiny_event_t on_receive;
tiny_event_t on_diagnostics_event;
tiny_event_subscription_t msec_interrupt_subscription;
tiny_event_subscription_t byte_received_subscription;
i_tiny_uart_t* uart;
tiny_timer_t timer;
uint8_t address;
bool ignore_destination_address;
uint8_t retries;
tiny_timer_group_t timer_group;

struct
{
uint8_t* buffer;
uint8_t buffer_size;
uint8_t state;
uint8_t offset;
uint16_t crc;
bool escaped;
volatile bool active;
volatile bool packet_queued_in_background;
uint8_t expected_reflection;
uint8_t retries;
} send;

struct
{
uint8_t* buffer;
uint16_t crc;
uint8_t buffer_size;
uint8_t count;
bool escaped;
volatile bool packet_ready;
} receive;
} _private;
} tiny_gea2_interface_t;

/*!
* Initialize a GEA2 interface.
*/
void tiny_gea2_interface_init(
tiny_gea2_interface_t* instance,
i_tiny_uart_t* uart,
i_tiny_time_source_t* time_source,
i_tiny_event_t* msec_interrupt,
uint8_t* receive_buffer,
uint8_t receive_buffer_size,
uint8_t* send_buffer,
uint8_t send_buffer_size,
uint8_t address,
bool ignore_destination_address,
uint8_t retries);

/*!
* Run the interface and publish received packets.
*/
void tiny_gea2_interface_run(tiny_gea2_interface_t* instance);

#endif
4 changes: 2 additions & 2 deletions include/tiny_gea3_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

#include <stdint.h>
#include "hal/i_tiny_uart.h"
#include "i_tiny_gea3_interface.h"
#include "i_tiny_gea_interface.h"
#include "tiny_event.h"
#include "tiny_queue.h"

typedef struct {
i_tiny_gea3_interface_t interface;
i_tiny_gea_interface_t interface;

tiny_event_t on_receive;
tiny_event_subscription_t byte_received_subscription;
Expand Down
2 changes: 1 addition & 1 deletion src/tiny_erd_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@ static const i_tiny_erd_client_api_t api = { read, write, subscribe, retain_subs
void tiny_erd_client_init(
tiny_erd_client_t* self,
tiny_timer_group_t* timer_group,
i_tiny_gea3_interface_t* gea3_interface,
i_tiny_gea_interface_t* gea3_interface,
uint8_t* queue_buffer,
size_t queue_buffer_size,
const tiny_erd_client_configuration_t* configuration)
Expand Down
Loading
Loading