def scanner(board_allocator: BoardAllocator) -> BleDevice: device = board_allocator.allocate("scanner") assert device device.ble.init() yield device device.ble.shutdown() board_allocator.release(device)
def client(board_allocator: BoardAllocator) -> BleDevice: device = board_allocator.allocate('client') assert device device.ble.init() yield device device.ble.shutdown() board_allocator.release(device)
def central(board_allocator: BoardAllocator): device = board_allocator.allocate('central') assert device is not None device.ble.init() yield device device.ble.shutdown() board_allocator.release(device)
def dual_role(board_allocator: BoardAllocator): device = board_allocator.allocate('dual_role') assert device is not None device.ble.init() yield device device.ble.shutdown() board_allocator.release(device)
def advertiser(board_allocator: BoardAllocator) -> BleDevice: device = board_allocator.allocate('advertiser') device.ble.init() device.advParams.setPrimaryInterval(ADVERTISING_INTERVAL, ADVERTISING_INTERVAL) device.gap.setAdvertisingParameters(LEGACY_ADVERTISING_HANDLE) yield device device.ble.shutdown() board_allocator.release(device)
def advertiser(board_allocator: BoardAllocator) -> BleDevice: dev = board_allocator.allocate("advertiser") assert dev is not None dev.ble.init() dev.advParams.setPrimaryInterval(ADV_INTERVAL_MSEC, ADV_INTERVAL_MSEC) dev.gap.setAdvertisingParameters(LEGACY_ADVERTISING_HANDLE) yield dev dev.ble.shutdown() board_allocator.release(dev)
def peripheral2(board_allocator: BoardAllocator): device = board_allocator.allocate('peripheral2') assert device is not None device.ble.init() yield device device.ble.shutdown() board_allocator.release(device)
def unknown_peripheral(board_allocator: BoardAllocator, rand_data): device = board_allocator.allocate('peripheral') assert device is not None init_device(device) configure_peripheral(device, rand_data) yield device device.ble.shutdown() board_allocator.release(device)
def peripheral(board_allocator: BoardAllocator, test_params: TestParams): device = board_allocator.allocate('peripheral') assert device is not None # initialize the ble stack device.ble.init() # setup advertising intervals device.advParams.setPrimaryInterval(100, 100) device.gap.setAdvertisingParameters(LEGACY_ADVERTISING_HANDLE) yield device device.ble.shutdown() board_allocator.release(device)
def central(board_allocator: BoardAllocator): device = board_allocator.allocate('central') assert device is not None init_device(device) device.gap.setCentralPrivacyConfiguration( False, "RESOLVE_AND_FORWARD" ) yield device device.ble.shutdown() board_allocator.release(device)
def server(board_allocator: BoardAllocator) -> BleDevice: device = board_allocator.allocate("server") assert device device.ble.init() device.advDataBuilder.clear() # add flags data into advertising payload advertising_flags = ["LE_GENERAL_DISCOVERABLE", "BREDR_NOT_SUPPORTED"] for f in advertising_flags: device.advDataBuilder.setFlags(f) device.gap.applyAdvPayloadFromBuilder(LEGACY_ADVERTISING_HANDLE) # set the advertising type device.advParams.setType("CONNECTABLE_UNDIRECTED") device.gap.setAdvertisingParameters(LEGACY_ADVERTISING_HANDLE) yield device device.ble.shutdown() board_allocator.release(device)
def advertiser(board_allocator: BoardAllocator, advertising_data: str) -> BleDevice: device = board_allocator.allocate('advertiser') assert device # Setup the advertiser device.ble.init() # set up advertising parameters device.advParams.setType(ADVERTISING_TYPE) device.advParams.setPrimaryInterval(ADVERTISING_INTERVAL, ADVERTISING_INTERVAL) device.gap.setAdvertisingParameters(LEGACY_ADVERTISING_HANDLE) # add emitter data into advertising payload device.advDataBuilder.setManufacturerSpecificData(advertising_data) # apply payload payload = device.advDataBuilder.getAdvertisingData().result device.gap.applyAdvPayloadFromBuilder(LEGACY_ADVERTISING_HANDLE) yield device device.ble.shutdown() board_allocator.release(device)
def broadcaster(board_allocator: BoardAllocator) -> BleDevice: device = board_allocator.allocate('broadcaster') assert device device.ble.init() advertising_interval = 100 advertising_type = "CONNECTABLE_UNDIRECTED" local_name = "foo" # setup the advertising interval device.advParams.setType(advertising_type) device.advParams.setPrimaryInterval(advertising_interval, advertising_interval) device.gap.setAdvertisingParameters(LEGACY_ADVERTISING_HANDLE) # setup the local name in the scan response device.advDataBuilder.clear() device.advDataBuilder.setName(local_name, True) device.gap.applyScanRespFromBuilder(LEGACY_ADVERTISING_HANDLE) yield device device.ble.shutdown() board_allocator.release(device)
async def board(board_allocator: BoardAllocator): board = await board_allocator.allocate('LinkLoss') yield board board_allocator.release(board)
def advertiser(board_allocator: BoardAllocator) -> BleDevice: device = board_allocator.allocate('advertiser') device.ble.init() yield device device.ble.shutdown() board_allocator.release(device)
async def board(board_allocator: BoardAllocator): board = await board_allocator.allocate('DeviceInformation') yield board board_allocator.release(board)