examples: check event type of BTSTACK_EVENT_STATE event

This commit is contained in:
Matthias Ringwald 2016-03-03 12:06:41 +01:00
parent 3de6de0559
commit 62d809aba1
2 changed files with 19 additions and 7 deletions

View File

@ -150,10 +150,16 @@ static void packet_handler (uint8_t packet_type, uint8_t *packet, uint16_t size)
/* @text In INIT, an inquiry scan is started, and the application transits to
* ACTIVE state.
*/
case INIT:
if (packet[2] == HCI_STATE_WORKING) {
start_scan();
state = ACTIVE;
case INIT:
switch(event){
case BTSTACK_EVENT_STATE:
if (packet[2] == HCI_STATE_WORKING){
start_scan();
state = ACTIVE;
}
break;
default:
break;
}
break;

View File

@ -137,9 +137,15 @@ static void packet_handler (uint8_t packet_type, uint8_t *packet, uint16_t size)
switch(state){
case INIT:
if (packet[2] == HCI_STATE_WORKING) {
hci_send_cmd(&hci_write_inquiry_mode, 0x01); // with RSSI
state = W4_INQUIRY_MODE_COMPLETE;
switch(event){
case BTSTACK_EVENT_STATE:
if (packet[2] == HCI_STATE_WORKING){
hci_send_cmd(&hci_write_inquiry_mode, 0x01); // with RSSI
state = W4_INQUIRY_MODE_COMPLETE;
}
break;
default:
break;
}
break;