Wednesday, 9 April 2014

API & Demos


What's inside?
  • InputStickAPI - if you want to develop your own Android apps.
  • DemoBT - simple demo app (source included), uses direct Bluetooth connection.
  • DemoService - simple demo app (source included), uses background service from InputStickUtility.
  • InputStickUtility - utility app. Required by apps, which use background service to communicate with InputStick. Allows to manage your InputStick device(s), and upgrade firmware if necessary.
Tomorrow I should be ready with Remote Controller app. Other apps will be released gradually, during next few days. Once an app becomes available, I'll post project update on IGG campaign page.

You need to allow to install applications form unknown sources in order to install .apk files (System settings -> Security -> Unknown sources). Apps don't require any unnecessary privileges (Bluetooth / Vibrations). During the weekend I'll do some testing using different Android OS versions (2.3, 4.0, 4.4), if everything turns out OK, I'll publish the apps on Google Play.

If you want to use the API, take a look at Demo apps. They are as simple as possible, it should be relatively easy to get started. I'll need some time to prepare better examples and documentation.

Some important remarks:
  • Supports Android 2.3 and higher.
  • Direct Bluetooth connection: there is no need to install InputStickUtility, but your application must take care of providing Bluetooth MAC address (and encryption key, once encryption will be fully supported). You also must add Bluetooth-related privileges in your AndroidManifest.xml file.
  • Background Service - InputStickUtility takes care of establishing Bluetooth connection. It is necessary to install the app, and add your InputStick device to database.
  • Adding API: in Eclipse go to Project Properties -> Android -> (Library) Add -> Select InputStickAPI 
  • Bluetooth pairing PIN: 1234.

7 comments:

  1. Some quick feedback:
    - the DemoService input box does not seem to transmit newlines (or other funny stuff like "tab") - maybe that's by design?
    - the "typing" speed is indeed about as fast as typing; for a short word that's fine, but for a substantially longer password / text it might be a bit slow in the future
    - even though the "only prompt me if there is more than one stick present" is selected in the utility, the demo app _does_ prompt me to select the single visible stick every time
    - how does one change the PIN? perhaps it was mentioned but I can't remember / find a way
    Best regards,
    Max

    ReplyDelete
  2. - this one is supposed to be just a single line of text (well it's a simple demo after all).
    - there is some room for improvements here (probably in next release).
    - my bad, it was trying to load settings form previous version. Fixed.
    - at this moment there is no way to change PIN and I'm not really sure if allowing this would be a good idea. After all if you forget new PIN and factory reset/loose/unpair your phone, the only way to connect again would be brute forcing 10k combinations. It will be possible to prevent unauthorized access once I'm done with password protection on protocol level (which won't completely lock the device if you forget it). Someone will be able to establish BT connection, but won't be able to do anything more.

    Thanks for your comment :)

    ReplyDelete
  3. Iam trying to import the demo with Windows and the adt-bundle from google, but i get the error "premature end of file" for each .xml file. After the import, eclipse had overwritten all xmlfiles with empty files. If i copy and paste the content of the xmlfiles from your zipfile it works. So i Imported the api and demoBT and tried it to run after i fixed the xmlfiles, but the compiled apk will crash on start (emulated and real device).
    Your precompiled demo works.

    I imported demoBT and the api and i added the api to the demoBT.

    Do you use Linux to compile your apps ?
    As iam VERY new do eclipse and androiddevelopment it could be that this is a layer 8 problem ;)

    ReplyDelete
    Replies
    1. IMO Eclipse + ADT is a bit buggy and there are often some problems with it. I use Windows version.
      Maybe XML problem is related to different encoding (just a guess)?

      I've just tried following things:
      1. Installed latest Eclpise + ADT bundle on a different PC.
      2. Opened ATD Manager and downloaded API18.
      3. Created new Android project (it wouldn't allow me to import projects into empty workspace)
      4. Downloaded and unzipped api.zip, unzipped projects.
      5. Imported InputStickAPI into workspace (import existing project into workspace).
      6. Imported DemoBT into workspace.
      7. After opening activity_main.xml I changed "Android version to used when rendering" to API18 (API20 won't work if there is a EditText View, because of new Android Wear).

      This worked fine, without any error messages.

      If you'd like to use InputStickAPI in a new project, created using latest Eclipse, you'll need to replace "/libs/android-support-v4.jar" file with latest version (which you'll find in your project's /libs/ folder). Otherwise Eclipse will display error that there are two different versions of the file.

      If this won't solve the problem here's another idea:
      Create new Android project, copy source files from InputStickAPI (src/com/inputstick/...), add Bluetooth permissions to AndroidManifest.xml. Use this project to build your app (copy/paste source from BTDemo).

      Let me know if any of this helped.

      Delete
    2. Thank you very much. Your way worked. I havnt reinstalled the bundle, I Just cleaned my projectfolder as i did before, but this time i followed your steps and it worked like a charm. I didnt found the the buttons for step 7, but it works now, so i can start learning :)

      Delete
    3. i now have tested your precompiled DemoBT. On my galaxy note 3 it will crash after get mac > select inputstick > press connect. I dont get the inputstick connection dialog from inputstick utitlity.

      Delete
    4. If you want to use InputStickUtility, use DemoService app.
      DemoBT will try to directly connect to InputStick, without going through Utility app (this is useful if you want to develop an app which won't require user to install Utility application).

      Delete