Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
args = shlex.split(line)
optParser = OptionParser(usage=optparse.SUPPRESS_USAGE, option_class=ExtendedOption)
try:
(options, remainingArgs) = optParser.parse_args(args)
except SystemExit:
return
if (len(remainingArgs) > 0):
print "Unexpected argument: " + remainingArgs[0]
return
if not self.bleMgr:
self.bleMgr = BleManager(self.devMgr)
if not self.bleMgr.isConnected():
print "BLE not connected"
return
try:
self.devMgr.TestAbortBle(FAKE_CONN_OBJ_VALUE)
except WoBleTestMgr.DeviceManagerException, ex:
print str(ex)
return
def do_blescan(self, line):
"""
ble-scan
Start BLE scanning operations.
"""
if not self.bleMgr:
self.bleMgr = BleManager(self.devMgr)
self.bleMgr.scan(line)
return
print "Usage:"
self.do_help('ble-diag-test-timing')
return
enabled = self.parseBoolean(remainingArgs[0])
if (enabled == None):
print "Invalid argument: " + remainingArgs[0]
return
if options.remote:
remote = 1
else:
remote = 0
if not self.bleMgr:
self.bleMgr = BleManager(self.devMgr)
if not self.bleMgr.isConnected():
print "BLE not connected"
return
try:
self.devMgr.TxTimingBle(FAKE_CONN_OBJ_VALUE, enabled, remote)
except WoBleTestMgr.DeviceManagerException, ex:
print str(ex)
return
def do_bleadapterselect(self, line):
"""
ble-adapter-select
Start BLE adapter select.
"""
if sys.platform.startswith('linux'):
if not self.bleMgr:
self.bleMgr = BleManager(self.devMgr)
self.bleMgr.ble_adapter_select(line)
else:
print "ble-adapter-select only works in Linux, ble-adapter-select mac_address"
return
def do_blesend(self, line):
"""
ble-send
Send a string of bytes to the connected peripheral.
"""
if not self.bleMgr:
self.bleMgr = BleManager(self.devMgr)
self.bleMgr.send(line)
def do_blescanconnect(self, line):
"""
ble-scan-connect
Scan and connect to a BLE peripheral identified by line.
"""
if not self.bleMgr:
self.bleMgr = BleManager(self.devMgr)
self.bleMgr.scan_connect(line)
return
def do_bleconnect(self, line):
"""
ble-connect
Connect to a BLE peripheral identified by line.
"""
if not self.bleMgr:
self.bleMgr = BleManager(self.devMgr)
self.bleMgr.connect(line)
return
rx = 0
if (count == 0 and duration == 0):
print "Packet Count or Duration has to be specified"
return
if (size < 0 or size > 2048):
print "Invalid Payload Size (0~2048): %d" % size
return
if (delay < 1 or delay > 60000):
print "Invalid Tx Gap (1~60000ms): %d" % delay
return
if not self.bleMgr:
self.bleMgr = BleManager(self.devMgr)
if not self.bleMgr.isConnected():
print "BLE not connected"
return
print "PacketCount = %d" % count
print "Duration = %d ms" % duration
print "Tx Gap = %d ms" % delay
print "Ack = %d" % ack
print "Payload Size = %d bytes" % size
print "Rx = %d" % rx
try:
self.devMgr.TestBle(FAKE_CONN_OBJ_VALUE, count, duration, delay, ack, size, rx)
except WoBleTestMgr.DeviceManagerException, ex:
print str(ex)
try:
(options, remainingArgs) = optParser.parse_args(args)
except SystemExit:
return
if (len(remainingArgs) > 0):
print "Unexpected argument: " + remainingArgs[0]
return
if options.local:
local = 1
else:
local = 0
if not self.bleMgr:
self.bleMgr = BleManager(self.devMgr)
if not self.bleMgr.isConnected():
print "BLE not connected"
return
try:
self.devMgr.TestResultBle(FAKE_CONN_OBJ_VALUE, local)
except WoBleTestMgr.DeviceManagerException, ex:
print str(ex)
return
def do_bledebuglog(self, line):
"""
ble-debug-log 0:1
0: disable BLE debug log
1: enable BLE debug log
"""
if not self.bleMgr:
self.bleMgr = BleManager(self.devMgr)
self.bleMgr.ble_debug_log(line)
return