1
0
Fork 0

Minor cleanups

This commit is contained in:
Shawn Nock 2019-08-03 04:51:07 -05:00
parent 9060e0d140
commit 247baf238a
1 changed files with 13 additions and 21 deletions

View File

@ -71,15 +71,17 @@ static struct k_thread event_thread_data;
static struct k_delayed_work ack_work; static struct k_delayed_work ack_work;
//static struct k_delayed_work retx_work; //static struct k_delayed_work retx_work;
#define HCI_3WIRE_ACK_PKT 0x00 typedef enum {
#define HCI_COMMAND_PKT 0x01 HCI_3WIRE_ACK_PKT = 0x00,
#define HCI_ACLDATA_PKT 0x02 HCI_COMMAND_PKT,
#define HCI_SCODATA_PKT 0x03 HCI_ACLDATA_PKT,
#define HCI_EVENT_PKT 0x04 HCI_SCODATA_PKT,
#define HCI_3WIRE_LINK_PKT 0x0f HCI_EVENT_PKT,
#define HCI_VENDOR_PKT 0xff HCI_VENDOR_SPECIFIC_PKT = 0xd,
HCI_3WIRE_LINK_PKT = 0x0f,
} h5_pkt_t;
static bool reliable_packet(u8_t type) static bool reliable_packet(h5_pkt_t type)
{ {
switch (type) { switch (type) {
case HCI_COMMAND_PKT: case HCI_COMMAND_PKT:
@ -117,7 +119,7 @@ typedef enum {
UNINIT, UNINIT,
INIT, INIT,
ACTIVE, ACTIVE,
} linkstate_t; } h5_linkstate_t;
static struct h5 { static struct h5 {
//struct net_buf *rx_buf; //struct net_buf *rx_buf;
@ -132,15 +134,7 @@ static struct h5 {
u8_t next_expected_seq_from_host; u8_t next_expected_seq_from_host;
u8_t local_seq; u8_t local_seq;
linkstate_t link_state; h5_linkstate_t link_state;
enum {
START,
HEADER,
PAYLOAD,
END,
} rx_state;
bool initializing;
} h5; } h5;
//static u8_t unack_queue_len; //static u8_t unack_queue_len;
@ -275,7 +269,7 @@ static u8_t next_seq(u8_t i) {
return (i + 1) % 8; return (i + 1) % 8;
} }
void h5_send(const u8_t *payload, u8_t type, int len) void h5_send(const u8_t *payload, h5_pkt_t type, int len)
{ {
h5_hdr_t hdr = {0}; h5_hdr_t hdr = {0};
@ -283,8 +277,6 @@ void h5_send(const u8_t *payload, u8_t type, int len)
hdr.ack = h5.next_expected_seq_from_host; hdr.ack = h5.next_expected_seq_from_host;
k_delayed_work_cancel(&ack_work); k_delayed_work_cancel(&ack_work);
LOG_INF("ACK'd %d", hdr.ack);
if (reliable_packet(type)) { if (reliable_packet(type)) {
hdr.is_reliable = true; hdr.is_reliable = true;
hdr.seq = h5.local_seq; hdr.seq = h5.local_seq;