Пример #1
0
 def testUnplug(self):
     b = bluetooth.Bluetooth()
     self.assertFalse(os.path.exists(self.outfile))
     b.UnplugGFRM100 = True
     self.loop.RunOnce()
     for _ in range(1, 5):
         # give the script time to run
         if not os.path.exists(self.outfile):
             time.sleep(0.2)
     self.assertTrue(os.path.exists(self.outfile))
Пример #2
0
def test():
    bt = bluetooth.Bluetooth()
    bt.active(True)
    bt.advertise(100, 'MicroPython')
    print('----')
    tx = bluetooth.Characteristic('6E400002-B5A3-F393-E0A9-E50E24DCCA9E',
                                  bluetooth.FLAG_READ | bluetooth.FLAG_NOTIFY)
    rx = bluetooth.Characteristic('6E400003-B5A3-F393-E0A9-E50E24DCCA9E',
                                  bluetooth.FLAG_WRITE)
    s = bt.add_service('6E400001-B5A3-F393-E0A9-E50E24DCCA9E', [tx, rx])
    tx.write('foo')
Пример #3
0
    def testRemoteControls(self):
        b = bluetooth.Bluetooth()
        self.assertEqual(2, b.RemoteControlNumberOfEntries)

        l = b.RemoteControlList
        self.assertEqual('GFRM100', l[1].Model)
        self.assertEqual('00:24:1C:B5:E2:C8', l[1].PhysAddress)
        self.assertEqual('', l[1].FirmwareVersion)
        self.assertEqual('', l[1].HardwareVersion)
        self.assertEqual('', l[1].SerialNumber)

        self.assertEqual('GFRM200', l[2].Model)
        self.assertEqual('5C:31:3E:08:25:44', l[2].PhysAddress)
        self.assertEqual('T0055.12 G001E.04', l[2].FirmwareVersion)
        self.assertEqual('GPN#07081865-01', l[2].HardwareVersion)
        self.assertEqual('21451 20002000', l[2].SerialNumber)
Пример #4
0
 def __init__(self):
     self.controller = remote_controller.RemoteController()
     self.bluetooth = bluetooth.Bluetooth(self.controller.on_open,
                                          self.controller.on_message,
                                          self.controller.on_close,
                                          self.controller.on_error)
Пример #5
0
import bluetooth
import utime

from led_services import LedServices

blue = bluetooth.Bluetooth()
blue.active(True)
blue.advertise(100, "uled")
print("UHOLA")
led = LedServices(blue, 30, 27)
print("hola")

led.main_loop()
Пример #6
0
import bluetooth
bt = bluetooth.Bluetooth()
bt.active(True)

LPF2_SERVICE = bluetooth.UUID('00001623-1212-EFDE-1623-785FEABCD123')
LWP_CHAR = (
    bluetooth.UUID('00001624-1212-EFDE-1623-785FEABCD123'),
    bluetooth.FLAG_NOTIFY | bluetooth.FLAG_WRITE,
)
lwp_char, = bt.gatts_add_service(LPF2_SERVICE, (LWP_CHAR, ))

bt.advertise(100, adv_data=bytearray('\x02\x01\x02\x0a\x09pybd-lpf2'))

#Now to send data from pyboard->hub do:

bt.gatts_notify(lwp_char, 64, 'from pybd')

#Then on pyboard get this data via:

bt.gatts_read(lwp_char)

# You can also register IRQ callbacks on the pyboard for all BLE events, like this:
'''
def bt_irq(event, data):
    print('bt_irq', event, data)
bt.irq(bt_irq, bluetooth.IRQ_ALL)

'''
'''
######  SPIKE Code #####
import hub,utime
Пример #7
0
 def testValidateExports(self):
     b = bluetooth.Bluetooth()
     tr.handle.ValidateExports(b)