def _update_dbus_paths(self):
     self.btn_srv_path = tools.uuid_dbus_path(constants.GATT_SERVICE_IFACE,
                                              self.btn_srv_uuid)[0]
     # Button A
     self.btn_a_chr_path = tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                                                self.btn_a_chr_uuid)[0]
     # Button B
     self.btn_b_chr_path = tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                                                self.btn_b_chr_uuid)[0]
Ejemplo n.º 2
0
 def _update_dbus_paths(self):
     self.btn_srv_path = tools.uuid_dbus_path(constants.GATT_SERVICE_IFACE,
                                              self.btn_srv_uuid)[0]
     # Button A
     self.btn_a_chr_path = tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                                                self.btn_a_chr_uuid)[0]
     # Button B
     self.btn_b_chr_path = tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                                                self.btn_b_chr_uuid)[0]
Ejemplo n.º 3
0
    def _get_dbus_paths(self):
        """
        Utility function to get the paths for UUIDs
        :return:
        """
        self.blinkt_srv_path = tools.uuid_dbus_path(
            constants.GATT_SERVICE_IFACE, BLINKT_SRV)[0]
        self.blinkt_chrc_path = tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                                                     BLINKT_CHRC)[0]
        self.blinkt_obj = tools.get_dbus_obj(constants.BLUEZ_SERVICE_NAME,
                                             self.blinkt_chrc_path)

        self.blinkt_iface = tools.get_dbus_iface(constants.GATT_CHRC_IFACE,
                                                 self.blinkt_obj)
def client():
    dongle = adapter.Adapter(adapter.list_adapters()[0])
    if not dongle.powered:
        dongle.powered = True

    dongle.nearby_discovery()
    cc2650 = device.Device(
        tools.device_dbus_path(constants.DEVICE_INTERFACE, 'SensorTag')[0])
    # Connect to device
    cc2650.connect()

    while not cc2650.services_resolved:
        sleep(0.5)

    # constants
    TMP_CONF_PATH = Characteristic(
        tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                             'F000AA02-0451-4000-B000-000000000000')[0])
    TMP_DATA_PATH = Characteristic(
        tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                             'F000AA01-0451-4000-B000-000000000000')[0])
    OPT_CONF_PATH = Characteristic(
        tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                             'F000AA72-0451-4000-B000-000000000000')[0])
    OPT_DATA_PATH = Characteristic(
        tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                             'F000AA71-0451-4000-B000-000000000000')[0])
    BAR_CONF_PATH = Characteristic(
        tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                             'F000AA42-0451-4000-B000-000000000000')[0])
    BAR_DATA_PATH = Characteristic(
        tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                             'F000AA41-0451-4000-B000-000000000000')[0])
    HUM_CONF_PATH = Characteristic(
        tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                             'F000AA22-0451-4000-B000-000000000000')[0])
    HUM_DATA_PATH = Characteristic(
        tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                             'F000AA21-0451-4000-B000-000000000000')[0])

    # Read the connected status property
    if cc2650.connected:
        # IR Temperature Sensor
        print('\nIR Temperature Sensor')
        read_sensor(TMP_CONF_PATH, TMP_DATA_PATH)
        # Optical Sensor
        print('\nOptical Sensor')
        read_sensor(OPT_CONF_PATH, OPT_DATA_PATH)
        # Barometric Pressure Sensor
        print('\nBarometric Pressure Sensor')
        read_sensor(BAR_CONF_PATH, BAR_DATA_PATH)
        # Humidity Sensor
        print('\nHumidity Sensor')
        read_sensor(HUM_CONF_PATH, HUM_DATA_PATH)

    # Disconnect device
    cc2650.disconnect()
def client():
    dongle = adapter.Adapter(adapter.list_adapters()[0])
    if not dongle.powered:
        dongle.powered = True

    dongle.nearby_discovery()
    cc2650 = device.Device(tools.device_dbus_path(constants.DEVICE_INTERFACE,
                                                  'SensorTag')[0])
    # Connect to device
    cc2650.connect()

    while not cc2650.services_resolved:
        sleep(0.5)

    # constants
    TMP_CONF_PATH = Characteristic(tools.uuid_dbus_path(
        constants.GATT_CHRC_IFACE,
        'F000AA02-0451-4000-B000-000000000000')[0])
    TMP_DATA_PATH = Characteristic(tools.uuid_dbus_path(
        constants.GATT_CHRC_IFACE,
        'F000AA01-0451-4000-B000-000000000000')[0])
    OPT_CONF_PATH = Characteristic(tools.uuid_dbus_path(
        constants.GATT_CHRC_IFACE,
        'F000AA72-0451-4000-B000-000000000000')[0])
    OPT_DATA_PATH = Characteristic(tools.uuid_dbus_path(
        constants.GATT_CHRC_IFACE,
        'F000AA71-0451-4000-B000-000000000000')[0])
    BAR_CONF_PATH = Characteristic(tools.uuid_dbus_path(
        constants.GATT_CHRC_IFACE,
        'F000AA42-0451-4000-B000-000000000000')[0])
    BAR_DATA_PATH = Characteristic(tools.uuid_dbus_path(
        constants.GATT_CHRC_IFACE,
        'F000AA41-0451-4000-B000-000000000000')[0])
    HUM_CONF_PATH = Characteristic(tools.uuid_dbus_path(
        constants.GATT_CHRC_IFACE,
        'F000AA22-0451-4000-B000-000000000000')[0])
    HUM_DATA_PATH = Characteristic(tools.uuid_dbus_path(
        constants.GATT_CHRC_IFACE,
        'F000AA21-0451-4000-B000-000000000000')[0])

    # Read the connected status property
    if cc2650.connected:
        # IR Temperature Sensor
        print('\nIR Temperature Sensor')
        read_sensor(TMP_CONF_PATH, TMP_DATA_PATH)
        # Optical Sensor
        print('\nOptical Sensor')
        read_sensor(OPT_CONF_PATH, OPT_DATA_PATH)
        # Barometric Pressure Sensor
        print('\nBarometric Pressure Sensor')
        read_sensor(BAR_CONF_PATH, BAR_DATA_PATH)
        # Humidity Sensor
        print('\nHumidity Sensor')
        read_sensor(HUM_CONF_PATH, HUM_DATA_PATH)

    # Disconnect device
    cc2650.disconnect()
Ejemplo n.º 6
0
 def _get_dbus_paths(self):
     """
     Utility function to get the paths for UUIDs
     """
     self.accel_srv_path = tools.uuid_dbus_path(
         constants.GATT_SERVICE_IFACE, ACCEL_SRV)[0]
     self.accel_data_path = tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                                                 ACCEL_DATA)[0]
     self.aceel_period_path = tools.uuid_dbus_path(
         constants.GATT_CHRC_IFACE, ACCEL_PERIOD)[0]
     self.magneto_srv_path = tools.uuid_dbus_path(
         constants.GATT_SERVICE_IFACE, MAGNETO_SRV)[0]
     self.magneto_data_path = tools.uuid_dbus_path(
         constants.GATT_CHRC_IFACE, MAGNETO_DATA)[0]
     self.magneto_period_path = tools.uuid_dbus_path(
         constants.GATT_CHRC_IFACE, MAGNETO_PERIOD)[0]
     self.magneto_bearing_path = tools.uuid_dbus_path(
         constants.GATT_CHRC_IFACE, MAGNETO_BEARING)[0]
     self.btn_srv_path = tools.uuid_dbus_path(constants.GATT_SERVICE_IFACE,
                                              BTN_SRV)[0]
     self.btn_a_state_path = tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                                                  BTN_A_STATE)[0]
     self.btn_b_state_path = tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                                                  BTN_B_STATE)[0]
     self.io_pin_srv_path = tools.uuid_dbus_path(
         constants.GATT_SERVICE_IFACE, IO_PIN_SRV)[0]
     self.io_pin_data_path = tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                                                  IO_PIN_DATA)[0]
     self.io_pin_config_path = tools.uuid_dbus_path(
         constants.GATT_CHRC_IFACE, IO_PIN_CONFIG)[0]
     self.io_pin_pwm_path = tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                                                 IO_PIN_PWM)[0]
     self.io_ad_config_path = tools.uuid_dbus_path(
         constants.GATT_CHRC_IFACE, IO_AD_CONFIG)[0]
     self.led_srv_path = tools.uuid_dbus_path(constants.GATT_SERVICE_IFACE,
                                              LED_SRV)[0]
     self.led_state_path = tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                                                LED_STATE)[0]
     self.led_text_path = tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                                               LED_TEXT)[0]
     self.led_scroll_path = tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                                                 LED_SCROLL)[0]
     self.temp_srv_path = tools.uuid_dbus_path(constants.GATT_SERVICE_IFACE,
                                               TEMP_SRV)[0]
     self.temp_data_path = tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                                                TEMP_DATA)[0]
     self.temp_period_path = tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                                                  TEMP_PERIOD)[0]
dongle.nearby_discovery()
ubit = device.Device(
    tools.device_dbus_path(constants.DEVICE_INTERFACE, 'puteg')[0])
while True:
    print('connect...')
    while not ubit.connected():
        ubit.connect()
    while not ubit.services_resolved():
        lights.set_pixel(1, 1, 255, 0, 0)
        sleep(0.1)
        lights.show()
        lights.clear()
        sleep(0.1)
    print('set up characteristics')
    ubit_btn_b = Characteristic(
        tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                             'E95DDA90-251D-470A-A062-FA1922DFA9A8')[0])
    ubit_btn_b.add_characteristic_cb(on_button_b)
    ubit_btn_b.start_notify()

    ubit_btn_a = Characteristic(
        tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                             'E95DDA91-251D-470A-A062-FA1922DFA9A8')[0])
    ubit_btn_a.add_characteristic_cb(on_button_a)
    ubit_btn_a.start_notify()

    ubit_speed = Characteristic(
        tools.uuid_dbus_path(constants.GATT_CHRC_IFACE,
                             'E95DFB24-251D-470A-A062-FA1922DFA9A8')[0])
    ubit_speed.write_value((160).to_bytes(2, byteorder='little'))

    ubit_accel = Characteristic(