aos/include/aos/shelly_client.h

42 lines
906 B
C

#ifndef _SHELLY_CLIENT_H_
#define _SHELLY_CLIENT_H_
#include <aos/aos.h>
// #define SHELLY_CLIENT_DEBUG_ON 1
#if defined(SHELLY_CLIENT_DEBUG_ON)
#define SHELLY_CLIENT_DEBUG(x...) debug_printf("[SHELLY_CLIENT_DEBUG] " x);
#else
#define SHELLY_CLIENT_DEBUG(x, ...) ((void)0)
#endif
enum shelly_msg_type {
SHELLY_MSG_PUTCHAR,
SHELLY_MSG_GETCHAR,
SHELLY_MSG_RESPONSE,
};
struct shelly_header {
enum shelly_msg_type type;
char character;
errval_t err;
};
struct shelly_client_state {
struct ump_send_chan *send_chan;
struct ump_recv_chan *recv_chan;
struct capref shared_frame;
bool request_ongoing;
struct shelly_header * current_request;
char * buf;
};
errval_t shelly_client_init(void);
errval_t shelly_client_getchar(struct aos_rpc * rpc, char * ret);
errval_t shelly_client_putchar(struct aos_rpc * rpc, char input);
#endif /* _SHELLY_CLIENT_H_ */