0

I'm currently trying to make an app that allows my phone to send commands to a raspberry pi and then the pi sends back data. This two way communication needs to be through bluetooth. All string data is fine. On Android this has been very simple so far. I use rfcomm0 and a python script on the pi to communicate to my Cordova app back and forth. I can also easily test communication with a bluetooth terminal on Android. Hardly any setup using bluez on the pi.

An example of what my app would do is simple things like sending an ifconfig command. On Android this is simple, I send "ifconfig" on my phone, python on the pi receives it over rfcomm0, and sends back the ifconfig data to the phone. Very easy.

Now I go to make an iOS app and I can barely get it to connect.

Using

sudo hciconfig hci0 leadv 0

on the pi allows the iOS device to see the pi and connect, but only if I connect through an app called BluetoothLE. The native bluetooth screen on iOS won't ever see the pi unless I connect first through that app. That is kinda beside the point since it does finally say connected after I connect with the BluetoothLE app.

Since iOS doesn't use rfcomm, I have no idea how to send data back and forth from iOS to the pi.

All my google searches have led me to believe it is impossible and I would have to do some weird ble advertising sending tiny little data packets.

I guess my main question is, is there an easy way to do this on iOS like on Android? If so is there a tutorial I'm not seeing? If not, is there a work around?

Thanks for any help.

Daniel Braun
  • 471
  • 1
  • 3
  • 12
  • iOS apps cannot use legacy Bluetooth profiles, such as the serial port profile, that you are using with android. You will need to write an app that uses core Bluetooth to connect to your peripheral using BLE and the GATT profile and you will need a corresponding application on the Pi. – Paulw11 Jun 02 '17 at 01:45

1 Answers1

0

There are tons of BLE examples online. Most common is that you let the Raspberry Pi be a peripheral which advertises and the iOS be a central which scans for your Pi and then connects to it through CoreBluetooth. You have to have some software in the Pi that creates a GATT DB. You for example have BlueZ or bleno. You shouldn't care too much about the iOS Bluetooth Settings view.

Emil
  • 16,784
  • 2
  • 41
  • 52