Skip to content

Allows external systems or MCUs to connect BLE (CC2540) using HCI as BLE Central Role

Notifications You must be signed in to change notification settings

travelbureau/BLE_HCI

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BLE_HCI

Allows external systems or MCUs to control BLE chip (CC2540) using Bluetooth HCI mode such as Windows/Linux/Mac, Arduino (AVR), Teensy 3.0 (ARM Cortex M4), Respberry Pi (ARM11), etc.

The libraries was written for Python and Arduino. Tested on Windows, Linux and Mac OS X This is in beta and still a work in progress, not all HCI commands and events have been implemented or fully tested.

The HCI firmware is built from TI CC254x SDK, refer to the HostTestApp project if you want to study the firmware code.

You can use it to connect to other BLE devices such as BLE Mini, BLE Shield or other BLE devices.

Example 1

PC/Mac as BLE central role and via the BLE link, connecting to BLE Mini running Biscuit firmware as peripheral role

Typical connections:

  1. PC <-> USB <-> BLE Mini (HCI) <----- BLE Link ------> BLE Mini (Biscuit) <-> Serial <-> Ardino
  2. Mac <-> USB <-> BLE Mini (HCI) <----- BLE Link ------> BLE Mini (Biscuit) <-> USB <-> Raspberry Pi
  3. Raspberry Pi <-> USB <-> BLE Mini (HCI) <----- BLE Link -----> BLE Mini (Biscuit) <-> Serial <-> Arduino

Requirements:

  1. A PC running Windows, Linux or a Mac running Mac OS X
  2. Raspberry Pi with Linux is also possible
  3. HCI firmware (USB) and Biscuit firmware (USB or Serial)
  4. Two BLE Mini boards, first one running the HCI firmware, another one running the Biscuit firmware
  5. Install Python 2.7.2 32-bit
  6. Install PySerial 2.5
  7. For Windows, install USB CDC driver
  8. Biscuit central Python script

How it works:
When you connect the BLE Mini (HCI) to your PC via the USB port, it will function as an USB CDC (Virtual COM Port). On Windows, it will ask for a device driver, so you need to install the USB CDC driver. It shows as a COM port (e.g. COM5). For Linux or Mac OS X, it will work as a tty device (e.g. ttyACM0 or tty.usbmodem1311).

The Biscuit central Python script controls the virtual COM port, sending BLE command over the port, and listening to the HCI events.

You need to change the following lines to match your COM port and bardrate:
if os.name == 'posix':
TX.port = '/dev/tty.usbmodem1431'
else:
TX.port = 'COM5'
TX.baudrate = 115200

Press 'd' to start discovery, it will show if any device is found, and then press 'e' to establish a BLE link with the device, you need then enable the notification before you can receive data from the device.

Press '1', it will send a string 'Hello World!' to the device and press '2' will send 'I love BLE!'.

You can do many other interesting things as you want with BLE.

Supported systems:

  1. Windows
  2. Linux (includes Raspberry Pi)
  3. Mac OS X

Example 2

Arduino as BLE central role and via the BLE link, connecting to BLE Mini running Biscuit firmware as peripheral role

Typical connections:

  1. Arduino (A) <-> Serial <-> BLE Mini (A) <----- BLE Link -----> BLE Mini (B) <-> Serial <-> Arduino (B)
  2. Arduino (A) <-> Serial <-> BLE Mini (A) <----- BLE Link -----> BLE Mini (C) <-> USB <-> Raspberry Pi
  • Suggest to use Arduino Leonardo or other boards with more than one serial to try this example.
  • We use the USB CDC serial for debug/UI and one for connecting to the BLE Mini on Leonardo board.
  • Uno has only one serial and we do not use SoftwareSerial because sometimes data recevied incorrectly.
    -> We used AltSoftSerial, so Uno works now, but the baudrate limited to 57600bps.
    -> http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
  • Tested with Uno (use pin 8, 9), Leonardo (use pin 0, 1), Mega 2560 (use TX1, RX1)

Requirements:

  1. BLE HCI library for Arduino
  2. Arduino (A) running HCI library
  3. AltSoftSerial (requred for Arduino Uno)
  4. BLE Mini (A) running HCI firmware (Serial)
  5. BLE Mini (B or C) running Biscuit firmware (Serial or USB)

How it works:
Similar to the Example 1, the Arduino will keep tracks of HCI events from the serial port. You can see those events and send command using the Arduino IDE's Serial Monitor.

Supported Arduino boards or compatible:

  1. Arduino UNO (R3)
  2. Arduino Leonardo (R3)
  3. Arduino Mega 2560 (R3)
  4. Seeeduino V3.0 (Atmega 328P)
  5. Teensy 3.0
    Write to us if any other boards you tested.

About

Allows external systems or MCUs to connect BLE (CC2540) using HCI as BLE Central Role

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published