esaj Posted September 14, 2015 Share Posted September 14, 2015 This is my "labor of love" that was born out of the need for hobby16 to have a app for recording data from his custom telemetry-devices (he's still working on those, as far as I know) and reverse-engineering the protocol used by Gotways and (at least) older King Songs. If your wheel works with the Gotway-app, it should work with this. It's pretty rough around the edges still, and not extensively tested, should work fine now, but I give no guarantees of anything. This is the first time I've written any software directly to Android, and in total have maybe about one weeks worth of experience with it, so there can be all sorts of quirks and problems with different Android-versions (and even different devices using the same version). YMMV I tested the application installation & usage process with vee's Huawei-phone (Android 4.2.2, that's where the screenshots are from) and I've tested it during development with my Lenovo A10-70 A7600-F (or something along those line, Android 4.4.2) -tablet. Here's instructions for installation & usage: Github-release: https://github.com/esaj/Wheelemetrics/releases/tag/160126 Github sources: https://github.com/esaj/Wheelemetrics Forum download: It's a basic Android apk, should be no developer-mode needed or anything, but your phone must be allowed to install software outside Google Play/whatever they're usually got from. If you've installed the Gotway-app from outside Google Play, you should be good to go, otherwise: Quote From your smartphone or tablet running Android 4.0 or higher, go to Settings, scroll down to Security, and select Unknown sources. Selecting this option will allow you to install apps outside of the Google Play store. Depending on your device, you can also choose to be warned before installing harmful apps. This can be enabled by selecting the Verify apps option in the Security settings. On devices running an earlier version of Android, go to Settings, open the Applications option, select Unknown sources, and click OK on the popup alert. After downloading the app, and starting to install it, you are requested to accept the permissions the application needs: Modify or delete the contents of your SD card: The application writes log files to your sd-card & stores settings Access Bluetooth settings / pair with Bluetooth devices: Well, duh, the application uses bluetooth to talk with your wheel Control vibration: Vibration is used for speed warnings (the warnings can be disabled inside the app, see later in this post) Test access to protected storage: I must admit that I have no idea what this is... read-rights for SD-card? No usage data or similar is collected or sent anywhere (as you see, the app has no rights to connect to internet), also I don't keep any records of when, who or where is accessing the file for download (probably the server hosting it has some logs, but I don't think I even have access to those). Use as you wish, but if you decompile it (it isn't obfuscated) and make a gazillion dollars thanks to it (like that's going to happen anyway :D), please do at least consider giving a small donation to me For the more technically inclined, here are the required permissions from AndroidManifest.xml: Quote <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.VIBRATE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> After installation, this is shown: Run in background is probably needed so that the app won't fall asleep even if your phones' screen does (there are calls to prevent the display from turning off, but I have no idea whether they work on all phones and all power-saving settings and whatnot). If you plan on trusting the vibration-alerts to keep you from riding over the speed-cliff, better turn that on (it was off by default at least on vee's phone). Opening the application should show you the following screen (note that it's locked into landscape-mode, but will rotate 180 degrees if you turn your phone upside down): The Speed, Power, Voltage, Current, Temperature, Trip & Odo -texts are replaced with actual values after the wheel is connected. On the right side are buttons for connecting to the wheel (Connect), hiding/showing speed warning settings (Speed Warnings), hiding/showing the graph in the middle (Graph view) and for recording telemetry data (Record). When Connect-button is tapped, this view will be opened: By default it will show all already paired BT-devices that support the SPP (Serial Port Profile), others will be filtered off the list. If your wheel is not yet paired, you can tap the "Scan for devices". Wait a while, as the scanning might take some time. I left out the filtering of SPP-devices only from scanning, in hindsight, probably should have done that. Anyway, this is the result when I scanned for devices: That's my TV, and my work computer. GotWay_0763 is probably vee's MSuper, and GotWay_1200 is his MCM2s, so I connect to that (of course the wheel must be already turned on at this point). After successful connection (you might have to try it again in case it doesn't go on first go, but usually it seems to work pretty well), the values on the main display will start updating and the graph is being drawn: The graph -view can be scrolled back and forth by swiping (I think I set it to save last 500 samples or so), and zoomed in with pinching. Under the graph view are a couple of text boxes, button to clear the graph and selection for which value is graphed: Update graph - controls whether the graph is updated or not, in case you want to "stop it" to check something closer Scroll to end - controls whether the graph will jump to the end when new data arrives, you might want to uncheck this if you want to scroll backwards while new data is coming in (ie. graph is updated) Clear graph - clears the graph. Pretty self-explanatory, huh? Voltage - This is the button (well, a "Spinner" in Android-lingo, kinda like a drop-down list) used to change what is being shown in the graph, hitting it you're given a list of choices: Picking any of these, the graph will be cleared and it will begin graphing the chosen value from incoming data. Here I've switched it to show power and nudged the wheel a bit (it's actually leaning against my desk here, so the power is really low): (BTW, the grey rectangles below are the text-edit field for writing commands to the wheel, and the lighter gray is the "Send"-button, they just don't fit in this small screen, and you probably won't need them. If you want to play around with those, see the command listing in the Gotway/Kingsong protocol reverse-engineering -topic: http://forum.electricunicycle.org/topic/870-gotwaykingsong-protocol-reverse-engineering/?do=findComment&comment=10155). The graph can be hidden with the "Graph view"-button, if you want to see just the immediate values and the graph feels like it's distracting: "Speed Warnings" -button show the current settings for the speed warnings: You can set the values between 4/5 (first/second warning) and 43/44km/h (first/second warning). Enable warnings"-checkbox can be used to enable/disable the warnings, they're enabled by default. Settings are saved & remembered after restart. Note that if you don't hide the graph-view before pulling up the speed warning-settings, it will look a bit weird on small screen: If you haven't got enough screen real-estate, hide the graph view first so it's easier to use the settings Sorry, I know that the UI still sucks balls The last button (Record) on the right-side controls the recording of telemetry-data. If you tap it, the text will change to show "Stop record". The app is now recording incoming data from the wheel. You can change the graphed value and warning settings etc., it will store all incoming data regardless of the UI: After you hit stop record, the app will ask under what name the file should be saved: Actually, the file is already saved in the directory & name the dialog shows, basically you can just rename it here. If you hit cancel, the file will still be there under the original name "wheelemetrics_log_YYYYMMDD_HHmmSS.txt", where Y/M/D/H/m/S are replaced with year, month, day, hour, minute and second of the time you started to record. WARNING: Should you choose an existing filename the app will NOT ask whether you want to overwrite, but simply overwrite directly, destroying the original data... Probably something I should work on The format of the file is comma-separated values, as follows: TIMESTAMP, SPEED, POWER, VOLTAGE, CURRENT, TEMPERATURE, TRIP, ODO where TIMESTAMP is milliseconds since the epoch (1.1.1970 12AM GMT). The data rate seems to be 5Hz (one data packet per 200ms), but the timestamp drifts a bit as it's stored in the app, and there can be delays, like BT-packet retransmits and the software handling of the packets might cause some delays here and there SPEED is the speed in kilometers per hour (dot as separator) POWER is the power used, calculated simply as VOLTAGE * CURRENT (the wheel does not send this), rounded down to nearest integer VOLTAGE is, well, voltage in volts (dot as separator) CURRENT is current in amperes (dot as separator) TEMPERATURE is the temperature in Celsius (dot as separator), I think it's measured from the mosfets of the mainboard itself, not from motor TRIP is the trip meter since last start up, in kilometers (dot as separator) ODO is the odometer, ie. the total mileage of the wheel, in kilometers (dot as separator) And that's pretty much it. The app is closed totally by hitting Back-button, before which it will still check with you. (And this time it really should close itself up properly, unlike the earlier version linked elsewhere in the forums ) The app SHOULD work fine even if it's backgrounded but still running, but I haven't tested this very extensively, so please be careful in case you're using it to prevent going over the speed cliff and it crashes/falls asleep while you don't notice Link to comment Share on other sites More sharing options...
This topic is now archived and is closed to further replies.