Friday, October 20, 2017

Android Wear Success ( or Not)


Here's what happens when you make a device without any programmer access...
Luckily, hot glue is reversible with alcohol.

To make everything work, I needed to reprogram my device to send out the isig every 5 minutes.  This way, another device (the watch) can listen for a notification.  I originally wrote this, years ago, to only send a response to a request, but this isn't really how BTLE wants to work.

Finally success with android wear.  The end result looks exactly like my last post.  Unfortunately, I can't really see those numbers without reading glasses, so I'm stuck with a custom watch face and bigger numbers.  I'll work on that, I'm still trying to figure out complications, they only work by accident now.

As to the android studio issues, here's what to do when it starts acting up.
To connect to the watch you do "adb connect {watch ip address}".  This should connect quickly.
Signs that you're screwed are the following:
- can't connect to the watch, and you get various meaningless errors
- studio hangs, windows crashes etc
- studio tells you it can't put the apk on the watch etc.
- you deploy code, but the debugger doesn't stay connected so no logging

First, toggle wifi off/on on the watch, then try the connect statement.  That generally fixes things.  If problems persist, restart everything.  Your PC, the watch and your router.  It will work for up to a week after that.  Also, you probably need to wake the watch up to program, otherwise Android Stuido will just sit there.  Not exactly user friendly.

I'm using the Sweet Blue bluetooth libraries.  That got me around allot of headaches.  One strange thing, the device name has to be LOWER case.  The device is programmed in UPPER case, and you can confirm that with a bluetooth scanner, but you need lower case for sweet blue.

Complications, aptly named, when developing this, I had no issue pushing a value to the complication and having the screen refresh immediately.  In practice, there is a delay, not enough that I care, the vibratory alerts happen real time, and you can tap the display to get the current value, but they can lag a few minutes.  Another issue on the programming side, if I update the code on the watch, the bluetooth doesn't always start up again, it binds the device, but no values show up.  Solution, restart the watch.

Well, that's it, I'll  update this post when I've figured out what the battery life is going to be.  The CC2500/RFduino device is good for 24 hours, I'm hoping the watch will hold out for a full day.
-----------
10 hours, and the battery indicator was at 50%...  I'll try again with WIFI off.
-----------
11/27... Basically, this is a failure.  Only works for a few hours at best, appear to be fighting with power management.  Most telling thing I've noticed, at some point when the watch has been untouched, the "Tick" event stops (every minute an event normally fires).

Monday, October 9, 2017

Android Wear... Sort of



What it should be. 

My Pebble round lasted 1.5 years.  The replacement 3 months.  Now I'm using a Pebble Time, which is working great, but for how long?

Saw a good price on the Moto 360, so I ordered one.  Turns out I was early to the party.  Waited around a month for the 2.0 update to finally show up.  2.0 being important since that allows watch to bluetooth device communication, and not just a phone.

Programming this thing is impossible.  The connection between Android Studio and the Watch is sketchy at best.  You have to connect from the Terminal using something like "adb connect 192.xxx.xxx.xxx".  But allot of the time, it won't connect.  Sometimes it seems like maybe it's the watch has gone to sleep.  Other times, you toggle wifi on the watch and then the connect will work.  Who knows.  Buggy.  I had one magical day where it sat in the charger and worked flawlessly.  Today, I might get the APK deployed, but then the watch disconnects, so no debug.

I was very surprised when I switched to a Kindle tablet.  Infinitely easier.  The device just shows up when you click run, imagine that. 

Oh, and bluetooth.  I have it working, but after reinstalling the app on the watch, I'm getting messages that I need to grant access to bluetooth.  You have to do this multiple places. 
1. In the manifest
2. After the program is deployed, there's a permissions section
3. And it appears, you need to answer the dialogs asking for access to bluetooth as well.

There's the rub.  This is running as a complication, there's nowhere to pop-up a dialog, so you are dead in the water, stupid.  You can see the issues "they" are having with security on Android.

At the moment I'm not sure how I had bluetooth working, and since I can't get a reliable debug(today)...  I know some of my tests I had a basic watchface, then I loaded the complication, and it all worked.  Thinking I got lucky, and the authorization I provided for one app bled over to another.

Going to implement this on the kindle first, just to work out the coding issues and then keep my fingers crossed that I can get something to work on the watch.

On the plus side, Apple announced that their watch will soon communicate directly with the G5, at least the manufacturers are getting the message that people don't want to be tied to a phone.  I may get an iWatch, as soon as that update hits, probably better long term possibilities there, sounds(and looks) like Android Wear is DOA.