34 lines
1.2 KiB
C
34 lines
1.2 KiB
C
#ifndef CLIENT_H
|
||
#define CLIENT_H
|
||
|
||
#include <stdint.h>
|
||
#include <stdbool.h>
|
||
|
||
enum HDLCState {
|
||
UNINITIALIZED_STATE = 0, // состояние до инцилизации
|
||
IDLE_STATE, // Состояние ожидания начала
|
||
READY_STATE, // Состояние принятия
|
||
CONNECTING, // состояние соединения
|
||
DISCONNECTING, // состояния отключения
|
||
RECIVING // состояние приема и отправки
|
||
};
|
||
|
||
struct Client{
|
||
enum HDLCState state;
|
||
int connecting_frame_timeout; //-1
|
||
int size_data_buffer;
|
||
int count_buffers;
|
||
int number_seq_frame;
|
||
};
|
||
|
||
//название функций
|
||
int init_hdlc_client(int count_buffers, int size_data_buffer, int connecting_frame_timeout, struct Client* client);
|
||
void connect(struct Client* client);
|
||
int send_data(struct Client* client, uint8_t* data, size_t data_len);
|
||
int get_frame(struct Client *client, uint8_t buffer[], size_t lenBuffer);
|
||
//принимает буффер с уарта
|
||
int hdlc_get_raw_data(struct Client* client, uint8_t buffer[], size_t len_buffer);
|
||
void hdlc_timeout_handler(struct Client* client, int delta_time);
|
||
|
||
#endif //CLIENT_H
|