Home

Awesome

uble

Lightweight Bluetooth Low Energy driver written in pure python for micropython.

WARNING: this project is in beta stage and is subject to changes of the code-base, including project-wide name changes and API changes.

Features

Usage

        MicroPython v1.8.7-79-g221f88d-dirty on 2017-01-26; PYBv1.1 with STM32F405RG
        Type "help()" for more information.
        >>> from bluetooth_low_energy.protocols.hci import (cmd, uart)
        >>> buf = b'\x01\x03\x0c\x00'
        >>> hci_uart = uart.HCI_UART.from_buffer(buf)
        >>> print(hci_uart)
        <HCI_UART pkt_type=COMMAND(0x01) data=030c00>
        >>> hci_cmd = cmd.HCI_COMMAND.from_buffer(hci_uart.data)
        >>> print(hci_cmd)
        <HCI_COMMAND opcode=0x0c03 ogf=HOST_CTL(0x03) ocf=RESET(0x03) request_data= response_data=>
        >>> hci_cmd.to_buffer()
        b'\x03\x0c\x00'        
        >>>
        MicroPython v1.8.7-79-g221f88d-dirty on 2017-01-26; PYBv1.1 with STM32F405RG
        Type "help()" for more information.
        >>> from bluetooth_low_energy.protocols.hci import cmd
        >>> hci_cmd = cmd.HCI_COMMAND(ogf=cmd.OGF_LE_CTL, ocf=cmd.OCF_LE_RAND)
        >>> print(hci_cmd)
        <HCI_COMMAND opcode=0x2018 ogf=LE_CTL(0x08) ocf=LE_RAND(0x18) request_data= response_data=>
        >>> hci_cmd.to_buffer()
        b'\x18 \x00'
        >>>

Software

Currently implemented full HCI commands from STSW-BLUENRG-DK 2.0.2

User manual BlueNRG-MS Bluetooth® LE stack application command interface

Programming manual BlueNRG, BlueNRG-MS stacks programming guidelines

Hardware

Currently supported module STMicroelectronics SPBTLE-RF

From STMicroelectronics X-NUCLEO-IDB05A1:

<img src="https://raw.githubusercontent.com/dmazzella/uble/master/hardware/X_Nucleo_IDB05A1/X_Nucleo_IDB05A1_mbed_pinout_v1.jpg" width="80%" height="80%" alt="X_Nucleo_IDB05A1_mbed_pinout_v1"/>

PyBoard breakout board: </br> <img src="https://raw.githubusercontent.com/dmazzella/uble/master/hardware/MicroPython_SPBTLERF_Breakout_v03/MicroPython_SPBTLERF_Breakout_v03_mod_TOP_and_BOTTOM.jpg" width="80%" height="80%" alt="MicroPython_SPBTLERF_Breakout_v03_mod_TOP_and_BOTTOM"/> </br>

Fritzing for breakout: MicroPython_SPBTLERF_Breakout_v03_mod.fzz

Gerber for breakout: MicroPython_SPBTLERF_Breakout_v03_mod.zip

If have interest into preassembled breakout board contact me at damianomazzella@gmail.com

External dependencies

Only for examples: 'logging' already available into folder 'micropython-lib' of this repository

Install 'bluetooth_low_energy' into the pyboard

To enable the functionality you need to freeze the package 'bluetooth_low_energy', to do this, copy the package 'bluetooth_low_energy' into 'micropython-lib'.

Navigate to the folder containing the repository micropython:

        $ cd ports/stm32
        $ make FROZEN_MPY_DIR="~/uble/micropython-lib"