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!
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.
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.
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.
Enable the Bluetooth and iPod/iPhone option on the EV3 brick. Can be done from tools menu on the EV3.
Enable Bluetooth on the iPhone.
Start Bluetooth pairing process.
Launch the Lego EV3 App on the iPhone.
Done.
Related
I'm trying to connect USB camera to iOS in Xcode using Swift or Objective C.
I saw online to try and use IOKit.framework, but I believe it's for MAC, which I'm not using. dos NSSstring converters but I'm unsure that will work either. I'm trying to do it through iOS.
I also have a WIFI adapter that will connect to my NIKON DSLR and shoot photos to a PC over wifi but not sure how to get the iOS device to connect and download these images.
Thanks in advance!
Looks like this isn't possible, at least for what you want.
Communicating with an external accessory requires you to work closely
with the accessory manufacturer to understand the services provided by
that accessory. Manufacturers must build explicit support into their
accessory hardware for communicating with iOS. As part of this
support, an accessory must support at least one command protocol
These USB devices obviously have not been designed with iOS in mind, so there is a very small chance you can get it to work the apple way.
Alternatively, you can look into jailbreaking and that sorta deal with the cameraconnectionkit library. This is way out of my scope though, so good luck!
What I am trying to accomplish:
User enters a password on the iOS app. If the password is correct, then send a one bit value to the microprocessor that indicates the user got the right password. The microprocessor can then start up the step motor to open the door latch.
Has anyone tried to achieve this before? If so, can you please point me in a general direction. I don't know how to approach this problem. I couldn't really find a tutorial for this. My questions are:
Is there a specific Bluetooth I need to purchase? such as only BLE devices
I see a lot of examples of Bluetooth communication between iOS and Ardunio. Would the execution of events be similar for my needs?
Is there another approach to my problem? rather than using Bluetooth?
I think reading the Core Bluetooth Programming Guide is a great start. However, this assumes the device you're connecting to is using Bluetooth 4.x which is widely known as Bluetooth Low Energy (BLE). If the device you're connecting to is using Bluetooth 2.x, you'll have to use the External Accessories Framework.
EA supports only devices that have been certified MFI (Made for iPhone) by Apple.
To make a long story short, if the device you're trying to connect to is Bluetooth 2.x and it's not MFI, you're basically SOL.
Otherwise, you can start connecting to that device pretty easily. Check out LightBlue as a way to test if you connect to the device. It will work with any BLE device.
Here's a simple tutorial to get you going with Core Bluetooth.
I'd really like to start testing my iOS apps Bluetooth capabilities, but have run into a few problems:
I have a device made with a RN-42 module, but it's not the Apple version and I don't have the Apple authentication module at the moment (I ordered it, but shipping from China can take a while). I know what the messages will look like, but can't send them to my iPhone!
I can use the module with my Macbook, but not in the iOS simulator! Apple has taken down all of the documentation related to getting the iOS < 7.0 to use a separate bluetooth dongle, and my efforts have left my 6.1 simulator endlessly spinning on the bluetooth screen.
I'm new to using Bluetooth, so this may be a dumb question...
Is there a way of getting a bluetooth client device (I have a Mac, another iPhone, and an Android tab) to act as a server module that can send (and receive) Bluetooth data to my iPhone?
Client/Server as per developer.bluetooth.org
Thanks!
Not 100% sure your meaning of "server module". But in CoreBluetooth, you can use CBPeripheralManager to broadcast data to other iOS or Mac apps.
https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/CBPeripheralManager_Class/Reference/CBPeripheralManager.html
If you're using standard Bluetooth (i.e. not Bluetooth LE or Bluetooth Smart or whatever you want to call it), you'll need to enroll in the MFI program or work with an MFI certified device (such as a Redpark cable) and use the External Accessories library provided by Apple. If you're using Bluetooth LE, you can use the Core Bluetooth library provided by Apple. If you fall into neither of those cases, sorry, you can't use Bluetooth on iOS.
Which libraries should I look into for the following tasks?
I want to receive a string from another device via Bluetooth (this will require looking at a list of nearby devices and choosing the right one.
I then want to send the String to a database via Wi-fi
This is a simple version of what I actually want to do, but I need to know how to do those things first. Also, any design tips would be greatly appreciated (like having multiple screens, which classes to write, etc).
The ordinary iOS Bluetooth APIs are only available if you enter into Apple's "Made for iPod" program. See MFi Program
If your device can use the newer "low energy" Bluetooth LE, you can look in the corebluetooth framework
There is an example of a Bluetooth LE heart rate monitor program here.
For WiFi, you can use any of several APIs from Apple and others: Berkeley unix sockets, NSURLConnection, CFNetwork, AsyncSocket, etc.
If you mean receive a string from another iOS device, the statement here about needing to be a part of the "Made For iPod" program is incorrect. This would be required if you mean you are trying to build an accessory for iPhone, iPad, or iPod.
The easiest way to "discover" other iOS devices (running your app) and transfer data between them is GKSession from the GameKit Framework. Beam It! is pretty good example code for this.
Once you initialize a GKSession just set a GKSessionDelegate and set the session's available property to YES. Check out the four required GKSessionDelegate methods and the Beam It! sample code.
http://arctouch.com/beamit/ //Beam It! code
Your best bet is to study Apple's WiTap sample app. That will answer your question #1. For question 2, you can use Apple's coredata. If you are not familiar with coredata, check out this site's tutorials.
Is it possible to pair an iDevice to an rs232-bluetooth adapter for the purpose of sending serial commands like it would through an iDevice dock connector to rs232 (just like the Redpark Serial Cable does)? I ask because the company I work for is thinking of having an iDevice control one of our systems for demo. I know it doesn't relate to anything specific but any information would be greatly appreciated.
(See also iPhone to RS-232 via Bluetooth)
Bluetooth modules exists that support MFi (Made For iPhone) such as this one from connectBlue http://www.connectblue.com/products/bluetooth-products/bluetooth-modules/bluetooth-iphone-ios-accessory-module-obs414/ So the standard iPhone Bluetooth stack can make a SPP/RFCOMM connection to that device. That device could be added to a board along with RS232 level-conversion etc... And thus success.
I don't know whether someone sells such a device. The RS232 device that connectBlue sells seems not to support MFi, http://www.connectblue.com/products/bluetooth-products/bluetooth-devices/bluetooth-rugged-serial-port-adapter-rbs433/
Not really. The GameKit is one way to access bluetooth in iOS, but it is very limited in what that API allows you to do.
Depending on what you are building, you might be able to use the Apple Made for iPod program, but it's probably a long shot.
http://developer.apple.com/programs/mfi/
The best way to go is probably to design a device that connects via WiFi. I've gone this route, and it worked out well. If you must interface with something with an RS-232 interface, you might design an intermediary "adapter" that connects via WiFi to the iOS device, and via RS-232 to the other device.
If you don't have a need to distribute your app via the App Store, you can use Redpark's iOS serial cable: http://redpark.com/c2db9.html. (Disclaimer, I've never tried one, but according to someone at Redpark, jailbreaking is not required, you just can't distribute your app on the app store.)
You could design a small dongle that attaches via the dock connector, and broadcasts over bluetooth to your other device.
Or you could use WiFi instead of bluetooth... perhaps communicating over WiFi to something that's physically plugged into whatever you want to control.
I worked on a jailbroken app which used BTStack to communicate with a serial device. You might be able to use this for your demo.
If you're still looking to use bluetooth, this helped me out alot to facilitate the standard serial connection for prototyping without jailbreaking:
http://www.seeedstudio.com/depot/bleshield-based-on-bluegigas-ble112-module-p-1367.html
It works on the Bluetooth 4.0 enabled iOS devices and all of the schematic, boardfiles, firmware sources and the iOS App sources are available here:
https://github.com/michaelkroll/BLE-Shield