Bluetooth connection to LEGO Mindstorms EV3 brick from iOS app
Asked Answered
M

4

7

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!

Moriyama answered 7/9, 2013 at 20:2 Comment(4)
I am also wondering where I can find the bluetooth protocol for iphone and android. Let me know your progress plzBrittenybrittingham
here some information in this link might be relevant. iphone only allow bluetooth connection to headphones and other ios devices. not sure how the official app achieve thatBrittenybrittingham
Are you passing any services in to the services array? If you are, you could be blocking out the brick. Also, did you make sure to set the delegate to self?Anthodium
The Mindstorms EV3 is an MFi device (non-LE Bluetooth), so you don't use Core Bluetooth (Bluetooth LE) to communicate with it. You instead use the External Accessory framework, but you're going to need to know the protocol they have set up for this in order to communicate with the device. I'm not sure if they're published that anywhere.Kerch
E
4

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.

Educatee answered 24/2, 2014 at 21:11 Comment(0)
H
1

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.

Heron answered 30/10, 2013 at 13:25 Comment(0)
L
0

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.

Luing answered 8/6, 2016 at 12:27 Comment(0)
H
-1
  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.
Hensel answered 8/9, 2013 at 4:56 Comment(2)
Sorry - perhaps my question was not clear enough. I would like to know how to do this in code from my own self-written app.Moriyama
this is not the answer apparentlyBrittenybrittingham

© 2022 - 2024 — McMap. All rights reserved.