mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-21 04:21:03 +00:00
java: use streamline event names, GAP_LE_EVENT_ADVERTISING_REPORT -> GAP_EVENT_ADVERTISING_REPORT
This commit is contained in:
parent
253d768484
commit
045013fe99
@ -57,7 +57,7 @@ static btstack_packet_callback_registration_t hci_event_callback_registration;
|
||||
/* @section GAP LE setup for receiving advertisements
|
||||
*
|
||||
* @text GAP LE advertisements are received as custom HCI events of the
|
||||
* GAP_LE_EVENT_ADVERTISING_REPORT type. To receive them, you'll need to register
|
||||
* GAP_EVENT_ADVERTISING_REPORT type. To receive them, you'll need to register
|
||||
* the HCI packet handler, as shown in Listing GAPLEAdvSetup.
|
||||
*/
|
||||
|
||||
@ -222,7 +222,7 @@ static void dump_advertisement_data(uint8_t * adv_data, uint8_t adv_size){
|
||||
*
|
||||
* @text The HCI packet handler has to start the scanning,
|
||||
* and to handle received advertisements. Advertisements are received
|
||||
* as HCI event packets of the GAP_LE_EVENT_ADVERTISING_REPORT type,
|
||||
* as HCI event packets of the GAP_EVENT_ADVERTISING_REPORT type,
|
||||
* see Listing GAPLEAdvPacketHandler.
|
||||
*/
|
||||
|
||||
@ -240,7 +240,7 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
|
||||
gap_start_scan();
|
||||
}
|
||||
break;
|
||||
case GAP_LE_EVENT_ADVERTISING_REPORT:{
|
||||
case GAP_EVENT_ADVERTISING_REPORT:{
|
||||
int pos = 2;
|
||||
uint8_t event_type = packet[pos++];
|
||||
uint8_t address_type = packet[pos++];
|
||||
|
@ -221,7 +221,7 @@ static void hci_event_handler(uint8_t packet_type, uint16_t channel, uint8_t *pa
|
||||
gap_set_scan_parameters(0,0x0030, 0x0030);
|
||||
gap_start_scan();
|
||||
break;
|
||||
case GAP_LE_EVENT_ADVERTISING_REPORT:
|
||||
case GAP_EVENT_ADVERTISING_REPORT:
|
||||
if (state != TC_W4_SCAN_RESULT) return;
|
||||
fill_advertising_report_from_packet(&report, packet);
|
||||
// stop scanning, and connect to the device
|
||||
|
@ -186,7 +186,7 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac
|
||||
gap_set_scan_parameters(0,0x0030, 0x0030);
|
||||
gap_start_scan();
|
||||
break;
|
||||
case GAP_LE_EVENT_ADVERTISING_REPORT:
|
||||
case GAP_EVENT_ADVERTISING_REPORT:
|
||||
fill_advertising_report_from_packet(&report, packet);
|
||||
// stop scanning, and connect to the device
|
||||
gap_stop_scan();
|
||||
|
@ -16,12 +16,12 @@ import com.bluekitchen.btstack.PacketHandler;
|
||||
import com.bluekitchen.btstack.Util;
|
||||
import com.bluekitchen.btstack.event.BTstackEventDaemonDisconnect;
|
||||
import com.bluekitchen.btstack.event.BTstackEventState;
|
||||
import com.bluekitchen.btstack.event.GAPLEAdvertisingReport;
|
||||
import com.bluekitchen.btstack.event.GATTCharacteristicQueryResult;
|
||||
import com.bluekitchen.btstack.event.GATTCharacteristicValueQueryResult;
|
||||
import com.bluekitchen.btstack.event.GATTNotification;
|
||||
import com.bluekitchen.btstack.event.GATTQueryComplete;
|
||||
import com.bluekitchen.btstack.event.GATTServiceQueryResult;
|
||||
import com.bluekitchen.btstack.event.GAPEventAdvertisingReport;
|
||||
import com.bluekitchen.btstack.event.GATTEventCharacteristicQueryResult;
|
||||
import com.bluekitchen.btstack.event.GATTEventCharacteristicValueQueryResult;
|
||||
import com.bluekitchen.btstack.event.GATTEventNotification;
|
||||
import com.bluekitchen.btstack.event.GATTEventQueryComplete;
|
||||
import com.bluekitchen.btstack.event.GATTEventServiceQueryResult;
|
||||
import com.bluekitchen.btstack.event.HCIEventDisconnectionComplete;
|
||||
import com.bluekitchen.btstack.event.HCIEventHardwareError;
|
||||
import com.bluekitchen.btstack.event.HCIEventLEConnectionComplete;
|
||||
@ -108,8 +108,8 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_scan_result:
|
||||
if (packet instanceof GAPLEAdvertisingReport){
|
||||
GAPLEAdvertisingReport report = (GAPLEAdvertisingReport) packet;
|
||||
if (packet instanceof GAPEventAdvertisingReport){
|
||||
GAPEventAdvertisingReport report = (GAPEventAdvertisingReport) packet;
|
||||
testAddrType = report.getAddressType();
|
||||
testAddr = report.getAddress();
|
||||
addMessage(String.format("Adv: type %d, addr %s", testAddrType, testAddr));
|
||||
@ -132,8 +132,8 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_services_complete:
|
||||
if (packet instanceof GATTServiceQueryResult){
|
||||
GATTServiceQueryResult event = (GATTServiceQueryResult) packet;
|
||||
if (packet instanceof GATTEventServiceQueryResult){
|
||||
GATTEventServiceQueryResult event = (GATTEventServiceQueryResult) packet;
|
||||
if (testService == null){
|
||||
addMessage(String.format("First service UUID %s", event.getService().getUUID()));
|
||||
testService = event.getService();
|
||||
@ -141,7 +141,7 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
Log.d(BTSTACK_TAG, "Service: " + event.getService());
|
||||
service_count++;
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
addMessage(String.format("Service query complete, total %d services", service_count));
|
||||
state = STATE.w4_characteristic_complete;
|
||||
btstack.GATTDiscoverCharacteristicsForService(testHandle, testService);
|
||||
@ -149,8 +149,8 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
break;
|
||||
|
||||
case w4_characteristic_complete:
|
||||
if (packet instanceof GATTCharacteristicQueryResult){
|
||||
GATTCharacteristicQueryResult event = (GATTCharacteristicQueryResult) packet;
|
||||
if (packet instanceof GATTEventCharacteristicQueryResult){
|
||||
GATTEventCharacteristicQueryResult event = (GATTEventCharacteristicQueryResult) packet;
|
||||
if (testCharacteristic == null){
|
||||
addMessage(String.format("First characteristic UUID %s", event.getCharacteristic().getUUID()));
|
||||
testCharacteristic = event.getCharacteristic();
|
||||
@ -158,7 +158,7 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
Log.d(BTSTACK_TAG, "Characteristic: " + event.getCharacteristic());
|
||||
characteristic_count++;
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
addMessage(String.format("Characteristic query complete, total %d characteristics", characteristic_count));
|
||||
state = STATE.w4_characteristic_read;
|
||||
btstack.GATTReadValueOfCharacteristic(testHandle, testCharacteristic);
|
||||
@ -166,7 +166,7 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
break;
|
||||
|
||||
case w4_characteristic_read:
|
||||
if (packet instanceof GATTCharacteristicValueQueryResult){
|
||||
if (packet instanceof GATTEventCharacteristicValueQueryResult){
|
||||
addMessage("Read complete");
|
||||
Log.d(BTSTACK_TAG, packet.toString());
|
||||
state = STATE.w4_characteristic_write;
|
||||
@ -175,7 +175,7 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_characteristic_write:
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
addMessage("Write complete, search for ACC service");
|
||||
state = STATE.w4_btstack_working;
|
||||
btstack.GAPDisconnect(testHandle);
|
||||
@ -200,8 +200,8 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_scan_result:
|
||||
if (packet instanceof GAPLEAdvertisingReport){
|
||||
GAPLEAdvertisingReport report = (GAPLEAdvertisingReport) packet;
|
||||
if (packet instanceof GAPEventAdvertisingReport){
|
||||
GAPEventAdvertisingReport report = (GAPEventAdvertisingReport) packet;
|
||||
testAddrType = report.getAddressType();
|
||||
testAddr = report.getAddress();
|
||||
addMessage(String.format("Adv: type %d, addr %s", testAddrType, testAddr));
|
||||
@ -231,13 +231,13 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
|
||||
case w4_acc_service_result:
|
||||
addMessage(String.format("w4_acc_service_result state"));
|
||||
if (packet instanceof GATTServiceQueryResult){
|
||||
GATTServiceQueryResult event = (GATTServiceQueryResult) packet;
|
||||
if (packet instanceof GATTEventServiceQueryResult){
|
||||
GATTEventServiceQueryResult event = (GATTEventServiceQueryResult) packet;
|
||||
addMessage(String.format("ACC service found %s", event.getService().getUUID()));
|
||||
accService = event.getService();
|
||||
break;
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
if (accService == null) {
|
||||
addMessage("No acc service found");
|
||||
break;
|
||||
@ -251,12 +251,12 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
break;
|
||||
|
||||
case w4_acc_enable_characteristic_result:
|
||||
if (packet instanceof GATTCharacteristicQueryResult){
|
||||
GATTCharacteristicQueryResult event = (GATTCharacteristicQueryResult) packet;
|
||||
if (packet instanceof GATTEventCharacteristicQueryResult){
|
||||
GATTEventCharacteristicQueryResult event = (GATTEventCharacteristicQueryResult) packet;
|
||||
enableCharacteristic = event.getCharacteristic();
|
||||
addMessage("Enable ACC Characteristic found ");
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
if (enableCharacteristic == null) {
|
||||
addMessage("No acc enable chr found");
|
||||
break;
|
||||
@ -267,7 +267,7 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_write_acc_enable_result:
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
addMessage("Acc enabled,searching for acc client config characteristic");
|
||||
byte [] uuid = new byte[16];
|
||||
Util.flipX(this.acc_chr_client_config_uuid, uuid);
|
||||
@ -277,12 +277,12 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
break;
|
||||
|
||||
case w4_acc_client_config_characteristic_result:
|
||||
if (packet instanceof GATTCharacteristicQueryResult){
|
||||
GATTCharacteristicQueryResult event = (GATTCharacteristicQueryResult) packet;
|
||||
if (packet instanceof GATTEventCharacteristicQueryResult){
|
||||
GATTEventCharacteristicQueryResult event = (GATTEventCharacteristicQueryResult) packet;
|
||||
configCharacteristic = event.getCharacteristic();
|
||||
addMessage("ACC Client Config Characteristic found");
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
if (configCharacteristic == null) {
|
||||
addMessage("No acc config chr found");
|
||||
break;
|
||||
@ -294,12 +294,12 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
break;
|
||||
|
||||
case w4_acc_data:
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
addMessage("Acc configured for notification");
|
||||
break;
|
||||
}
|
||||
|
||||
if (packet instanceof GATTNotification){
|
||||
if (packet instanceof GATTEventNotification){
|
||||
addMessage("Acc Value");
|
||||
Log.d(BTSTACK_TAG, packet.toString());
|
||||
state = STATE.w4_btstack_working;
|
||||
@ -356,13 +356,13 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_scan_result:
|
||||
if (packet instanceof GAPLEAdvertisingReport){
|
||||
if (packet instanceof GAPEventAdvertisingReport){
|
||||
|
||||
BD_ADDR sensor_tag_addr = new BD_ADDR("1C:BA:8C:20:C7:F6");
|
||||
BD_ADDR pts_dongle = new BD_ADDR("00:1B:DC:07:32:EF");
|
||||
BD_ADDR asus_dongle = new BD_ADDR("5c:f3:70:60:7b:87");
|
||||
|
||||
GAPLEAdvertisingReport report = (GAPLEAdvertisingReport) packet;
|
||||
GAPEventAdvertisingReport report = (GAPEventAdvertisingReport) packet;
|
||||
BD_ADDR reportAddr = report.getAddress();
|
||||
if (reportAddr.toString().equalsIgnoreCase(asus_dongle.toString())){
|
||||
testAddrType = report.getAddressType();
|
||||
@ -392,8 +392,8 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_services_complete:
|
||||
if (packet instanceof GATTServiceQueryResult){
|
||||
GATTServiceQueryResult event = (GATTServiceQueryResult) packet;
|
||||
if (packet instanceof GATTEventServiceQueryResult){
|
||||
GATTEventServiceQueryResult event = (GATTEventServiceQueryResult) packet;
|
||||
if (testService == null){
|
||||
addMessage(String.format("First service UUID %s", event.getService().getUUID()));
|
||||
testService = event.getService();
|
||||
@ -401,7 +401,7 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
Log.d(BTSTACK_TAG, "Service: " + event.getService());
|
||||
service_count++;
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
addMessage(String.format("Service query complete, total %d services", service_count));
|
||||
state = STATE.w4_disconnect;
|
||||
test_run_count++;
|
||||
|
@ -9,12 +9,12 @@ import com.bluekitchen.btstack.Packet;
|
||||
import com.bluekitchen.btstack.PacketHandler;
|
||||
import com.bluekitchen.btstack.Util;
|
||||
import com.bluekitchen.btstack.event.BTstackEventState;
|
||||
import com.bluekitchen.btstack.event.GAPLEAdvertisingReport;
|
||||
import com.bluekitchen.btstack.event.GATTCharacteristicQueryResult;
|
||||
import com.bluekitchen.btstack.event.GATTCharacteristicValueQueryResult;
|
||||
import com.bluekitchen.btstack.event.GATTNotification;
|
||||
import com.bluekitchen.btstack.event.GATTQueryComplete;
|
||||
import com.bluekitchen.btstack.event.GATTServiceQueryResult;
|
||||
import com.bluekitchen.btstack.event.GAPEventAdvertisingReport;
|
||||
import com.bluekitchen.btstack.event.GATTEventCharacteristicQueryResult;
|
||||
import com.bluekitchen.btstack.event.GATTEventCharacteristicValueQueryResult;
|
||||
import com.bluekitchen.btstack.event.GATTEventNotification;
|
||||
import com.bluekitchen.btstack.event.GATTEventQueryComplete;
|
||||
import com.bluekitchen.btstack.event.GATTEventServiceQueryResult;
|
||||
import com.bluekitchen.btstack.event.HCIEventDisconnectionComplete;
|
||||
import com.bluekitchen.btstack.event.HCIEventLEConnectionComplete;
|
||||
|
||||
@ -50,7 +50,7 @@ public class GATTClientTest implements PacketHandler {
|
||||
private GATTService batteryService;
|
||||
private GATTCharacteristic batteryLevelCharacteristic;
|
||||
private byte[] battery_level_chr_uuid = new byte[] {0, 0, (byte)0x2a, (byte)0x19, 0, 0, (byte)0x10, 0, (byte)0x80, 0, 0, (byte)0x80, (byte)0x5f, (byte)0x9b, (byte)0x34, (byte)0xfb};
|
||||
GATTCharacteristicValueQueryResult battery;
|
||||
GATTEventCharacteristicValueQueryResult battery;
|
||||
|
||||
private BT_UUID uuid128(byte[] att_uuid) {
|
||||
byte [] uuid = new byte[16];
|
||||
@ -66,8 +66,8 @@ public class GATTClientTest implements PacketHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
GATTQueryComplete event = (GATTQueryComplete) packet;
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
GATTEventQueryComplete event = (GATTEventQueryComplete) packet;
|
||||
System.out.println(testAddr + " battery data");
|
||||
if (event.getStatus() != 0){
|
||||
System.out.println("Battery data could not be read.\nRestart scanning.");
|
||||
@ -89,9 +89,9 @@ public class GATTClientTest implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_scan_result:
|
||||
if (packet instanceof GAPLEAdvertisingReport){
|
||||
if (packet instanceof GAPEventAdvertisingReport){
|
||||
// Advertisement received. Connect to the found BT address.
|
||||
GAPLEAdvertisingReport report = (GAPLEAdvertisingReport) packet;
|
||||
GAPEventAdvertisingReport report = (GAPEventAdvertisingReport) packet;
|
||||
testAddrType = report.getAddressType();
|
||||
testAddr = report.getAddress();
|
||||
System.out.println(String.format("Adv: type %d, addr %s\ndata: %s \n Stop scan, initiate connect.", testAddrType, testAddr, Util.asHexdump(report.getData())));
|
||||
@ -118,14 +118,14 @@ public class GATTClientTest implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_services_complete:
|
||||
if (packet instanceof GATTServiceQueryResult){
|
||||
// Store battery service. Wait for GATTQueryComplete event to send next GATT command.
|
||||
GATTServiceQueryResult event = (GATTServiceQueryResult) packet;
|
||||
if (packet instanceof GATTEventServiceQueryResult){
|
||||
// Store battery service. Wait for GATTEventQueryComplete event to send next GATT command.
|
||||
GATTEventServiceQueryResult event = (GATTEventServiceQueryResult) packet;
|
||||
System.out.println(testAddr + String.format(" - battery service %s", event.getService().getUUID()));
|
||||
batteryService = event.getService();
|
||||
break;
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
// Check if battery service is found.
|
||||
if (batteryService == null) {
|
||||
System.out.println(testAddr + " - no battery service. \nRestart scanning.");
|
||||
@ -139,15 +139,15 @@ public class GATTClientTest implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_characteristic_complete:
|
||||
if (packet instanceof GATTCharacteristicQueryResult){
|
||||
// Store battery level characteristic. Wait for GATTQueryComplete event to send next GATT command.
|
||||
GATTCharacteristicQueryResult event = (GATTCharacteristicQueryResult) packet;
|
||||
if (packet instanceof GATTEventCharacteristicQueryResult){
|
||||
// Store battery level characteristic. Wait for GATTEventQueryComplete event to send next GATT command.
|
||||
GATTEventCharacteristicQueryResult event = (GATTEventCharacteristicQueryResult) packet;
|
||||
batteryLevelCharacteristic = event.getCharacteristic();
|
||||
System.out.println(testAddr + " - battery level found.");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(packet instanceof GATTQueryComplete)) break;
|
||||
if (!(packet instanceof GATTEventQueryComplete)) break;
|
||||
if (batteryLevelCharacteristic == null) {
|
||||
System.out.println("No battery level characteristic found");
|
||||
break;
|
||||
@ -168,8 +168,8 @@ public class GATTClientTest implements PacketHandler {
|
||||
}).start();
|
||||
break;
|
||||
case battery_data:
|
||||
if (packet instanceof GATTCharacteristicValueQueryResult){
|
||||
GATTCharacteristicValueQueryResult battery = (GATTCharacteristicValueQueryResult) packet;
|
||||
if (packet instanceof GATTEventCharacteristicValueQueryResult){
|
||||
GATTEventCharacteristicValueQueryResult battery = (GATTEventCharacteristicValueQueryResult) packet;
|
||||
|
||||
if (battery.getValueLength() != 1) break;
|
||||
byte[] data = battery.getValue();
|
||||
@ -207,8 +207,8 @@ public class GATTClientTest implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_scan_result:
|
||||
if (packet instanceof GAPLEAdvertisingReport){
|
||||
GAPLEAdvertisingReport report = (GAPLEAdvertisingReport) packet;
|
||||
if (packet instanceof GAPEventAdvertisingReport){
|
||||
GAPEventAdvertisingReport report = (GAPEventAdvertisingReport) packet;
|
||||
testAddrType = report.getAddressType();
|
||||
testAddr = report.getAddress();
|
||||
System.out.println(String.format("Adv: type %d, addr %s", testAddrType, testAddr));
|
||||
@ -232,8 +232,8 @@ public class GATTClientTest implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_services_complete:
|
||||
if (packet instanceof GATTServiceQueryResult){
|
||||
GATTServiceQueryResult event = (GATTServiceQueryResult) packet;
|
||||
if (packet instanceof GATTEventServiceQueryResult){
|
||||
GATTEventServiceQueryResult event = (GATTEventServiceQueryResult) packet;
|
||||
if (testService == null){
|
||||
System.out.println(String.format("First service UUID %s", event.getService().getUUID()));
|
||||
testService = event.getService();
|
||||
@ -241,7 +241,7 @@ public class GATTClientTest implements PacketHandler {
|
||||
System.out.println("Service: " + event.getService());
|
||||
service_count++;
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
System.out.println(String.format("Service query complete, total %d services", service_count));
|
||||
state = STATE.w4_characteristic_complete;
|
||||
btstack.GATTDiscoverCharacteristicsForService(testHandle, testService);
|
||||
@ -249,8 +249,8 @@ public class GATTClientTest implements PacketHandler {
|
||||
break;
|
||||
|
||||
case w4_characteristic_complete:
|
||||
if (packet instanceof GATTCharacteristicQueryResult){
|
||||
GATTCharacteristicQueryResult event = (GATTCharacteristicQueryResult) packet;
|
||||
if (packet instanceof GATTEventCharacteristicQueryResult){
|
||||
GATTEventCharacteristicQueryResult event = (GATTEventCharacteristicQueryResult) packet;
|
||||
if (testCharacteristic == null){
|
||||
System.out.println(String.format("First characteristic UUID %s", event.getCharacteristic().getUUID()));
|
||||
testCharacteristic = event.getCharacteristic();
|
||||
@ -258,7 +258,7 @@ public class GATTClientTest implements PacketHandler {
|
||||
System.out.println("Characteristic: " + event.getCharacteristic());
|
||||
characteristic_count++;
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
System.out.println(String.format("Characteristic query complete, total %d characteristics", characteristic_count));
|
||||
state = STATE.w4_characteristic_read;
|
||||
btstack.GATTReadValueOfCharacteristic(testHandle, testCharacteristic);
|
||||
@ -266,7 +266,7 @@ public class GATTClientTest implements PacketHandler {
|
||||
break;
|
||||
|
||||
case w4_characteristic_read:
|
||||
if (packet instanceof GATTCharacteristicValueQueryResult){
|
||||
if (packet instanceof GATTEventCharacteristicValueQueryResult){
|
||||
System.out.println("Read complete");
|
||||
System.out.println( packet.toString());
|
||||
state = STATE.w4_characteristic_write;
|
||||
@ -275,7 +275,7 @@ public class GATTClientTest implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_characteristic_write:
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
System.out.println("Write complete, search for ACC service");
|
||||
state = STATE.w4_acc_service_result;
|
||||
btstack.GATTDiscoverPrimaryServicesByUUID128(testHandle, new BT_UUID(this.acc_service_uuid)); // not working
|
||||
@ -297,13 +297,13 @@ public class GATTClientTest implements PacketHandler {
|
||||
|
||||
case w4_acc_service_result:
|
||||
System.out.println(String.format("w4_acc_service_result state"));
|
||||
if (packet instanceof GATTServiceQueryResult){
|
||||
GATTServiceQueryResult event = (GATTServiceQueryResult) packet;
|
||||
if (packet instanceof GATTEventServiceQueryResult){
|
||||
GATTEventServiceQueryResult event = (GATTEventServiceQueryResult) packet;
|
||||
System.out.println(String.format("ACC service found %s", event.getService().getUUID()));
|
||||
accService = event.getService();
|
||||
break;
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
if (accService == null) {
|
||||
System.out.println("No acc service found");
|
||||
break;
|
||||
@ -317,12 +317,12 @@ public class GATTClientTest implements PacketHandler {
|
||||
break;
|
||||
|
||||
case w4_acc_enable_characteristic_result:
|
||||
if (packet instanceof GATTCharacteristicQueryResult){
|
||||
GATTCharacteristicQueryResult event = (GATTCharacteristicQueryResult) packet;
|
||||
if (packet instanceof GATTEventCharacteristicQueryResult){
|
||||
GATTEventCharacteristicQueryResult event = (GATTEventCharacteristicQueryResult) packet;
|
||||
enableCharacteristic = event.getCharacteristic();
|
||||
System.out.println("Enable ACC Characteristic found ");
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
if (enableCharacteristic == null) {
|
||||
System.out.println("No acc enable chr found");
|
||||
break;
|
||||
@ -333,7 +333,7 @@ public class GATTClientTest implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_write_acc_enable_result:
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
System.out.println("Acc enabled,searching for acc client config characteristic");
|
||||
byte [] uuid = new byte[16];
|
||||
Util.flipX(this.acc_chr_client_config_uuid, uuid);
|
||||
@ -343,12 +343,12 @@ public class GATTClientTest implements PacketHandler {
|
||||
break;
|
||||
|
||||
case w4_acc_client_config_characteristic_result:
|
||||
if (packet instanceof GATTCharacteristicQueryResult){
|
||||
GATTCharacteristicQueryResult event = (GATTCharacteristicQueryResult) packet;
|
||||
if (packet instanceof GATTEventCharacteristicQueryResult){
|
||||
GATTEventCharacteristicQueryResult event = (GATTEventCharacteristicQueryResult) packet;
|
||||
configCharacteristic = event.getCharacteristic();
|
||||
System.out.println("ACC Client Config Characteristic found");
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
if (configCharacteristic == null) {
|
||||
System.out.println("No acc config chr found");
|
||||
break;
|
||||
@ -360,12 +360,12 @@ public class GATTClientTest implements PacketHandler {
|
||||
break;
|
||||
|
||||
case w4_acc_data:
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
System.out.println("Acc configured for notification");
|
||||
break;
|
||||
}
|
||||
|
||||
if (packet instanceof GATTNotification){
|
||||
if (packet instanceof GATTEventNotification){
|
||||
System.out.println("Acc Value");
|
||||
System.out.println(packet.toString());
|
||||
btstack.GAPDisconnect(testHandle);
|
||||
|
@ -12,8 +12,8 @@ import com.bluekitchen.btstack.Util;
|
||||
import com.bluekitchen.btstack.event.BTstackEventState;
|
||||
import com.bluekitchen.btstack.event.HCIEventDisconnectionComplete;
|
||||
import com.bluekitchen.btstack.event.RFCOMMEventOpenChannelComplete;
|
||||
import com.bluekitchen.btstack.event.SDPQueryComplete;
|
||||
import com.bluekitchen.btstack.event.SDPQueryRFCOMMService;
|
||||
import com.bluekitchen.btstack.event.SDPEventQueryComplete;
|
||||
import com.bluekitchen.btstack.event.SDPEventQueryRFCOMMService;
|
||||
|
||||
public class SPPClientTest implements PacketHandler {
|
||||
|
||||
@ -58,11 +58,11 @@ public class SPPClientTest implements PacketHandler {
|
||||
break;
|
||||
|
||||
case w4_query_result:
|
||||
if (packet instanceof SDPQueryRFCOMMService){
|
||||
SDPQueryRFCOMMService service = (SDPQueryRFCOMMService) packet;
|
||||
if (packet instanceof SDPEventQueryRFCOMMService){
|
||||
SDPEventQueryRFCOMMService service = (SDPEventQueryRFCOMMService) packet;
|
||||
services.add(service.getRFCOMMChannel());
|
||||
}
|
||||
if (packet instanceof SDPQueryComplete){
|
||||
if (packet instanceof SDPEventQueryComplete){
|
||||
for (Integer channel_nr : services){
|
||||
System.out.println("Found rfcomm channel nr: " + channel_nr);
|
||||
if (channel_nr == btIncomingChannelNr){
|
||||
|
@ -155,7 +155,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
||||
le_peripheral_todos |= SET_ADVERTISEMENT_ENABLED;
|
||||
break;
|
||||
|
||||
case GAP_LE_EVENT_ADVERTISING_REPORT: {
|
||||
case GAP_EVENT_ADVERTISING_REPORT: {
|
||||
if (bleAdvertismentCallback) {
|
||||
BLEAdvertisement advertisement(packet);
|
||||
(*bleAdvertismentCallback)(&advertisement);
|
||||
|
@ -15,12 +15,12 @@ import com.bluekitchen.btstack.Packet;
|
||||
import com.bluekitchen.btstack.PacketHandler;
|
||||
import com.bluekitchen.btstack.Util;
|
||||
import com.bluekitchen.btstack.event.BTstackEventState;
|
||||
import com.bluekitchen.btstack.event.GAPLEAdvertisingReport;
|
||||
import com.bluekitchen.btstack.event.GATTCharacteristicQueryResult;
|
||||
import com.bluekitchen.btstack.event.GATTCharacteristicValueQueryResult;
|
||||
import com.bluekitchen.btstack.event.GATTNotification;
|
||||
import com.bluekitchen.btstack.event.GATTQueryComplete;
|
||||
import com.bluekitchen.btstack.event.GATTServiceQueryResult;
|
||||
import com.bluekitchen.btstack.event.GAPEventAdvertisingReport;
|
||||
import com.bluekitchen.btstack.event.GATTEventCharacteristicQueryResult;
|
||||
import com.bluekitchen.btstack.event.GATTEventCharacteristicValueQueryResult;
|
||||
import com.bluekitchen.btstack.event.GATTEventNotification;
|
||||
import com.bluekitchen.btstack.event.GATTEventQueryComplete;
|
||||
import com.bluekitchen.btstack.event.GATTEventServiceQueryResult;
|
||||
import com.bluekitchen.btstack.event.HCIEventCommandComplete;
|
||||
import com.bluekitchen.btstack.event.HCIEventDisconnectionComplete;
|
||||
import com.bluekitchen.btstack.event.HCIEventLEConnectionComplete;
|
||||
@ -64,7 +64,7 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
private GATTCharacteristic batteryLevelCharacteristic;
|
||||
//private byte[] battery_service_uuid = new byte[] {0, 0, (byte)0x18, (byte)0x0F, 0, 0, (byte)0x10, 0, (byte)0x80, 0, 0, (byte)0x80, (byte)0x5f, (byte)0x9b, (byte)0x34, (byte)0xfb};
|
||||
private byte[] battery_level_chr_uuid = new byte[] {0, 0, (byte)0x2a, (byte)0x1b, 0, 0, (byte)0x10, 0, (byte)0x80, 0, 0, (byte)0x80, (byte)0x5f, (byte)0x9b, (byte)0x34, (byte)0xfb};
|
||||
GATTCharacteristicValueQueryResult battery;
|
||||
GATTEventCharacteristicValueQueryResult battery;
|
||||
private int batteryLevel = 0;
|
||||
private int counter;
|
||||
|
||||
@ -132,8 +132,8 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_scan_result:
|
||||
if (packet instanceof GAPLEAdvertisingReport){
|
||||
GAPLEAdvertisingReport report = (GAPLEAdvertisingReport) packet;
|
||||
if (packet instanceof GAPEventAdvertisingReport){
|
||||
GAPEventAdvertisingReport report = (GAPEventAdvertisingReport) packet;
|
||||
testAddrType = report.getAddressType();
|
||||
deviceAddr = report.getAddress();
|
||||
addMessage(String.format("Adv: type %d, addr %s", testAddrType, deviceAddr));
|
||||
@ -156,8 +156,8 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_services_complete:
|
||||
if (packet instanceof GATTServiceQueryResult){
|
||||
GATTServiceQueryResult event = (GATTServiceQueryResult) packet;
|
||||
if (packet instanceof GATTEventServiceQueryResult){
|
||||
GATTEventServiceQueryResult event = (GATTEventServiceQueryResult) packet;
|
||||
if (testService == null){
|
||||
addMessage(String.format("First service UUID %s", event.getService().getUUID()));
|
||||
testService = event.getService();
|
||||
@ -165,7 +165,7 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
Log.d(BTSTACK_TAG, "Service: " + event.getService());
|
||||
service_count++;
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
addMessage(String.format("Service query complete, total %d services", service_count));
|
||||
state = STATE.w4_characteristic_complete;
|
||||
btstack.GATTDiscoverCharacteristicsForService(connectionHandle, testService);
|
||||
@ -173,8 +173,8 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
break;
|
||||
|
||||
case w4_characteristic_complete:
|
||||
if (packet instanceof GATTCharacteristicQueryResult){
|
||||
GATTCharacteristicQueryResult event = (GATTCharacteristicQueryResult) packet;
|
||||
if (packet instanceof GATTEventCharacteristicQueryResult){
|
||||
GATTEventCharacteristicQueryResult event = (GATTEventCharacteristicQueryResult) packet;
|
||||
if (testCharacteristic == null){
|
||||
addMessage(String.format("First characteristic UUID %s", event.getCharacteristic().getUUID()));
|
||||
testCharacteristic = event.getCharacteristic();
|
||||
@ -182,7 +182,7 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
Log.d(BTSTACK_TAG, "Characteristic: " + event.getCharacteristic());
|
||||
characteristic_count++;
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
addMessage(String.format("Characteristic query complete, total %d characteristics", characteristic_count));
|
||||
if (characteristic_count > 0){
|
||||
state = STATE.w4_characteristic_read;
|
||||
@ -195,7 +195,7 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
break;
|
||||
|
||||
case w4_characteristic_read:
|
||||
if (packet instanceof GATTCharacteristicValueQueryResult){
|
||||
if (packet instanceof GATTEventCharacteristicValueQueryResult){
|
||||
addMessage("Read complete");
|
||||
Log.d(BTSTACK_TAG, packet.toString());
|
||||
state = STATE.w4_characteristic_write;
|
||||
@ -204,7 +204,7 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_characteristic_write:
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
addMessage("Write complete, disconnect now.");
|
||||
state = STATE.w4_disconnect;
|
||||
// btstack.GAPDisconnect(testHandle);
|
||||
@ -233,8 +233,8 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_scan_result:
|
||||
if (packet instanceof GAPLEAdvertisingReport){
|
||||
GAPLEAdvertisingReport report = (GAPLEAdvertisingReport) packet;
|
||||
if (packet instanceof GAPEventAdvertisingReport){
|
||||
GAPEventAdvertisingReport report = (GAPEventAdvertisingReport) packet;
|
||||
testAddrType = report.getAddressType();
|
||||
deviceAddr = report.getAddress();
|
||||
if (deviceAddr.toString().equalsIgnoreCase(sensor_tag_addr.toString())){
|
||||
@ -267,13 +267,13 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
case w4_acc_service_result:
|
||||
clearMessages();
|
||||
addMessage(String.format("w4_acc_service_result state"));
|
||||
if (packet instanceof GATTServiceQueryResult){
|
||||
GATTServiceQueryResult event = (GATTServiceQueryResult) packet;
|
||||
if (packet instanceof GATTEventServiceQueryResult){
|
||||
GATTEventServiceQueryResult event = (GATTEventServiceQueryResult) packet;
|
||||
addMessage(String.format("ACC service found %s", event.getService().getUUID()));
|
||||
accService = event.getService();
|
||||
break;
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
if (accService == null) {
|
||||
addMessage("No acc service found");
|
||||
break;
|
||||
@ -287,12 +287,12 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
break;
|
||||
|
||||
case w4_acc_enable_characteristic_result:
|
||||
if (packet instanceof GATTCharacteristicQueryResult){
|
||||
GATTCharacteristicQueryResult event = (GATTCharacteristicQueryResult) packet;
|
||||
if (packet instanceof GATTEventCharacteristicQueryResult){
|
||||
GATTEventCharacteristicQueryResult event = (GATTEventCharacteristicQueryResult) packet;
|
||||
enableCharacteristic = event.getCharacteristic();
|
||||
addMessage("Enable ACC Characteristic found ");
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
if (enableCharacteristic == null) {
|
||||
addMessage("No acc enable chr found");
|
||||
break;
|
||||
@ -303,7 +303,7 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_write_acc_enable_result:
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
addMessage("Acc enabled,searching for acc client config characteristic");
|
||||
byte [] uuid = new byte[16];
|
||||
Util.flipX(this.acc_chr_client_config_uuid, uuid);
|
||||
@ -313,12 +313,12 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
break;
|
||||
|
||||
case w4_acc_client_config_characteristic_result:
|
||||
if (packet instanceof GATTCharacteristicQueryResult){
|
||||
GATTCharacteristicQueryResult event = (GATTCharacteristicQueryResult) packet;
|
||||
if (packet instanceof GATTEventCharacteristicQueryResult){
|
||||
GATTEventCharacteristicQueryResult event = (GATTEventCharacteristicQueryResult) packet;
|
||||
configCharacteristic = event.getCharacteristic();
|
||||
addMessage("ACC Client Config Characteristic found");
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
if (configCharacteristic == null) {
|
||||
addMessage("No acc config chr found");
|
||||
break;
|
||||
@ -330,12 +330,12 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
break;
|
||||
|
||||
case w4_acc_data:
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
addMessage("Acc configured for notification");
|
||||
break;
|
||||
}
|
||||
|
||||
if (packet instanceof GATTNotification){
|
||||
if (packet instanceof GATTEventNotification){
|
||||
addTempMessage("Acc Value");
|
||||
Log.d(BTSTACK_TAG, packet.toString());
|
||||
//state = STATE.w4_btstack_working;
|
||||
@ -391,11 +391,11 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_scan_result:
|
||||
if (packet instanceof GAPLEAdvertisingReport){
|
||||
if (packet instanceof GAPEventAdvertisingReport){
|
||||
BD_ADDR sensor_tag_addr = new BD_ADDR("1C:BA:8C:20:C7:F6");
|
||||
//BD_ADDR pts_dongle = new BD_ADDR("00:1B:DC:07:32:EF");
|
||||
|
||||
GAPLEAdvertisingReport report = (GAPLEAdvertisingReport) packet;
|
||||
GAPEventAdvertisingReport report = (GAPEventAdvertisingReport) packet;
|
||||
BD_ADDR reportAddr = report.getAddress();
|
||||
if (reportAddr.toString().equalsIgnoreCase(sensor_tag_addr.toString())){
|
||||
testAddrType = report.getAddressType();
|
||||
@ -425,8 +425,8 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_services_complete:
|
||||
if (packet instanceof GATTServiceQueryResult){
|
||||
GATTServiceQueryResult event = (GATTServiceQueryResult) packet;
|
||||
if (packet instanceof GATTEventServiceQueryResult){
|
||||
GATTEventServiceQueryResult event = (GATTEventServiceQueryResult) packet;
|
||||
if (testService == null){
|
||||
addMessage(String.format("First service UUID %s", event.getService().getUUID()));
|
||||
testService = event.getService();
|
||||
@ -434,7 +434,7 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
Log.d(BTSTACK_TAG, "Service: " + event.getService());
|
||||
service_count++;
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
addMessage(String.format("Service query complete, total %d services", service_count));
|
||||
state = STATE.w4_disconnect;
|
||||
test_run_count++;
|
||||
@ -496,9 +496,9 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_scan_result:
|
||||
if (packet instanceof GAPLEAdvertisingReport){
|
||||
if (packet instanceof GAPEventAdvertisingReport){
|
||||
clearMessages();
|
||||
GAPLEAdvertisingReport report = (GAPLEAdvertisingReport) packet;
|
||||
GAPEventAdvertisingReport report = (GAPEventAdvertisingReport) packet;
|
||||
testAddrType = report.getAddressType();
|
||||
deviceAddr = report.getAddress();
|
||||
addMessage(String.format("Adv: type %d, addr %s", testAddrType, deviceAddr));
|
||||
@ -582,10 +582,10 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_scan_result:
|
||||
if (packet instanceof GAPLEAdvertisingReport){
|
||||
if (packet instanceof GAPEventAdvertisingReport){
|
||||
// Advertisement received. Connect to the found BT address.
|
||||
clearMessages();
|
||||
GAPLEAdvertisingReport report = (GAPLEAdvertisingReport) packet;
|
||||
GAPEventAdvertisingReport report = (GAPEventAdvertisingReport) packet;
|
||||
testAddrType = report.getAddressType();
|
||||
deviceAddr = report.getAddress();
|
||||
addMessage(String.format("Adv: type %d, addr %s\ndata: %s \n Stop scan, initiate connect.", testAddrType, deviceAddr, Util.asHexdump(report.getData())));
|
||||
@ -615,14 +615,14 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
break;
|
||||
|
||||
case w4_services_complete:
|
||||
if (packet instanceof GATTServiceQueryResult){
|
||||
// Store battery service. Wait for GATTQueryComplete event to send next GATT command.
|
||||
GATTServiceQueryResult event = (GATTServiceQueryResult) packet;
|
||||
if (packet instanceof GATTEventServiceQueryResult){
|
||||
// Store battery service. Wait for GATTEventQueryComplete event to send next GATT command.
|
||||
GATTEventServiceQueryResult event = (GATTEventServiceQueryResult) packet;
|
||||
addMessage(String.format("Battery service found %s", event.getService().getUUID()));
|
||||
batteryService = event.getService();
|
||||
break;
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
// Check if battery service is found.
|
||||
if (batteryService == null) {
|
||||
addMessage("No battery service found, restart scanning.");
|
||||
@ -636,15 +636,15 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
}
|
||||
break;
|
||||
case w4_characteristic_complete:
|
||||
if (packet instanceof GATTCharacteristicQueryResult){
|
||||
// Store battery level characteristic. Wait for GATTQueryComplete event to send next GATT command.
|
||||
GATTCharacteristicQueryResult event = (GATTCharacteristicQueryResult) packet;
|
||||
if (packet instanceof GATTEventCharacteristicQueryResult){
|
||||
// Store battery level characteristic. Wait for GATTEventQueryComplete event to send next GATT command.
|
||||
GATTEventCharacteristicQueryResult event = (GATTEventCharacteristicQueryResult) packet;
|
||||
batteryLevelCharacteristic = event.getCharacteristic();
|
||||
addMessage("Battery level characteristic found.");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(packet instanceof GATTQueryComplete)) break;
|
||||
if (!(packet instanceof GATTEventQueryComplete)) break;
|
||||
if (batteryLevelCharacteristic == null) {
|
||||
addMessage("No battery level characteristic found");
|
||||
break;
|
||||
@ -668,8 +668,8 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
|
||||
case battery_data:
|
||||
clearMessages();
|
||||
if (packet instanceof GATTCharacteristicValueQueryResult){
|
||||
GATTCharacteristicValueQueryResult battery = (GATTCharacteristicValueQueryResult) packet;
|
||||
if (packet instanceof GATTEventCharacteristicValueQueryResult){
|
||||
GATTEventCharacteristicValueQueryResult battery = (GATTEventCharacteristicValueQueryResult) packet;
|
||||
|
||||
if (battery.getValueLength() < 1) break;
|
||||
this.batteryLevel = battery.getValue()[0];
|
||||
@ -678,8 +678,8 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
break;
|
||||
|
||||
}
|
||||
if (packet instanceof GATTQueryComplete){
|
||||
GATTQueryComplete event = (GATTQueryComplete) packet;
|
||||
if (packet instanceof GATTEventQueryComplete){
|
||||
GATTEventQueryComplete event = (GATTEventQueryComplete) packet;
|
||||
addMessage(String.format("Counter %d, battery level: %d", counter, batteryLevel) + "%");
|
||||
if (event.getStatus() != 0){
|
||||
addMessage("Battery data could not be read - status 0x%02x. Restart scanning." + String.valueOf(event.getStatus()));
|
||||
|
@ -25,8 +25,8 @@ import com.bluekitchen.btstack.event.HCIEventInquiryComplete;
|
||||
import com.bluekitchen.btstack.event.HCIEventInquiryResultWithRssi;
|
||||
import com.bluekitchen.btstack.event.HCIEventRemoteNameRequestComplete;
|
||||
import com.bluekitchen.btstack.event.RFCOMMEventOpenChannelComplete;
|
||||
import com.bluekitchen.btstack.event.SDPQueryComplete;
|
||||
import com.bluekitchen.btstack.event.SDPQueryRFCOMMService;
|
||||
import com.bluekitchen.btstack.event.SDPEventQueryComplete;
|
||||
import com.bluekitchen.btstack.event.SDPEventQueryRFCOMMService;
|
||||
|
||||
|
||||
public class MainActivity extends Activity implements PacketHandler {
|
||||
@ -149,7 +149,7 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
private int mtu = 0;
|
||||
private BD_ADDR remoteBDAddr;
|
||||
|
||||
List<SDPQueryRFCOMMService> services = new ArrayList<SDPQueryRFCOMMService>(10);
|
||||
List<SDPEventQueryRFCOMMService> services = new ArrayList<SDPEventQueryRFCOMMService>(10);
|
||||
List<RemoteDevice> devices = new ArrayList<RemoteDevice>(10);
|
||||
|
||||
private int counter;
|
||||
@ -282,15 +282,15 @@ public class MainActivity extends Activity implements PacketHandler {
|
||||
break;
|
||||
|
||||
case w4_sdp_query_result:
|
||||
if (packet instanceof SDPQueryRFCOMMService){
|
||||
SDPQueryRFCOMMService service = (SDPQueryRFCOMMService) packet;
|
||||
if (packet instanceof SDPEventQueryRFCOMMService){
|
||||
SDPEventQueryRFCOMMService service = (SDPEventQueryRFCOMMService) packet;
|
||||
services.add(service);
|
||||
addMessage(String.format("Found \"%s\", channel %d", service.getName(), service.getRFCOMMChannel()));
|
||||
}
|
||||
if (packet instanceof SDPQueryComplete){
|
||||
if (packet instanceof SDPEventQueryComplete){
|
||||
// find service with "SPP" prefix
|
||||
SDPQueryRFCOMMService selectedService = null;
|
||||
for (SDPQueryRFCOMMService service : services){
|
||||
SDPEventQueryRFCOMMService selectedService = null;
|
||||
for (SDPEventQueryRFCOMMService service : services){
|
||||
if (service.getName().startsWith(RFCOMM_SERVICE_PREFIX)){
|
||||
selectedService = service;
|
||||
break;
|
||||
|
@ -154,10 +154,10 @@ typedef uint8_t sm_key_t[16];
|
||||
// get state: @returns HCI_STATE
|
||||
#define BTSTACK_GET_STATE 0x01
|
||||
|
||||
// set power mode: @param HCI_POWER_MODE
|
||||
// set power mode: param HCI_POWER_MODE
|
||||
#define BTSTACK_SET_POWER_MODE 0x02
|
||||
|
||||
// set capture mode: @param on
|
||||
// set capture mode: param on
|
||||
#define BTSTACK_SET_ACL_CAPTURE_MODE 0x03
|
||||
|
||||
// get BTstack version
|
||||
@ -175,25 +175,25 @@ typedef uint8_t sm_key_t[16];
|
||||
// set global Bluetooth state
|
||||
#define BTSTACK_SET_BLUETOOTH_ENABLED 0x08
|
||||
|
||||
// create l2cap channel: @param bd_addr(48), psm (16)
|
||||
// create l2cap channel: param bd_addr(48), psm (16)
|
||||
#define L2CAP_CREATE_CHANNEL 0x20
|
||||
|
||||
// disconnect l2cap disconnect, @param channel(16), reason(8)
|
||||
// disconnect l2cap disconnect, param channel(16), reason(8)
|
||||
#define L2CAP_DISCONNECT 0x21
|
||||
|
||||
// register l2cap service: @param psm(16), mtu (16)
|
||||
// register l2cap service: param psm(16), mtu (16)
|
||||
#define L2CAP_REGISTER_SERVICE 0x22
|
||||
|
||||
// unregister l2cap disconnect, @param psm(16)
|
||||
// unregister l2cap disconnect, param psm(16)
|
||||
#define L2CAP_UNREGISTER_SERVICE 0x23
|
||||
|
||||
// accept connection @param bd_addr(48), dest cid (16)
|
||||
// accept connection param bd_addr(48), dest cid (16)
|
||||
#define L2CAP_ACCEPT_CONNECTION 0x24
|
||||
|
||||
// decline l2cap disconnect,@param bd_addr(48), dest cid (16), reason(8)
|
||||
// decline l2cap disconnect,param bd_addr(48), dest cid (16), reason(8)
|
||||
#define L2CAP_DECLINE_CONNECTION 0x25
|
||||
|
||||
// create l2cap channel: @param bd_addr(48), psm (16), mtu (16)
|
||||
// create l2cap channel: param bd_addr(48), psm (16), mtu (16)
|
||||
#define L2CAP_CREATE_CHANNEL_MTU 0x26
|
||||
|
||||
// register SDP Service Record: service record (size)
|
||||
@ -459,8 +459,8 @@ typedef uint8_t sm_key_t[16];
|
||||
|
||||
/**
|
||||
* TODO: format for variable data 2?
|
||||
* @param rfcomm_cid
|
||||
* @param rpn_data
|
||||
* param rfcomm_cid
|
||||
* param rpn_data
|
||||
*/
|
||||
#define RFCOMM_EVENT_PORT_CONFIGURATION 0x88
|
||||
|
||||
@ -750,7 +750,7 @@ typedef uint8_t sm_key_t[16];
|
||||
* @param data_length
|
||||
* @param data
|
||||
*/
|
||||
#define GAP_LE_EVENT_ADVERTISING_REPORT 0xE2
|
||||
#define GAP_EVENT_ADVERTISING_REPORT 0xE2
|
||||
|
||||
|
||||
// Meta Events, see below for sub events
|
||||
|
@ -714,88 +714,6 @@ static inline hci_con_handle_t hci_event_encryption_key_refresh_complete_get_han
|
||||
return little_endian_read_16(event, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field status from event hci_subevent_le_connection_complete
|
||||
* @param event packet
|
||||
* @return status
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hci_subevent_le_connection_complete_get_status(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
/**
|
||||
* @brief Get field connection_handle from event hci_subevent_le_connection_complete
|
||||
* @param event packet
|
||||
* @return connection_handle
|
||||
* @note: btstack_type H
|
||||
*/
|
||||
static inline hci_con_handle_t hci_subevent_le_connection_complete_get_connection_handle(const uint8_t * event){
|
||||
return little_endian_read_16(event, 4);
|
||||
}
|
||||
/**
|
||||
* @brief Get field role from event hci_subevent_le_connection_complete
|
||||
* @param event packet
|
||||
* @return role
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hci_subevent_le_connection_complete_get_role(const uint8_t * event){
|
||||
return event[6];
|
||||
}
|
||||
/**
|
||||
* @brief Get field peer_address_type from event hci_subevent_le_connection_complete
|
||||
* @param event packet
|
||||
* @return peer_address_type
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hci_subevent_le_connection_complete_get_peer_address_type(const uint8_t * event){
|
||||
return event[7];
|
||||
}
|
||||
/**
|
||||
* @brief Get field peer_address from event hci_subevent_le_connection_complete
|
||||
* @param event packet
|
||||
* @param Pointer to storage for peer_address
|
||||
* @note: btstack_type B
|
||||
*/
|
||||
static inline void hci_subevent_le_connection_complete_get_peer_address(const uint8_t * event, bd_addr_t peer_address){
|
||||
reverse_bd_addr(&event[8], peer_address);
|
||||
}
|
||||
/**
|
||||
* @brief Get field conn_interval from event hci_subevent_le_connection_complete
|
||||
* @param event packet
|
||||
* @return conn_interval
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t hci_subevent_le_connection_complete_get_conn_interval(const uint8_t * event){
|
||||
return little_endian_read_16(event, 14);
|
||||
}
|
||||
/**
|
||||
* @brief Get field conn_latency from event hci_subevent_le_connection_complete
|
||||
* @param event packet
|
||||
* @return conn_latency
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t hci_subevent_le_connection_complete_get_conn_latency(const uint8_t * event){
|
||||
return little_endian_read_16(event, 16);
|
||||
}
|
||||
/**
|
||||
* @brief Get field supervision_timeout from event hci_subevent_le_connection_complete
|
||||
* @param event packet
|
||||
* @return supervision_timeout
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t hci_subevent_le_connection_complete_get_supervision_timeout(const uint8_t * event){
|
||||
return little_endian_read_16(event, 18);
|
||||
}
|
||||
/**
|
||||
* @brief Get field master_clock_accuracy from event hci_subevent_le_connection_complete
|
||||
* @param event packet
|
||||
* @return master_clock_accuracy
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hci_subevent_le_connection_complete_get_master_clock_accuracy(const uint8_t * event){
|
||||
return event[20];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field state from event btstack_event_state
|
||||
* @param event packet
|
||||
@ -2143,60 +2061,142 @@ static inline uint8_t sm_event_authorization_result_get_authorization_result(con
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get field advertising_event_type from event gap_le_event_advertising_report
|
||||
* @brief Get field advertising_event_type from event gap_event_advertising_report
|
||||
* @param event packet
|
||||
* @return advertising_event_type
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t gap_le_event_advertising_report_get_advertising_event_type(const uint8_t * event){
|
||||
static inline uint8_t gap_event_advertising_report_get_advertising_event_type(const uint8_t * event){
|
||||
return event[2];
|
||||
}
|
||||
/**
|
||||
* @brief Get field address_type from event gap_le_event_advertising_report
|
||||
* @brief Get field address_type from event gap_event_advertising_report
|
||||
* @param event packet
|
||||
* @return address_type
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t gap_le_event_advertising_report_get_address_type(const uint8_t * event){
|
||||
static inline uint8_t gap_event_advertising_report_get_address_type(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
/**
|
||||
* @brief Get field address from event gap_le_event_advertising_report
|
||||
* @brief Get field address from event gap_event_advertising_report
|
||||
* @param event packet
|
||||
* @param Pointer to storage for address
|
||||
* @note: btstack_type B
|
||||
*/
|
||||
static inline void gap_le_event_advertising_report_get_address(const uint8_t * event, bd_addr_t address){
|
||||
static inline void gap_event_advertising_report_get_address(const uint8_t * event, bd_addr_t address){
|
||||
reverse_bd_addr(&event[4], address);
|
||||
}
|
||||
/**
|
||||
* @brief Get field rssi from event gap_le_event_advertising_report
|
||||
* @brief Get field rssi from event gap_event_advertising_report
|
||||
* @param event packet
|
||||
* @return rssi
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t gap_le_event_advertising_report_get_rssi(const uint8_t * event){
|
||||
static inline uint8_t gap_event_advertising_report_get_rssi(const uint8_t * event){
|
||||
return event[10];
|
||||
}
|
||||
/**
|
||||
* @brief Get field data_length from event gap_le_event_advertising_report
|
||||
* @brief Get field data_length from event gap_event_advertising_report
|
||||
* @param event packet
|
||||
* @return data_length
|
||||
* @note: btstack_type J
|
||||
*/
|
||||
static inline int gap_le_event_advertising_report_get_data_length(const uint8_t * event){
|
||||
static inline int gap_event_advertising_report_get_data_length(const uint8_t * event){
|
||||
return event[11];
|
||||
}
|
||||
/**
|
||||
* @brief Get field data from event gap_le_event_advertising_report
|
||||
* @brief Get field data from event gap_event_advertising_report
|
||||
* @param event packet
|
||||
* @return data
|
||||
* @note: btstack_type V
|
||||
*/
|
||||
static inline const uint8_t * gap_le_event_advertising_report_get_data(const uint8_t * event){
|
||||
static inline const uint8_t * gap_event_advertising_report_get_data(const uint8_t * event){
|
||||
return &event[12];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field status from event hci_subevent_le_connection_complete
|
||||
* @param event packet
|
||||
* @return status
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hci_subevent_le_connection_complete_get_status(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
/**
|
||||
* @brief Get field connection_handle from event hci_subevent_le_connection_complete
|
||||
* @param event packet
|
||||
* @return connection_handle
|
||||
* @note: btstack_type H
|
||||
*/
|
||||
static inline hci_con_handle_t hci_subevent_le_connection_complete_get_connection_handle(const uint8_t * event){
|
||||
return little_endian_read_16(event, 4);
|
||||
}
|
||||
/**
|
||||
* @brief Get field role from event hci_subevent_le_connection_complete
|
||||
* @param event packet
|
||||
* @return role
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hci_subevent_le_connection_complete_get_role(const uint8_t * event){
|
||||
return event[6];
|
||||
}
|
||||
/**
|
||||
* @brief Get field peer_address_type from event hci_subevent_le_connection_complete
|
||||
* @param event packet
|
||||
* @return peer_address_type
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hci_subevent_le_connection_complete_get_peer_address_type(const uint8_t * event){
|
||||
return event[7];
|
||||
}
|
||||
/**
|
||||
* @brief Get field peer_address from event hci_subevent_le_connection_complete
|
||||
* @param event packet
|
||||
* @param Pointer to storage for peer_address
|
||||
* @note: btstack_type B
|
||||
*/
|
||||
static inline void hci_subevent_le_connection_complete_get_peer_address(const uint8_t * event, bd_addr_t peer_address){
|
||||
reverse_bd_addr(&event[8], peer_address);
|
||||
}
|
||||
/**
|
||||
* @brief Get field conn_interval from event hci_subevent_le_connection_complete
|
||||
* @param event packet
|
||||
* @return conn_interval
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t hci_subevent_le_connection_complete_get_conn_interval(const uint8_t * event){
|
||||
return little_endian_read_16(event, 14);
|
||||
}
|
||||
/**
|
||||
* @brief Get field conn_latency from event hci_subevent_le_connection_complete
|
||||
* @param event packet
|
||||
* @return conn_latency
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t hci_subevent_le_connection_complete_get_conn_latency(const uint8_t * event){
|
||||
return little_endian_read_16(event, 16);
|
||||
}
|
||||
/**
|
||||
* @brief Get field supervision_timeout from event hci_subevent_le_connection_complete
|
||||
* @param event packet
|
||||
* @return supervision_timeout
|
||||
* @note: btstack_type 2
|
||||
*/
|
||||
static inline uint16_t hci_subevent_le_connection_complete_get_supervision_timeout(const uint8_t * event){
|
||||
return little_endian_read_16(event, 18);
|
||||
}
|
||||
/**
|
||||
* @brief Get field master_clock_accuracy from event hci_subevent_le_connection_complete
|
||||
* @param event packet
|
||||
* @return master_clock_accuracy
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hci_subevent_le_connection_complete_get_master_clock_accuracy(const uint8_t * event){
|
||||
return event[20];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field status from event hsp_subevent_audio_connection_complete
|
||||
* @param event packet
|
||||
@ -2206,15 +2206,6 @@ static inline const uint8_t * gap_le_event_advertising_report_get_data(const uin
|
||||
static inline uint8_t hsp_subevent_audio_connection_complete_get_status(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
/**
|
||||
* @brief Get field handle from event hsp_subevent_audio_connection_complete
|
||||
* @param event packet
|
||||
* @return handle
|
||||
* @note: btstack_type H
|
||||
*/
|
||||
static inline hci_con_handle_t hsp_subevent_audio_connection_complete_get_handle(const uint8_t * event){
|
||||
return little_endian_read_16(event, 4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field status from event hsp_subevent_audio_disconnection_complete
|
||||
@ -2285,6 +2276,320 @@ static inline const uint8_t * hsp_subevent_ag_indication_get_value(const uint8_t
|
||||
return &event[4];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field status from event hfp_subevent_service_level_connection_established
|
||||
* @param event packet
|
||||
* @return status
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_service_level_connection_established_get_status(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get field status from event hfp_subevent_audio_connection_established
|
||||
* @param event packet
|
||||
* @return status
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_audio_connection_established_get_status(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get field status from event hfp_subevent_complete
|
||||
* @param event packet
|
||||
* @return status
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_complete_get_status(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field indicator_index from event hfp_subevent_ag_indicator_status_changed
|
||||
* @param event packet
|
||||
* @return indicator_index
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_ag_indicator_status_changed_get_indicator_index(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
/**
|
||||
* @brief Get field indicator_status from event hfp_subevent_ag_indicator_status_changed
|
||||
* @param event packet
|
||||
* @return indicator_status
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_ag_indicator_status_changed_get_indicator_status(const uint8_t * event){
|
||||
return event[4];
|
||||
}
|
||||
/**
|
||||
* @brief Get field indicator_name from event hfp_subevent_ag_indicator_status_changed
|
||||
* @param event packet
|
||||
* @return indicator_name
|
||||
* @note: btstack_type T
|
||||
*/
|
||||
static inline const char * hfp_subevent_ag_indicator_status_changed_get_indicator_name(const uint8_t * event){
|
||||
return (const char *) &event[5];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field network_operator_mode from event hfp_subevent_network_operator_changed
|
||||
* @param event packet
|
||||
* @return network_operator_mode
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_network_operator_changed_get_network_operator_mode(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
/**
|
||||
* @brief Get field network_operator_format from event hfp_subevent_network_operator_changed
|
||||
* @param event packet
|
||||
* @return network_operator_format
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_network_operator_changed_get_network_operator_format(const uint8_t * event){
|
||||
return event[4];
|
||||
}
|
||||
/**
|
||||
* @brief Get field network_operator_name from event hfp_subevent_network_operator_changed
|
||||
* @param event packet
|
||||
* @return network_operator_name
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_network_operator_changed_get_network_operator_name(const uint8_t * event){
|
||||
return event[5];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field error from event hfp_subevent_extended_audio_gateway_error
|
||||
* @param event packet
|
||||
* @return error
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_extended_audio_gateway_error_get_error(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field status from event hfp_subevent_codecs_connection_complete
|
||||
* @param event packet
|
||||
* @return status
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_codecs_connection_complete_get_status(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get field number from event hfp_subevent_place_call_with_number
|
||||
* @param event packet
|
||||
* @return number
|
||||
* @note: btstack_type T
|
||||
*/
|
||||
static inline const char * hfp_subevent_place_call_with_number_get_number(const uint8_t * event){
|
||||
return (const char *) &event[3];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get field number from event hfp_subevent_number_for_voice_tag
|
||||
* @param event packet
|
||||
* @return number
|
||||
* @note: btstack_type T
|
||||
*/
|
||||
static inline const char * hfp_subevent_number_for_voice_tag_get_number(const uint8_t * event){
|
||||
return (const char *) &event[3];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field dtmf from event hfp_subevent_transmit_dtmf_codes
|
||||
* @param event packet
|
||||
* @return dtmf
|
||||
* @note: btstack_type T
|
||||
*/
|
||||
static inline const char * hfp_subevent_transmit_dtmf_codes_get_dtmf(const uint8_t * event){
|
||||
return (const char *) &event[3];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get field status from event hfp_subevent_speaker_volume
|
||||
* @param event packet
|
||||
* @return status
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_speaker_volume_get_status(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
/**
|
||||
* @brief Get field gain from event hfp_subevent_speaker_volume
|
||||
* @param event packet
|
||||
* @return gain
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_speaker_volume_get_gain(const uint8_t * event){
|
||||
return event[4];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field status from event hfp_subevent_microphone_volume
|
||||
* @param event packet
|
||||
* @return status
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_microphone_volume_get_status(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
/**
|
||||
* @brief Get field gain from event hfp_subevent_microphone_volume
|
||||
* @param event packet
|
||||
* @return gain
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_microphone_volume_get_gain(const uint8_t * event){
|
||||
return event[4];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field type from event hfp_subevent_call_waiting_notification
|
||||
* @param event packet
|
||||
* @return type
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_call_waiting_notification_get_type(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
/**
|
||||
* @brief Get field number from event hfp_subevent_call_waiting_notification
|
||||
* @param event packet
|
||||
* @return number
|
||||
* @note: btstack_type T
|
||||
*/
|
||||
static inline const char * hfp_subevent_call_waiting_notification_get_number(const uint8_t * event){
|
||||
return (const char *) &event[4];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field type from event hfp_subevent_calling_line_indetification_notification
|
||||
* @param event packet
|
||||
* @return type
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_calling_line_indetification_notification_get_type(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
/**
|
||||
* @brief Get field number from event hfp_subevent_calling_line_indetification_notification
|
||||
* @param event packet
|
||||
* @return number
|
||||
* @note: btstack_type T
|
||||
*/
|
||||
static inline const char * hfp_subevent_calling_line_indetification_notification_get_number(const uint8_t * event){
|
||||
return (const char *) &event[4];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field clcc_idx from event hfp_subevent_enhanced_call_status
|
||||
* @param event packet
|
||||
* @return clcc_idx
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_enhanced_call_status_get_clcc_idx(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
/**
|
||||
* @brief Get field clcc_dir from event hfp_subevent_enhanced_call_status
|
||||
* @param event packet
|
||||
* @return clcc_dir
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_enhanced_call_status_get_clcc_dir(const uint8_t * event){
|
||||
return event[4];
|
||||
}
|
||||
/**
|
||||
* @brief Get field clcc_status from event hfp_subevent_enhanced_call_status
|
||||
* @param event packet
|
||||
* @return clcc_status
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_enhanced_call_status_get_clcc_status(const uint8_t * event){
|
||||
return event[5];
|
||||
}
|
||||
/**
|
||||
* @brief Get field clcc_mpty from event hfp_subevent_enhanced_call_status
|
||||
* @param event packet
|
||||
* @return clcc_mpty
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_enhanced_call_status_get_clcc_mpty(const uint8_t * event){
|
||||
return event[6];
|
||||
}
|
||||
/**
|
||||
* @brief Get field bnip_type from event hfp_subevent_enhanced_call_status
|
||||
* @param event packet
|
||||
* @return bnip_type
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_enhanced_call_status_get_bnip_type(const uint8_t * event){
|
||||
return event[7];
|
||||
}
|
||||
/**
|
||||
* @brief Get field bnip_number from event hfp_subevent_enhanced_call_status
|
||||
* @param event packet
|
||||
* @return bnip_number
|
||||
* @note: btstack_type T
|
||||
*/
|
||||
static inline const char * hfp_subevent_enhanced_call_status_get_bnip_number(const uint8_t * event){
|
||||
return (const char *) &event[8];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field status from event hfp_subevent_subscriber_number_information
|
||||
* @param event packet
|
||||
* @return status
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_subscriber_number_information_get_status(const uint8_t * event){
|
||||
return event[3];
|
||||
}
|
||||
/**
|
||||
* @brief Get field bnip_type from event hfp_subevent_subscriber_number_information
|
||||
* @param event packet
|
||||
* @return bnip_type
|
||||
* @note: btstack_type 1
|
||||
*/
|
||||
static inline uint8_t hfp_subevent_subscriber_number_information_get_bnip_type(const uint8_t * event){
|
||||
return event[4];
|
||||
}
|
||||
/**
|
||||
* @brief Get field bnip_number from event hfp_subevent_subscriber_number_information
|
||||
* @param event packet
|
||||
* @return bnip_number
|
||||
* @note: btstack_type T
|
||||
*/
|
||||
static inline const char * hfp_subevent_subscriber_number_information_get_bnip_number(const uint8_t * event){
|
||||
return (const char *) &event[5];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get field value from event hfp_subevent_response_and_hold_status
|
||||
* @param event packet
|
||||
* @return value
|
||||
* @note: btstack_type T
|
||||
*/
|
||||
static inline const char * hfp_subevent_response_and_hold_status_get_value(const uint8_t * event){
|
||||
return (const char *) &event[3];
|
||||
}
|
||||
|
||||
#ifdef ENABLE_BLE
|
||||
/**
|
||||
* @brief Get field handle from event ancs_subevent_client_connected
|
||||
|
@ -838,7 +838,7 @@ void le_handle_advertisement_report(uint8_t *packet, int size){
|
||||
uint8_t data_length = packet[offset + 8];
|
||||
uint8_t event_size = 10 + data_length;
|
||||
int pos = 0;
|
||||
event[pos++] = GAP_LE_EVENT_ADVERTISING_REPORT;
|
||||
event[pos++] = GAP_EVENT_ADVERTISING_REPORT;
|
||||
event[pos++] = event_size;
|
||||
memcpy(&event[pos], &packet[offset], 1+1+6); // event type + address type + address
|
||||
offset += 8;
|
||||
|
@ -52,7 +52,7 @@ static void handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *pac
|
||||
gap_start_scan();
|
||||
break;
|
||||
|
||||
case GAP_LE_EVENT_ADVERTISING_REPORT:{
|
||||
case GAP_EVENT_ADVERTISING_REPORT:{
|
||||
advertisement_received = 1;
|
||||
memcpy(advertisement_packet, packet, size);
|
||||
|
||||
|
@ -382,7 +382,7 @@ static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *
|
||||
sm_authorization_grant(little_endian_read_16(packet, 2));
|
||||
break;
|
||||
|
||||
case GAP_LE_EVENT_ADVERTISING_REPORT:
|
||||
case GAP_EVENT_ADVERTISING_REPORT:
|
||||
handle_advertising_event(packet, size);
|
||||
break;
|
||||
|
||||
|
@ -27,7 +27,7 @@ def assert_dir(path):
|
||||
def cap(x):
|
||||
if x.lower() == 'btstack':
|
||||
return 'BTstack'
|
||||
acronyms = ['GAP', 'GATT', 'HCI', 'L2CAP', 'LE', 'RFCOMM', 'SM', 'SDP', 'UUID16', 'UUID128', 'HSP', 'HFP', 'ANCS']
|
||||
acronyms = ['ATT', 'GAP', 'GATT', 'HCI', 'L2CAP', 'LE', 'RFCOMM', 'SM', 'SDP', 'UUID16', 'UUID128', 'HSP', 'HFP', 'ANCS']
|
||||
if x.upper() in acronyms:
|
||||
return x.upper()
|
||||
return x.capitalize()
|
||||
|
@ -30,7 +30,7 @@
|
||||
-e 's/SM_EVENT_AUTHORIZATION_RESULT/SM_EVENT_AUTHORIZATION_RESULT/g'
|
||||
-e 's/GAP_EVENT_SECURITY_LEVEL/GAP_EVENT_SECURITY_LEVEL/g'
|
||||
-e 's/GAP_EVENT_DEDICATED_BONDING_COMPLETED/GAP_EVENT_DEDICATED_BONDING_COMPLETED/g'
|
||||
-e 's/GAP_LE_EVENT_ADVERTISING_REPORT/GAP_LE_EVENT_ADVERTISING_REPORT/g'
|
||||
-e 's/GAP_EVENT_ADVERTISING_REPORT/GAP_EVENT_ADVERTISING_REPORT/g'
|
||||
-e 's/ANCS_EVENT_CLIENT_CONNECTED/ANCS_EVENT_CLIENT_CONNECTED/g'
|
||||
-e 's/ANCS_EVENT_CLIENT_NOTIFICATION/ANCS_EVENT_CLIENT_NOTIFICATION/g'
|
||||
-e 's/ANCS_EVENT_CLIENT_DISCONNECTED/ANCS_EVENT_CLIENT_DISCONNECTED/g'
|
||||
|
@ -314,14 +314,25 @@ def create_event(event_name, format, args):
|
||||
to_string_method = java_event_to_string.format(event_name, to_string_args)
|
||||
fout.write(java_event_template.format(package, event_name, getters, to_string_method))
|
||||
|
||||
def event_supported(event_name):
|
||||
parts = event_name.split('_')
|
||||
if parts[0] in ['ATT', 'BTSTACK', 'DAEMON', 'L2CAP', 'RFCOMM', 'SDP', 'GATT', 'GAP', 'HCI', 'SM']:
|
||||
return True
|
||||
|
||||
def class_name_for_event(event_name):
|
||||
return parser.camel_case(event_name.replace('SUBEVENT','EVENT'))
|
||||
|
||||
def create_events(events):
|
||||
global gen_path
|
||||
gen_path_events = gen_path + '/event'
|
||||
parser.assert_dir(gen_path_events)
|
||||
|
||||
for event_type, event_name, format, args in events:
|
||||
event_name = parser.camel_case(event_name)
|
||||
create_event(event_name, format, args)
|
||||
if not event_supported(event_name):
|
||||
continue
|
||||
class_name = class_name_for_event(event_name)
|
||||
create_event(class_name, format, args)
|
||||
|
||||
|
||||
def create_event_factory(events, subevents, defines):
|
||||
global gen_path
|
||||
@ -337,12 +348,11 @@ def create_event_factory(events, subevents, defines):
|
||||
cases += java_event_factory_event.format(event_type, event_name)
|
||||
subcases = ''
|
||||
for event_type, event_name, format, args in subevents:
|
||||
# replace subevent with event as we just enumerate all events
|
||||
event_name = parser.camel_case(event_name.replace('SUBEVENT','EVENT'))
|
||||
# subevents besides le_events are not handled yet
|
||||
if not event_name.startswith("HCIEvent"):
|
||||
if not event_supported(event_name):
|
||||
continue
|
||||
subcases += java_event_factory_subevent.format(event_type, event_name)
|
||||
class_name = class_name_for_event(event_name)
|
||||
print class_name
|
||||
subcases += java_event_factory_subevent.format(event_type, class_name)
|
||||
|
||||
with open(outfile, 'wt') as fout:
|
||||
defines_text = java_defines_string(defines)
|
||||
|
Loading…
x
Reference in New Issue
Block a user