From 848f44266dd4b9213af632d55747d66f03881422 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Wed, 6 Dec 2017 07:17:24 +0100 Subject: refactoring for memory limited systems --- code/test/basic.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'code/test/basic.c') diff --git a/code/test/basic.c b/code/test/basic.c index 5627fd3..85c4f31 100644 --- a/code/test/basic.c +++ b/code/test/basic.c @@ -20,40 +20,37 @@ ECPConnection conn; #define CTYPE_TEST 0 #define MTYPE_MSG 8 -ssize_t handle_open_c(ECPConnection *conn, ecp_seq_t sq, unsigned char t, unsigned char *p, ssize_t s) { +ssize_t handle_open_c(ECPConnection *conn, ecp_seq_t sq, unsigned char t, unsigned char *p, ssize_t s, ECP2Buffer *b) { uint32_t seq = 0; - ecp_conn_handle_open(conn, sq, t, p, s); + ecp_conn_handle_open(conn, sq, t, p, s, b); if (s < 0) { printf("OPEN ERR:%ld\n", s); return s; } - unsigned char payload[ECP_SIZE_PLD(1000, 0)]; - unsigned char *buf = ecp_pld_get_buf(payload, 0); char *msg = "PERA JE CAR!"; + unsigned char buf[1000]; - ecp_pld_set_type(payload, MTYPE_MSG); strcpy((char *)buf, msg); - ssize_t _rv = ecp_pld_send(conn, payload, sizeof(payload)); + ssize_t _rv = ecp_send(conn, MTYPE_MSG, buf, 1000); + return s; } -ssize_t handle_msg_c(ECPConnection *conn, ecp_seq_t sq, unsigned char t, unsigned char *p, ssize_t s) { +ssize_t handle_msg_c(ECPConnection *conn, ecp_seq_t sq, unsigned char t, unsigned char *p, ssize_t s, ECP2Buffer *b) { printf("MSG C:%s size:%ld\n", p, s); return s; } -ssize_t handle_msg_s(ECPConnection *conn, ecp_seq_t sq, unsigned char t, unsigned char *p, ssize_t s) { +ssize_t handle_msg_s(ECPConnection *conn, ecp_seq_t sq, unsigned char t, unsigned char *p, ssize_t s, ECP2Buffer *b) { printf("MSG S:%s size:%ld\n", p, s); - unsigned char payload[ECP_SIZE_PLD(1000, 0)]; - unsigned char *buf = ecp_pld_get_buf(payload, 0); char *msg = "VAISTINU JE CAR!"; + unsigned char buf[1000]; - ecp_pld_set_type(payload, MTYPE_MSG); strcpy((char *)buf, msg); - ssize_t _rv = ecp_pld_send(conn, payload, sizeof(payload)); + ssize_t _rv = ecp_send(conn, MTYPE_MSG, buf, 1000); return s; } -- cgit v1.2.3