![Gitter](https://badges.gitter.im/Join Chat.svg)
The free MiP iOS SDK lets you control your WowWee MiP robot and WowWee Turbo Dave robot on devices running iOS 8.0 and above and Xcode 6. To use this SDK you will also need a physical MiP robot or Turbo Dave robot.
Pre-built official SDKs are also available for Android, PhoneGap, Windows and JavaScript (Node.js).
For information on WowWee products visit: http://www.wowwee.com
- Quick Installation
- Notes about the SDK
- Using the SDK
- SDK Documentation (coming soon)
- License
- Contributing
- Credits
- Projects using this SDK
-
Clone the repository
git clone https://github.com/WowWeeLabs/MiP-iOS-SDK.git
-
In XCode, create a new project. The simplest application is a Single-View application.
-
Open the project navigator in Xcode and drag the WowWeeMiPSDK.framework file from the Mac OS Finder to the Frameworks directory for your project in XCode.
- Confirm that the framework is added to your project by going into Project Settings (first item in the project navigator), then click the first target (e.g. MiPSampleProject), then Build Phases. If there is not a "Copy Files" phase., click the top left + to add one. Set the destination to "Frameworks" and add the framework file under the "Name" section.
Also make that the framework is present under the "Link Binary With Libraries" section.
-
In the ViewController.h file, add the following line at the top of the file:
@import WowWeeMiP;
Alternatively you can add this line into your Project-Prefix.pch (e.g. MiPSampleProject-Prefix.pch) file so that you don't need to import in each class your planning to use the SDK in.
-
Check that the project compiles successfully after completing the above steps by pressing ⌘+b in Xcode to build the project. The project should build successfully.
-
Choose the classes you want to handle the delegate callbacks from a MiP Robot, these classes will receive callbacks for when events happen (such as finding a new robot, robot connected, robot falls over etc) in this case we will simply choose our ViewController.
To receive MiP Finder notifications, in the ViewController.h file, modify the following sections:
- (void)viewDidLoad {
[super viewDidLoad];
// listen for callbacks
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mipFoundNotification:) name:MipRobotFinderNotificationID object:nil];
// Init the robot finder
[MipRobotFinder sharedInstance];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:MipRobotFinderNotificationID object:nil];
}
- (void)mipFoundNotification:(NSNotification *)note {
NSDictionary *noteDict = note.userInfo;
if (!noteDict || !noteDict[@"code"]) {
// Looks like an invalid notification
return;
}
MipRobotFinderNotificationValue noteType = (MipRobotFinderNotificationValue)[noteDict[@"code"] integerValue];
if (noteType == MipRobotFinder_MipFound) {
MipRobot *mip = noteDict[@"data"];
NSLog(@"Found: %@", mip);
mip.delegate = self;
// TODO: change this if you don't need to automatically connect to first mip
[mip connect];
} else if (noteType == MipRobotFinder_BluetoothError) {
CBCentralManagerState errorCode = (CBCentralManagerState)[noteDict[@"data"] integerValue];
if (errorCode == CBCentralManagerStateUnsupported) {
NSLog(@"Bluetooth Unsupported on this device");
} else if (errorCode == CBCentralManagerStatePoweredOff) {
NSLog(@"Bluetooth is turned off");
}
}
}
To receive MiP callbacks, in the ViewController.h file, change the interface to match the following:
@interface ViewController <MiPRobotDelegate>
In the interface definition add the following callbacks:
- (void) MipDeviceReady:(MipRobot *)mip {
NSLog(@"We are connected to MiP and ready to go");
}
- (void) MipDeviceDisconnected:(MipRobot *)mip error:(NSError *)error {
NSLog(@"A mip was disconnected");
}
- You should be now ready to go! Plug in an iOS device then compile and run the project using ⌘+r . When you turn on a MiP you should see some debug messages in the logs.
Once your application is listening to notifications, you need to issue the following call:
[[MipRobotFinder sharedInstance] scanForMips];
Scanning is battery intensive so we recommend you don't continuously scan, instead you can use this to scan for 5 seconds then stop:
[[MipRobotFinder sharedInstance] scanForMipsForDuration:5];
After a mip is found, the MipRobotFinder will send a notification with the following dictionary for the notification userInfo
{
"code": MipRobotFinder_MipFound,
"data": <MipRobot>
}
You can handle this notification using the following snippet from the sample project
- (void)mipFoundNotification:(NSNotification *)note {
if (noteType == MipRobotFinder_MipFound) {
MipRobot *mip = noteDict[@"data"];
NSLog(@"Found: %@", mip);
}
}
In our sample project we automatically connect to the first MiP we find, however you can store these references and use them later, there is no need to connect initially.
If you are going to search for Turbo Dave, you can use the function below:
[[MipRobotFinder sharedInstance] scanForMinions];
Same as finding MiPs, you are recommended to use this function for scanning:
[[MipRobotFinder sharedInstance] scanForMinionsForDuration:5];
To scan for all types of robot including MiP, CoderMiP and Turbo Dave, you can simply call:
[[MipRobotFinder sharedInstance] scanForAllRobots];
[[MipRobotFinder sharedInstance] scanForAllRobotsForDuration:5];
When MiPs are no longer available (e.g. the player turns one off), they will still contain a valid MipRobot instance object. The only way to know if the MiP is available is to try to connect to it, or do another scan.
For now we do not support CocoaPods. Pull requests are welcome.
Our SDK fully builds for the simulator, however at present the IOS simulator does not support Bluetooth Low Energy. This means you will not be able to properly test the functionality without using a real IOS device.
Our SDK is a universal build which means it includes support for all platforms. Currently however Apple does not allow frameworks which contain simulator support to be submitted to the appstore. We provide a special framework for this purpose, but also it's very easy to do yourself. You can use the lipo tool provided on OSX.
lipo -remove i386 -remove x86_64 WowWeeMiPSDK -output WowWeeMiPSDK
At present we don't have an Apple Watch device to test with. When it becomes available we are open to adding support for WatchKit.
At this stage we do not plan on releasing our full library source code.
The SDK is currently and will always be free for you to build and release your own applications. Your welcome to charge money or release free applications using our SDK without restrictions.
If you create a great application, all we ask is that you provide a link for people to purchase their own MiP so they can enjoy your product.
Currently the SDK is not available for OSX however we will make this available if it's important to you. If that's the case please open up an issue in the bug tracker. .
Yes we have provided the source code in our sample project, feel free to use this or make changes as you want. We would love pull requests.
The lower level BLE command protocol is available in our MiP-BLE-Protocol repository.
MiP iOS SDK is available under the Apache License, Version 2.0 license. See the LICENSE.txt file for more info.
You are free to use our SDK in your own projects whether free or paid. There are no restrictions on releasing into the Apple App Store or Google Play.
We happily accept any pull requests and monitor issues on GitHub regularly. Please feel free to give us your suggestions or enhancements. Please note that due to resource constraints we most likely cannot add new features to the MiP robot himself, but we will certainly consider them for inclusion to future robots/versions.
Tell your friends, fork our project, buy our robot and share with us your own projects! These are the best kinds of positive feedback to us.
- WowWee MiP Official App - Official app developed by WowWee using this SDK.
- MiP Robot Controller - Control your MiP using Pebble watch or your iPhone!
- Send us a pull request to add your app here