import time import busio import board from digitalio import DigitalInOut from adafruit_bluefruitspi import BluefruitSPI spi_bus = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) cs = DigitalInOut(board.D8) irq = DigitalInOut(board.D7) rst = DigitalInOut(board.D4) bluefruit = BluefruitSPI(spi_bus, cs, irq, rst, debug=False) # Initialize the device and perform a factory reset print("Initializing the Bluefruit LE SPI Friend module") bluefruit.init() bluefruit.command_check_OK(b'AT+FACTORYRESET', delay=1) # Print the response to 'ATI' (info request) as a string print(str(bluefruit.command_check_OK(b'ATI'), 'utf-8')) # Change advertised name bluefruit.command_check_OK(b'AT+GAPDEVNAME=BlinkaBLE') while True: print("Waiting for a connection to Bluefruit LE Connect ...") # Wait for a connection ... dotcount = 0 while not bluefruit.connected: print(".", end="") dotcount = (dotcount + 1) % 80 if dotcount == 79:
# Initialize the I2C bus i2c = busio.I2C(board.SCL, board.SDA) # Initialize the SPI bus spi = busio.SPI(SPI_SCK, MOSI=SPI_MOSI, MISO=SPI_MISO) print() print("{0} v{1:1.1f}".format(BLUEFRUIT_DEV_NAME, SCRIPT_VERSION)) # Initialize the Bluefruit LE SPI Friend and perform a factory reset bluefruit = BluefruitSPI(spi, cs=BLUEFRUIT_CS, irq=BLUEFRUIT_IRQ, reset=BLUEFRUIT_RST) print() print("Initializing Bluetooth") bluefruit.init() bluefruit.command_check_OK(b'AT+FACTORYRESET', delay=1) # Print the response to 'ATI' (info request) as a string print(str(bluefruit.command_check_OK(b'ATI'), 'utf-8')) # Change advertised name bluefruit.command_check_OK(b'AT+GAPDEVNAME=' + BLUEFRUIT_DEV_NAME) # Set the name of the beacon ##BLUEFRUIT_BEACON_NAME = "FrankBLE" ##bluefruit.command_check_OK(b'AT+BLEURIBEACON=' BLUEFRUIT_BEACON_NAME) # Initialze RFM69 radio print("Initializing the RFM69 radio") rfm69 = adafruit_rfm69.RFM69(spi, RFM69_CS, RFM69_RST, RFM69_RADIO_FREQ_MHZ)
import time import busio import board from digitalio import DigitalInOut from adafruit_bluefruitspi import BluefruitSPI spi_bus = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO) cs = DigitalInOut(board.D8) irq = DigitalInOut(board.D7) rst = DigitalInOut(board.D4) bluefruit = BluefruitSPI(spi_bus, cs, irq, rst, debug=False) # Initialize the device and perform a factory reset print("Initializing the Bluefruit LE SPI Friend module") bluefruit.init() bluefruit.command_check_OK(b"AT+FACTORYRESET", delay=1) # Print the response to 'ATI' (info request) as a string print(str(bluefruit.command_check_OK(b"ATI"), "utf-8")) # Change advertised name bluefruit.command_check_OK(b"AT+GAPDEVNAME=BlinkaBLE") while True: print("Waiting for a connection to Bluefruit LE Connect ...") # Wait for a connection ... dotcount = 0 while not bluefruit.connected: print(".", end="") dotcount = (dotcount + 1) % 80 if dotcount == 79: