mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-18 05:42:49 +00:00
simplified switch statement in packet handler
This commit is contained in:
parent
8a41a694f3
commit
bb6656c957
@ -40,6 +40,9 @@ static timer_source_t heartbeat;
|
|||||||
static int real_counter = 0;
|
static int real_counter = 0;
|
||||||
static int counter_to_send = 0;
|
static int counter_to_send = 0;
|
||||||
|
|
||||||
|
enum STATE {INIT, W4_CONNECTION, W4_CHANNEL_COMPLETE, ACTIVE} ;
|
||||||
|
enum STATE state = INIT;
|
||||||
|
|
||||||
static void tryToSend(void){
|
static void tryToSend(void){
|
||||||
if (!rfcomm_channel_id) return;
|
if (!rfcomm_channel_id) return;
|
||||||
if (real_counter <= counter_to_send) return;
|
if (real_counter <= counter_to_send) return;
|
||||||
@ -66,11 +69,12 @@ static void packet_handler (void * connection, uint8_t packet_type, uint16_t cha
|
|||||||
bd_addr_t event_addr;
|
bd_addr_t event_addr;
|
||||||
uint8_t rfcomm_channel_nr;
|
uint8_t rfcomm_channel_nr;
|
||||||
uint16_t mtu;
|
uint16_t mtu;
|
||||||
|
uint8_t event = packet[0];
|
||||||
|
|
||||||
switch (packet_type) {
|
// handle events, ignore data
|
||||||
case HCI_EVENT_PACKET:
|
if (packet_type != HCI_EVENT_PACKET) return;
|
||||||
switch (packet[0]) {
|
|
||||||
|
|
||||||
|
switch (event) {
|
||||||
case BTSTACK_EVENT_STATE:
|
case BTSTACK_EVENT_STATE:
|
||||||
// bt stack activated, get started - set local name
|
// bt stack activated, get started - set local name
|
||||||
if (packet[2] == HCI_STATE_WORKING) {
|
if (packet[2] == HCI_STATE_WORKING) {
|
||||||
@ -135,11 +139,7 @@ static void packet_handler (void * connection, uint8_t packet_type, uint16_t cha
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run_loop_register_timer(timer_source_t *timer, uint16_t period){
|
static void run_loop_register_timer(timer_source_t *timer, uint16_t period){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user