Exemple #1
0
    def setUp(self):
        self.vdev = subprocess.Popen(
            ['virtual_device', 'bled112', 'report_test'])

        bleds = BLED112Adapter.find_bled112_devices()
        print(bleds)
        self.hw = HardwareManager(port='bled112:{}'.format(bleds[1]))
Exemple #2
0
    def setUp(self):
        self.old_serial = serial.Serial
        serial.Serial = util.dummy_serial.Serial
        self.adapter = MockBLED112(3)
        self.dev1 = MockIOTileDevice(100, 'TestCN')
        self.dev1_ble = MockBLEDevice("00:11:22:33:44:55", self.dev1)
        self.adapter.add_device(self.dev1_ble)

        self.dev1.reports = [
            IndividualReadingReport.FromReadings(100, [IOTileReading(0, 1, 2)])
        ]
        self._reports_received = threading.Event()

        logging.basicConfig(level=logging.INFO, stream=sys.stdout)

        util.dummy_serial.RESPONSE_GENERATOR = self.adapter.generate_response

        self.scanned_devices = []
        self.bled = BLED112Adapter('test',
                                   self._on_scan_callback,
                                   self._on_disconnect_callback,
                                   passive=False,
                                   stop_check_interval=0.01)
        self.bled.add_callback('on_report', self._on_report_callback)
        self.reports = []
    def setUp(self):
        self.old_serial = serial.Serial
        serial.Serial = util.dummy_serial.Serial
        self.adapter = MockBLED112(3)

        self.dev1 = MockIOTileDevice(100, 'TestCN')
        self.dev1_ble = MockBLEDevice("00:11:22:33:44:55", self.dev1)
        self.adapter.add_device(self.dev1_ble)

        util.dummy_serial.RESPONSE_GENERATOR = self.adapter.generate_response

        self._scanned_devices_seen = threading.Event()
        self.num_scanned_devices = 0
        self.scanned_devices = []
        self.bled = BLED112Adapter('test', self._on_scan_callback,
                                   self._on_disconnect_callback, passive=False, stop_check_interval=0.01)
    def setUp(self):
        self.old_serial = serial.Serial
        serial.Serial = util.dummy_serial.Serial
        self.adapter = MockBLED112(3)
        self.dev1 = SimpleVirtualDevice(100, 'TestCN')
        self.dev1_ble = MockBLEDevice("00:11:22:33:44:55", self.dev1)
        self.adapter.add_device(self.dev1_ble)

        util.dummy_serial.RESPONSE_GENERATOR = self.adapter.generate_response

        self.scanned_devices = []
        self.bled = BLED112Adapter('test',
                                   self._on_scan_callback,
                                   self._on_disconnect_callback,
                                   stop_check_interval=0.01)
        self._current = None
        self._total = None
Exemple #5
0
        exit("This script must be run as root")

    if not shutil.which("dfu-util"):
        exit("Requires the dfu-util utility")


if __name__ == "__main__":

    check_pre_requisites()

    parser = argparse.ArgumentParser()
    parser.add_argument("blob", nargs='?', default="bled112-v1-6-0-virtual.raw")
    parser.add_argument("-n", "--num", help="Number of expected bled devices", required=False, type=int)
    args = parser.parse_args()

    unreset_bleds = BLED112Adapter.find_bled112_devices()

    if args.num and args.num != len(unreset_bleds):
        print("Error: Did not find expected number of bleds. Expected:", args.num, "Found:", len(unreset_bleds))
        exit(1)

    if args.num:
        total_num_to_flash = args.num
    else:
        total_num_to_flash = len(unreset_bleds)

    print("Resetting each dongle")
    while unreset_bleds:
        reset(unreset_bleds.pop())

    ready_bleds = []
Exemple #6
0
"""If there are two bled112 dongles on this computer attempt to setup a loopback test

We will serve a virtual device over one bled112 and connect to it with the other bled112
"""

from __future__ import unicode_literals, absolute_import, print_function
import pytest
import unittest
import subprocess
from iotile_transport_bled112.bled112 import BLED112Adapter
from iotile.core.hw.hwmanager import HardwareManager
import time
import signal

can_loopback = len(BLED112Adapter.find_bled112_devices()) >= 2


@pytest.mark.skipif(
    True,
    reason=
    '(loopback not finished yet)You need two BLED112 adapters for loopback tests'
)
class TestBLED112Loopback(unittest.TestCase):
    def setUp(self):
        self.vdev = subprocess.Popen(
            ['virtual_device', 'bled112', 'report_test'])

        bleds = BLED112Adapter.find_bled112_devices()
        print(bleds)
        self.hw = HardwareManager(port='bled112:{}'.format(bleds[1]))