[BOUNTY] Mobile SDK


#1

We are opening up a new bounty for someone who can write a Mobile SDK for us. There will be two bounties of equal value, one for the Android side and one for the iOS side (so one person could technically win both, or two people can win them separately).

The main goal is to put together a library that people can quickly import into their apps so they can interact with bluz. The SDK should be added easily through normal package manager best practices for each platform (Gradle for Android, Cocoapods for iOS but also open to using Carthage).

The SDK should handle all of the lower layer interactions with bluz, eliminating any users need to call respective BLE functions on the platform. Instead, these basic calls should be available:

  • StartScanForDevices: Takes in a time period to scan for and a callback function. A BluzDevice object should be handed to the callback every time one is discovered
  • StopScanForDevices: Stops any currently running scan
  • SetStateCallback: Takes in a callback function that will be called whenever the state changes on a BluzDevice object. So whenever a device connects/disconnects, the callback function should be called with eh BluzDevice object and the new state
  • SetDataCallback: Takes in a callback function that will be called whenever data arrives from a connected Bluz DK device. The callback function should take a BluzDevice object and the data as a byte array
  • Connect: Takes in a BluzDevice object that was handed back from the scan call and connects to it. Should also take an optional boolean argument specifying if the device should be connected to the cloud or not
  • Disconnect: Takes in a BluzDevice object and disconnects it from the phone
  • SendData: Sends data to a connected bluz DK. Takes a BluzDevice object and a byte array to send
  • GetDeviceID: Gets the Particle device ID of a connected bluz DK, takes in a BluzDevice object

The exact naming and syntax of functions above should be coordinated through the bluz team so that we don’t have wildly different syntax between the two platforms. They should be the same basic syntax/framework on iOS and Android. We will coordinate with the people who decide to try so that things are consistent. Callback functionality can be handled appropriately on each platform by using subclasses.

The SDK should handle all cloud connections in the background. So when Connect is called, it will allow bluz to request opening a socket to the Paricle cloud and will handle all communications between Particle and bluz seamlessly.

Language of the SDK is up to you somewhat. Android should be Java, iOS can be Objective-C or Swift.

Deliverables need to be full source code published online along with instructions for installation and use. Installation into any new project should be done through a package manager as noted above. We will test your SDK by creating samples apps on the specified platform and making sure all functions work.

You can of course use our open source apps as a good starting point, they already do all of the above functionality. You basically are creating a wrapper around it and getting it integrated with the package manager.

Prizes! The prize for each will be a $150 gift card to be used on our store, which can be used for any items we have available. Again, each bounty gets this, so if one person does both, you would get a $300 gift card!

If you are going to attempt this task, please respond here so people know and we don’t have super duplication. Plus, we want to coordinate with you, so please let us know!


#2

#3

I’m going to write a cordova/ javascript version for both platforms. This is not exactly what you are asking for but more useful for me and colleagues. So, if anyone wants to do the native version(s) that’s good too. I suppose that if we can converge on a test UI for all 3 that would also be nice.


#4

I am honestly not too familiar with Cordova. I know the very high level (write apps for Android and iOS like web apps) but I have never used it or really know how it works.

If you create a library/package in Cordova, can you do ll the same functions I had listed above? And then anyone can easily import that into their own Cordova app? What is the package manager called?

Can Cordova access all the underlying Bluetooth and TCP/IP functions to do everything?

If all that is the case, I would be happy to extend the bounty to include your Cordova work as well. I certainly want to enable as many people as possible to write their own apps.

As for the UI, I am leaving that up to the users app. This SDK should only expose the functions needed to discover, connect, and control bluz DK. The UI can be up to the users own use case.


#5

Thx @eric,

People who are already working on the specific platforms will doubtless prefer native SDKs but we find cordova very useful for prototyping. Yes, we write the whole app in html and javascript. Existing libraries contain any required native code. There is no common package manager as such. We usually build in cordova’s CLI which creates android .apks directly and for IoS an object that you can use in Xcode without modification. There is also a web IDE but we do not find that as convenient.

Yes, there is an excellent BLE library (from @randdusing). It does everything we need for talking with BLE devices such as Bluz.

I’m not too concerned with a bounty but will try to work with your suggested structure. Early versions may use an existing structure but that can evolve later.

My reference to UI was only in relation to making the SDK testable. As you say, individual apps will each have it’s own UI.


#6

Hi Paul, did you get somewhere with cordova?
is this the plugin you are referring to?

EDIT: got my response, I’m guessing is this one.

thanks!
Gustavo.


#7

@eric, any updates on this Mobile SDK? When will it be available?


#8

Honest answer: I’m not sure. This hasn’t been a priority as our apps are open source and can easily be replicated for anyone that needs to build an app for bluz.

If you want to tackle it, the bounty is still open!


#9

@eric, I found your iOS code on Github, https://github.com/bluzDK/iOS-app, but it was 11 months ago. Are you planing to release the most recent version?

Thanks.


#10

That is actually the most recent version, it is from February. We have some overhauls of the app planned, they are in the queue.

The code for the gateway/connection portion won’t change, however, only new features will be added on top. So this should be a good blueprint for any app you would want to write. You can take the Libraries folder basically as-is and use that in your project. There clearly would need to be some work to better turn this into a well-documented SDK, but it is a start for now.


#11

@eric, I just tried to run your Bluz-ios-app. I am getting all sorts of errors. I did Pod Install (success) and launch the Xcode Workspace > convert to latest swift version (successful and saved) > run. get the following errors:

Please let me know what I need to do to be able to run your sample code. I am using Xcode 8.0.

Thanks.


#12

We are still using Swift 2, the app was tested with Swift 2.2 to be exact. 2.3 should work as well as it is a minor upgrade. So you shouldn’t update to the latest version of Swift, you should continue to use 2.3.


#13

@eric, no conversion of swift, getting similar errors (17 errors). Converted to syntax 2.3 Swift I am getting the errors below:


#14

Well, looks like we have some work to do for iOS 10: https://forums.developer.apple.com/thread/51222

Adding these changes to my list, but in the meantime, is it possible to work on iOS 9?


#15

@eric, I had iOS 9 before and still errors. Just tried iOS 8 and still getting the following errors:

Which iOS version were you using?

Thanks.


#16

Building for iOS 9, everything works from my end. I suspect it isn’t using Swift 2.3 and is still on 3, those errors seem to indicate that.


#17

@eric, I am using Xcode 8.0. I just tried coveting again to Swift 2.3. Still getting errors:


#18

Sorry for the delay. I will add this to my list, there must be some incompatibilities with XCode 8/swift 2.3.

If you had the time, Pull Requests are also always welcome!


#19

@eric, thanks for the update. If you don’t mind could you please give this some priority. I really would like to be able to run this for claiming devices. Sort of a related question, I am assuming I can’t claim the device without the device being online or power off. Also for production, are you willing to ship it with DeviceId printed on the packaging?

Thanks.


#20

I will certainly try to get to this as soon as possible. It looks to be only a few changes in the CBManagerState, that link I posted earlier seems to provide the workaround so you could make the changes as well if you are in a hurry and are trying to modify the app for your purpose.

Correct, the device must be online for it to be claimed.

As for printing the device ID on the packaging, that isn’t something we plan to do. We can possibly accommodate requests like this, but we would need a lot more details (like number of devices you wanted). If this is for a special project or product, you can reach out to us at hello@bluz.io and we can discuss further over email.