Ejemplo n.º 1
0
import board
from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService
from adafruit_airlift.esp32 import ESP32

# If you are using an AirLift FeatherWing or AirLift Bitsy Add-On,
# use the pin settings below:
esp32 = ESP32(
    reset=board.D12,
    gpio0=board.D10,
    busy=board.D11,
    chip_select=board.D13,
    tx=board.TX,
    rx=board.RX,
)

# If you are using an AirLift Breakout, comment out the DEFAULT lines
# above and uncomment the lines below:
# esp32 = ESP32(
#    reset=board.GP16,
#    gpio0=board.GP9,
#    busy=board.GP14,
#    chip_select=board.GP13,
#    tx=board.GP0,
#    rx=board.GP1,
# )

adapter = esp32.start_bluetooth()

ble = BLERadio(adapter)
Ejemplo n.º 2
0
strip.fill((0, 0, 31))
time.sleep(0.5)
strip.fill((0, 0, 0))

last_seen_update_ns = time.monotonic_ns()
# Reintroduce screen_update_ns to limit call to change color
screen_update_ns = 250 * 1000 * 1000

### If no advertisement received for 'hide_time_ns' that RGB LED turn BLUE and will be forgotten
hide_time_ns =      20 * 1000 * 1000 * 1000
### If no advertisement is received for 'stale_time_ns' that RGB LED is flushed for reuse
stale_time_ns =    200 * 1000 * 1000 * 1000
scan_time_s = 10

from adafruit_airlift.esp32 import ESP32
esp32 = ESP32(tx=board.TX, rx=board.RX)
adapter = esp32.start_bluetooth()
ble = BLERadio(adapter)
ble.name = "PyPortal"

###ble = BLERadio()
###ble.name = "CPB"

### An array of timestamp and advertisement by key (addr)
last_ad_by_key = {}

MINI_BLUE = (0, 0, 1)
SHADE_BLUE = [(0, 0, 63), (0, 0, 31), (0, 0, 15), (0, 0, 7), (0, 0, 3)]
TIME_BLUE = [50 * 1000 * 1000 * 1000, 80 * 1000 * 1000 * 1000, 110 * 1000 * 1000 * 1000, 140 * 1000 * 1000 * 1000, 170 * 1000 * 1000 * 1000]

RSSI_DEFAULT_COLOR = (63, 0, 0)
# SPDX-FileCopyrightText: 2020 Dan Halbert, written for Adafruit Industries
#
# SPDX-License-Identifier: Unlicense

# Test works for boards with onboard adapters.

import _bleio
from adafruit_airlift.esp32 import ESP32

esp32 = ESP32()
adapter = esp32.start_bluetooth()
_bleio.set_adapter(adapter)  # pylint: disable=no-member

print(_bleio.adapter.address)