0

Sup yo.

I have my Adafruit Bluefruit Feather all wired up. It's lovely. I've got it responding to commands over the USB serial, activating an array of octocouplers. It's terrific. Here's the thing though. I need to talk to it wirelessly.

I can only pair it (MacOS) the Adafruit Bluefruit LE Connect app. It doesn't show up in my Bluetooth preference pane.

$ ls /dev/tty.* shows /dev/tty.Bluetooth-Incoming-Port and the Arduino IDE can see it. Unfortunately the word Incoming is right there in the middle of that port name. Sending commands through the Arduino serial monitor doesn't seem to do anything.

The Bluefruit connect app appears to be able to send commands over something called UART but my board doesn't respond to the stuff that works over USB serial.

How do I talk to this board over Bluetooth?

3

The “UART” being referred to is the Nordic UART GATT Service. This is not a serial port or USB connection. It is a high level BLE protocol that simulates a serial port via the Bluetooth connection.

In order to connect to the device from your Mac you’ll need to write some C or Obj-C. I’ve done this for Windows, but not a Mac, so I’m afraid I can’t give you detailed instructions. However, the source code for the iOS Adafruit Bluefruit LE Connect app you’re using is open source and should be a good starting point.

Be warned of a few things though.

  1. You’re going to have to learn a bit about the BLE protocols and standards. It’s not exactly for the faint of heart.
  2. Apple throttles the speed/throughput of BLE for their iOS devices (as does Android) to protect battery life. I don’t know if they apply the same throttling to their laptops. You may not be able to achieve a satisfying data rate if you’re looking to create a high throughput “data pipe”. With Win10 and the Bluefruit LE I was able to achieve 40 bytes every 30ms. You’ll likely be limited to 20 every ~30ms.

    If you’re looking to just send some occasional text (maybe AT style) commands to the device via BLE though, you won’t come close to those limitations.

  • gosh thanks dude. it sounds like a lot more trouble than it's worth. i'm just going to do a salvage run to another project that can actually do a bluetooth serial. – Walrus the Cat Apr 12 '18 at 0:46
  • It depends on what you need. If you just need to send & receive some text at a low rate, not much trouble at all. If you need a lot of throughput, then yeah... it’s a bit of a headache. You’ve got to remember that BLE stands for Bluetooth Low Energy. It’s designed to conserve battery life. – RubberDuck Apr 12 '18 at 1:01
1

First you should do some research on just what Bluetooth LE is. First and foremost, what it is not, is a serial port.

In fact the BLE specification has no concept of serial ports, not like the old Bluetooth 2.x SPP specification.

Yes, you can use it like a serial port, but the point I am making is there is no GATT profile for serial data transfer. Every module manufacturer has their own way of doing it, so it's down to your application to implement that method (usually using libraries provided by the manufacturer). You can't present BLE as a serial port (COM3, /dev/rfcomm0 etc).

Sure, you could write a daemon that connects the MFG's custom method to a PTY and make it look more like a serial port (and such a thing may already exist in the community for some devices), but it will only ever work with that device and never any other device. There is no serial - there is only serial emulation and it's specific to the device. If it were standard no doubt someone would write a driver for it - like SPP of Bluetooth 2.x. But with GATT you just don't get that standard facility.

BLE is intended for sending short packets of data back and forth using minimal power. Many manufacturers have chosen to create a profile that can be used in a similar way to a serial port (in that you send data through a virtual "pipe"), however you require special software to interface with it. And, since there is no standard, and manufacturers just don't talk to each other, the software is specific to the device you are talking to.

If you are directly programming a BLE chip itself with your own firmware there is nothing to stop you from implementing your own protocol for serial data transfer and writing an application, driver, daemon, whatever, for communicating with that custom firmware. The same thing stands though: whoever wants to use it will require your specific application to communicate with it.

The only people who want to use BLE for serial are people like us. Everyone else (that's 99.999% of the market) uses it for what it is intended - connecting sensors and HID devices to mobile phones etc. That's why all the GATT profiles are for such things as heart rate, blood sugar levels, cycle speed, etc.

So no. You can't use it like a serial port. It's not a serial port. The only foolproof way (and the way to which I have resorted in the past) is to create a USB dongle that exposes a CDC/ACM interface to the computer, and contains a BLE module that is capable of communicating directly with a similar BLE module through its own proprietary profile (the one I use has a "transparent UART" mode when two modules are paired together). The MCU in the dongle then forwards data between the computer and the BLE module.

  • @RubberDuck I think you misunderstood what I was saying there. Yes, you can use it like a serial port, but the point I am making is there is no GATT profile for serial data transfer. Every module manufacturer has their own way of doing it, so it's down to your application to implement that method (usually using libraries provided by the manufacturer). You can't present BLE as a serial port (COM3, /dev/rfcomm0 etc). Sure, you could write a daemon that connects the MFG's custom method to a PTY and make it look more like a serial port, but it will only ever work with that device and never ... – Majenko Apr 7 '18 at 9:25
  • ... any other device. There is no serial - there is only serial emulation and it's specific to the device. If it were standard no doubt someone would write a driver for it - like SPP of Bluetooth 2.x. But with GATT you just don't get that standard facility. – Majenko Apr 7 '18 at 9:26
  • Only works with Nordic though. Like I said, it's manufacturer specific as there is no standard. – Majenko Apr 7 '18 at 10:08
  • lol thanks for the involved answer. it sounds like this board is just not the right board here. – Walrus the Cat Apr 12 '18 at 0:47

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.