Bluetooth connection to LEGO Mindstorms EV3 brick from iOS app

16.1k Views Asked by At

Does anybody know how to establish a bluetooth connection from a self-written iOS app to the new LEGO Mindstorms EV3 programmable brick?

I tried to do this via the scanForPeripheralsWithServices:options: method of CBCentralManager, but the brick is not recognized.

But if I enable Bluetooth in the Settings of the iPhone, then the EV3 device is displayed there. There is also an app in the AppStore from LEGO ("Commander") which talks to the brick via Bluetooth, so I think this should be possible in general (as I know, it was not possible for the previous Mindstorms NXT brick).

Does anybody have an idea how I can do this?

Thanks!

4

There are 4 best solutions below

2
On
  1. Enable the Bluetooth and iPod/iPhone option on the EV3 brick. Can be done from tools menu on the EV3.
  2. Enable Bluetooth on the iPhone.
  3. Start Bluetooth pairing process.
  4. Launch the Lego EV3 App on the iPhone. Done.
0
On

You will have to wait until Lego release the SDK which hopefully contains information about the protocol. It was possible with the NXT and i think it will be possible with the EV3.

In the mean time you could try to send your messages via Wifi which is possible right now.

0
On

Note that there are two protocol with which the EV3 communicates over Bluetooth. One is used by the LEGO EV3 App on the iPhone and the other one is the same available over USB-HID and WiFi and is partly specified by Communication developer manual and by the source code. The latter protocol is the one you should use.

You can call/link against/check the source code of my uploader for c4ev3 to see how the connection is realized.

HTH.

0
On

As said, the device isn't listed using CoreBluetooth, got it using EAcessory framework, you need to have the item "COM.LEGO.MINDSTORMS.EV3" in UISupportedExternalAccessoryProtocols in your App-Info.plist :

<EAAccessory: 0x15567180> {
  connected:YES
  connectionID:18565483
  name: MFI Accessory
  manufacturer: LEGO
  modelNumber: DM240411
  serialNumber: 
  firmwareRevision: 1.0.0
  hardwareRevision: 1.0.0
  protocols: (
    "COM.LEGO.MINDSTORMS.EV3"
)
  delegate: (null)
}

As with the Lego app, you need to first connect to the EV3 using Settings App. Then, look at the Apple EADemo sample, it show how to use EASession (encapsulate read/write stream).

Maybe sending data like the C# gathered from monobrick.dk source code (said in Mailerdaimon answer) will work... I'll get a try via Wifi (after porting C# to ObjC, long job), after that, writing to EASession might be easier. I'll update this answer when done.