diff options
-rw-r--r-- | examples/direct_bt_scanner10/dbt_scanner10.cpp | 6 | ||||
-rw-r--r-- | examples/java/DBTScanner10.java | 15 |
2 files changed, 15 insertions, 6 deletions
diff --git a/examples/direct_bt_scanner10/dbt_scanner10.cpp b/examples/direct_bt_scanner10/dbt_scanner10.cpp index 5b69f8d6..bc5a4ff2 100644 --- a/examples/direct_bt_scanner10/dbt_scanner10.cpp +++ b/examples/direct_bt_scanner10/dbt_scanner10.cpp @@ -619,10 +619,10 @@ static void connectDiscoveredDevice(std::shared_ptr<BTDevice> device) { if( nullptr != sec ) { if( sec->isSecurityAutoEnabled() ) { bool res = device->setConnSecurityAuto( sec->getSecurityAutoIOCap() ); - fprintf(stderr, "****** Connecting Device: Using SecurityDetail.AutoIOCap %s, set OK %d\n", sec->toString().c_str(), res); + fprintf(stderr, "****** Connecting Device: Using SecurityDetail.SEC AUTO %s, set OK %d\n", sec->toString().c_str(), res); } else { bool res = device->setConnSecurityBest( sec->getSecLevel(), sec->getIOCap() ); - fprintf(stderr, "****** Connecting Device: Using SecurityDetail.IOCap %s, set OK %d\n", sec->toString().c_str(), res); + fprintf(stderr, "****** Connecting Device: Using SecurityDetail.Level+IOCap %s, set OK %d\n", sec->toString().c_str(), res); } } else { fprintf(stderr, "****** Connecting Device: No SecurityDetail for %s\n", device->getAddressAndType().toString().c_str()); @@ -1032,7 +1032,7 @@ int main(int argc, char *argv[]) const BDAddressAndType macAndType(EUI48(mac), getBDAddressType(atype)); MyBTSecurityDetail* sec = MyBTSecurityDetail::getOrCreate(macAndType); sec->io_cap_auto = getSMPIOCapability(atoi(argv[++i])); - fprintf(stderr, "Set auto security io_cap in %s\n", sec->toString().c_str()); + fprintf(stderr, "Set SEC AUTO security io_cap in %s\n", sec->toString().c_str()); } else if( !strcmp("-unpairPre", argv[i]) ) { UNPAIR_DEVICE_PRE = true; } else if( !strcmp("-unpairPost", argv[i]) ) { diff --git a/examples/java/DBTScanner10.java b/examples/java/DBTScanner10.java index fbdea31f..d02b74ad 100644 --- a/examples/java/DBTScanner10.java +++ b/examples/java/DBTScanner10.java @@ -172,7 +172,7 @@ public class DBTScanner10 { @Override public String toString() { - return "BTSecurityDetail["+addrAndType+", lvl "+sec_level+", io "+io_cap+", passkey "+passkey+"]"; + return "BTSecurityDetail["+addrAndType+", lvl "+sec_level+", io "+io_cap+", auto-io "+io_cap_auto+", passkey "+passkey+"]"; } static private HashMap<BDAddressAndType, MyBTSecurityDetail> devicesSecDetail = new HashMap<BDAddressAndType, MyBTSecurityDetail>(); @@ -596,10 +596,10 @@ public class DBTScanner10 { if( null != sec ) { if( sec.isSecurityAutoEnabled() ) { final boolean res = device.setConnSecurityAuto( sec.getSecurityAutoIOCap() ); - println("****** Connecting Device: Using SecurityDetail "+sec+" -> set OK "+res); + println("****** Connecting Device: Using SecurityDetail.SEC AUTO "+sec+" -> set OK "+res); } else { final boolean res = device.setConnSecurityBest(sec.getSecLevel(), sec.getIOCap()); - println("****** Connecting Device: Using SecurityDetail "+sec+" -> set OK "+res); + println("****** Connecting Device: Using SecurityDetail.Level+IOCap "+sec+" -> set OK "+res); } } else { println("****** Connecting Device: No SecurityDetail for "+device.getAddressAndType()); @@ -1093,6 +1093,14 @@ public class DBTScanner10 { final int io_cap_i = Integer.valueOf(args[++i]).intValue(); sec.io_cap = SMPIOCapability.get( (byte)( io_cap_i & 0xff ) ); System.err.println("Set io_cap "+io_cap_i+" in "+sec); + } else if( arg.equals("-secauto") && args.length > (i+3) ) { + final String mac = args[++i]; + final byte atype = (byte) ( Integer.valueOf(args[++i]).intValue() & 0xff ); + final BDAddressAndType macAndType = new BDAddressAndType(new EUI48(mac), BDAddressType.get(atype)); + final MyBTSecurityDetail sec = MyBTSecurityDetail.getOrCreate(macAndType); + final int io_cap_i = Integer.valueOf(args[++i]).intValue(); + sec.io_cap_auto = SMPIOCapability.get( (byte)( io_cap_i & 0xff ) ); + System.err.println("Set SEC AUTO security io_cap "+io_cap_i+" in "+sec); } else if( arg.equals("-unpairPre") ) { test.UNPAIR_DEVICE_PRE = true; } else if( arg.equals("-unpairPost") ) { @@ -1122,6 +1130,7 @@ public class DBTScanner10 { "(-mac <device_address>)* (-wl <device_address>)* "+ "[-seclevel <device_address> <(int)address_type> <int>] "+ "[-iocap <device_address> <(int)address_type> <int>] "+ + "[-secauto <device_address> <(int)address_type> <int>] "+ "[-passkey <device_address> <(int)address_type> <digits>] " + "[-unpairPre] [-unpairPost] "+ "[-charid <uuid>] [-charval <byte-val>] "+ |