|
@@ -6,9 +6,177 @@
|
|
|
<description>Recent content in Posts on Pleasant Programmer</description>
|
|
|
<generator>Hugo -- gohugo.io</generator>
|
|
|
<language>en-us</language>
|
|
|
- <lastBuildDate>Fri, 24 Jun 2016 00:00:00 +0000</lastBuildDate>
|
|
|
+ <lastBuildDate>Sun, 15 Jan 2017 19:31:00 +0800</lastBuildDate>
|
|
|
<atom:link href="http://pleasantprogrammer.com/posts/rss.xml" rel="self" type="application/rss+xml" />
|
|
|
|
|
|
+ <item>
|
|
|
+ <title>OpenPrepPad</title>
|
|
|
+ <link>http://pleasantprogrammer.com/posts/openpreppad.html</link>
|
|
|
+ <pubDate>Sun, 15 Jan 2017 19:31:00 +0800</pubDate>
|
|
|
+
|
|
|
+ <guid>http://pleasantprogrammer.com/posts/openpreppad.html</guid>
|
|
|
+ <description>
|
|
|
+
|
|
|
+<p>Smart electronics and IoT (Internet of Things) are all the rage these days. You
|
|
|
+have a lot of companies sprout up trying to make the next big thing, which also
|
|
|
+leads to a lot of failures big and small. Pebble, the maker of my smartwatch,
|
|
|
+got bought out by Fitbit recently. This left watch owners without any official
|
|
|
+support, but thankfully, community members <a href="http://rebble.io/">stepped up</a> to continue
|
|
|
+maintaining it.</p>
|
|
|
+
|
|
|
+<p>Another casualty of the IoT boom was the <a href="http://theorangechef.com/">Orange Chef</a> <a href="https://www.amazon.com/Orange-Chef-Smart-Scale-Silver/dp/B00KFW8L90">Prep Pad</a>. It&rsquo;s a
|
|
|
+bluetooth connected weighing scale to make it easy to track your calories and
|
|
|
+carb/fat/protein intake. My dad bought it last year only to find out that the
|
|
|
+app was incredibly buggy. The search function doesn&rsquo;t work which makes the whole
|
|
|
+thing practically useless. I also found out later that you can&rsquo;t even download
|
|
|
+the app to use the scale anymore.</p>
|
|
|
+
|
|
|
+<p><strong>Note</strong> I just found out as I was writing this post that it <em>may</em> get supported
|
|
|
+by <a href="http://www.prnewswire.com/news-releases/perfect-company-acquires-orange-chefs-prep-pad-related-ip-continues-momentum-in-the-connected-kitchen-300383178.html">another company</a>.</p>
|
|
|
+
|
|
|
+<p>So the app is useless, but at least you can use it as a scale, right?</p>
|
|
|
+
|
|
|
+<p><img src="http://pleasantprogrammer.com/galleries/openpreppad/preppad.jpg" alt="Prep Pad" /></p>
|
|
|
+
|
|
|
+<p>Nope. The device has no display whatsoever. The only controls on it are the
|
|
|
+on/off button and a green LED that isn&rsquo;t even that useful at telling you whether
|
|
|
+it&rsquo;s on or not. At this point, it&rsquo;s just a giant paperweight.</p>
|
|
|
+
|
|
|
+<h2 id="reverse-engineering">Reverse Engineering</h2>
|
|
|
+
|
|
|
+<p>Since I essentially had nothing to lose, I tried poking at the thing to figure
|
|
|
+out how it works. I didn&rsquo;t really have experience with bluetooth besides trying
|
|
|
+to get my bluetooth mouse connected on Linux. The main thing I used then was
|
|
|
+<code>bluetoothctl</code> which is essentially a CLI for managing bluetooth devices so I
|
|
|
+started there.</p>
|
|
|
+
|
|
|
+<p>I started up <code>bluetoothctl</code> and turned on the Prep Pad. And it showed up!</p>
|
|
|
+<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span>[bluetooth]# power on
|
|
|
+[CHG] Controller ... Class: 0x00010c
|
|
|
+Changing power on succeeded
|
|
|
+[CHG] Controller ... Powered: yes
|
|
|
+[bluetooth]# scan on
|
|
|
+Discovery started
|
|
|
+[CHG] Device 1C:BA:8C:21:7C:BB RSSI: -51
|
|
|
+[CHG] Device 1C:BA:8C:21:7C:BB Name: CHSLEEV_00
|
|
|
+[CHG] Device 1C:BA:8C:21:7C:BB Alias: CHSLEEV_00
|
|
|
+</pre></div>
|
|
|
+
|
|
|
+<p>I then connected to it, which was surprisingly easy.</p>
|
|
|
+<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span>[bluetooth]# connect 1C:BA:8C:21:7C:BB
|
|
|
+Attempting to connect to 1C:BA:8C:21:7C:BB
|
|
|
+[CHG] Device 1C:BA:8C:21:7C:BB Connected: yes
|
|
|
+[CHG] Device 1C:BA:8C:21:7C:BB Name: CH BTScale_00
|
|
|
+[CHG] Device 1C:BA:8C:21:7C:BB Alias: CH BTScale_00
|
|
|
+</pre></div>
|
|
|
+
|
|
|
+<p>Now normally, when you turn the device on, the green light flashes occasionally.
|
|
|
+Once I connected to it, the green light stayed on permanently. Clearly, I was
|
|
|
+making progress. A lot of services were also discovered but I had no idea what
|
|
|
+those things were at that point.</p>
|
|
|
+
|
|
|
+<p>After a lot of poking around, I could check the general device information. You
|
|
|
+could get hardware, software and firmware version. There&rsquo;s also the device
|
|
|
+serial number which was nowhere on the actual physical device.</p>
|
|
|
+<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span>[CHSLEEV_00]# select-attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0010/char0017
|
|
|
+[CH BTScale_00:/service0010/char0017]# attribute-info
|
|
|
+Characteristic - Firmware Revision String
|
|
|
+ UUID: 00002a26-0000-1000-8000-00805f9b34fb
|
|
|
+ Service: /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0010
|
|
|
+ Value: 0x31
|
|
|
+ Value: 0x2e
|
|
|
+ Value: 0x31
|
|
|
+ Value: 0x33
|
|
|
+ Value: 0x41
|
|
|
+ Value: 0x00
|
|
|
+ Flags: read
|
|
|
+[CH BTScale_00:/service0010/char0017]# read
|
|
|
+Attempting to read /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0010/char0017
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0010/char0017 Value: 0x31
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0010/char0017 Value: 0x2e
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0010/char0017 Value: 0x31
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0010/char0017 Value: 0x33
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0010/char0017 Value: 0x41
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0010/char0017 Value: 0x00
|
|
|
+ 31 2e 31 33 41 00 1.13A.
|
|
|
+[CH BTScale_00:/service0010/char0017]#
|
|
|
+</pre></div>
|
|
|
+
|
|
|
+<p>There was also a service which contained Accel Enable, Accel Range, Accel
|
|
|
+X-Coordinate, Accel Y-Coordinate, and Accel Z-Coordinate. I guess it stands for
|
|
|
+accelerometer, which is probably what it uses to weigh things.</p>
|
|
|
+<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span>[CHSLEEV_00]# select-attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char0024/desc0026
|
|
|
+[CH BTScale_00:/service0023/char0024/desc0026]# read
|
|
|
+Attempting to read /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char0024/desc0026
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char0024/desc0026 Value: 0x41
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char0024/desc0026 Value: 0x63
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char0024/desc0026 Value: 0x63
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char0024/desc0026 Value: 0x65
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char0024/desc0026 Value: 0x6c
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char0024/desc0026 Value: 0x20
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char0024/desc0026 Value: 0x45
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char0024/desc0026 Value: 0x6e
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char0024/desc0026 Value: 0x61
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char0024/desc0026 Value: 0x62
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char0024/desc0026 Value: 0x6c
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char0024/desc0026 Value: 0x65
|
|
|
+ 41 63 63 65 6c 20 45 6e 61 62 6c 65 Accel Enable
|
|
|
+</pre></div>
|
|
|
+
|
|
|
+<p>I couldn&rsquo;t read from any of the Accel Coordinates. It kept saying permission
|
|
|
+denied. I could however, notify on them. But that didn&rsquo;t yield anything as well.
|
|
|
+What I <em>could</em> read was Accel Enable, which was set to 00. I guess that means it
|
|
|
+was off. After writing 01 to Accel Enable, I found I could get values out of
|
|
|
+Accel X-Coordinate!</p>
|
|
|
+<div class="highlight" style="background: #f8f8f8"><pre style="line-height: 125%"><span></span>[CHSLEEV_00]# select-attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char0024
|
|
|
+[CH BTScale_00:/service0023/char0024]# write 01
|
|
|
+Attempting to write /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char0024
|
|
|
+[CH BTScale_00:/service0023/char0024]# select-attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char002a
|
|
|
+[CH BTScale_00:/service0023/char002a]# notify on
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char002a Notifying: yes
|
|
|
+Notify started
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char002a Value: 0x5b
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char002a Value: 0xa3
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char002a Value: 0x02
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char002a Value: 0x00
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char002a Value: 0x55
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char002a Value: 0xa3
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char002a Value: 0x02
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char002a Value: 0x00
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char002a Value: 0x59
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char002a Value: 0xa3
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char002a Value: 0x02
|
|
|
+[CHG] Attribute /org/bluez/hci0/dev_1C_BA_8C_21_7C_BB/service0023/char002a Value: 0x00
|
|
|
+</pre></div>
|
|
|
+
|
|
|
+<p>I tried pressing the scale down a few times, and the values changed accordingly.
|
|
|
+Now, I just had to figure out how to convert the values into grams. It looked
|
|
|
+like the values were 32-bit integers sent as 4 bytes. In the above example it
|
|
|
+would be <code>0x0002a35b</code>, <code>0x0002a355</code>, <code>0x0002a359</code> or 172891, 172855, 172899. The
|
|
|
+values also decrease as you exert more effort on the scale. So assuming you have
|
|
|
+take the initial value as <em>tare</em>, you simply subtract any succeeding from that
|
|
|
+<em>tare</em> and you can have your &ldquo;weight&rdquo;.</p>
|
|
|
+
|
|
|
+<p>The values I got didn&rsquo;t seem to be grams though. After weighing some things on
|
|
|
+an actual scale and comparing the values I got, I found I can just divide the
|
|
|
+values by 14 and get something in grams. That 14 is entirely a magic number
|
|
|
+though and I have no idea whether other Prep Pad&rsquo;s would have the same constant.</p>
|
|
|
+
|
|
|
+<h2 id="openpreppad">OpenPrepPad</h2>
|
|
|
+
|
|
|
+<p>With all that figured out, I went ahead and made a <a href="https://github.com/thatsmydoing/openpreppad">simple CLI application</a>
|
|
|
+to interface with the Prep Pad. Ironically, node was the simplest thing I found
|
|
|
+that had <a href="https://github.com/sandeepmistry/noble">nice bluetooth library support</a> so that&rsquo;s what I wrote it in. I
|
|
|
+also added most of the technical details in the README for that as well.</p>
|
|
|
+
|
|
|
+<p>While this is all well and cool, I doubt the intersection of Linux users and
|
|
|
+people who <s>got ripped off</s> bought the Prep Pad is anyone besides me. In
|
|
|
+light of that, I&rsquo;m in the process of making a React Native version of the app,
|
|
|
+but that&rsquo;s still a work in progress. Who knows, if the new owners of Prep Pad
|
|
|
+are good, I might not even need to finish it.</p>
|
|
|
+</description>
|
|
|
+ </item>
|
|
|
+
|
|
|
<item>
|
|
|
<title>Haproxy Charset</title>
|
|
|
<link>http://pleasantprogrammer.com/posts/haproxy-charset.html</link>
|
|
@@ -717,38 +885,6 @@ Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
|
|
|
<p>GTFS Editor is very much in development. Just getting it to run was problematic. There also seem to be a lot of missing issues judging from the Github Issues page. If you want to try it out for yourself, I suggest you clone <a href="https://github.com/thatsmydoing/gtfs-editor">my branch</a> as I&rsquo;ve fixed the issues discussed earlier. The default login is <code>admin:admin</code>.</p>
|
|
|
|
|
|
<p>Even after getting it to run, it&rsquo;s still not quite usable. Not in the UX sense, but you really can&rsquo;t do much with it. There is no way to import the GTFS data into the webapp. There is something like import from TransitWand but even that is unclear to me. And even if we do get that running as well, we still don&rsquo;t have any data we can play around with. We would need database dumps from the already running tools for these to be of any use right now.</p>
|
|
|
-</description>
|
|
|
- </item>
|
|
|
-
|
|
|
- <item>
|
|
|
- <title>One Bus (or maybe Jeep) Away</title>
|
|
|
- <link>http://pleasantprogrammer.com/posts/one-bus-or-maybe-jeep-away.html</link>
|
|
|
- <pubDate>Tue, 09 Jul 2013 00:00:00 +0000</pubDate>
|
|
|
-
|
|
|
- <guid>http://pleasantprogrammer.com/posts/one-bus-or-maybe-jeep-away.html</guid>
|
|
|
- <description><p>Link: <a href="http://onebusaway.org/">http://onebusaway.org/</a></p>
|
|
|
-
|
|
|
-<p><strong>TL;DR</strong> no routing; useless in Philippines</p>
|
|
|
-
|
|
|
-<p>OneBusAway is a transit information app. It provides data on what bus stops are near you, which buses pass by. You can also get schedules and the route of a particular bus given the number. It can also provide realtime updates like how many minutes until the next bus arrives. It does not, however, provide routing. There is no support for providing directions to get from point A to point B.</p>
|
|
|
-
|
|
|
-<p>It&rsquo;s comparable to what you get in some bus stops abroad. You&rsquo;d get a vicinity map and a list of buses passing through the stop. You might also get the times when the next buses will pass. It&rsquo;s useful for locals who already know how to get around, and want to avoid waiting for the bus. But it&rsquo;s not particularly good for people who want to know how to get around the city.</p>
|
|
|
-
|
|
|
-<p>OneBusAway is quite comprehensive in its platform support though. There is a webapp, apps for iOS, Android and Windows Phone, as well as SMS and Voice support. This would all be nice but we don&rsquo;t have the necessary infrastructure yet in the Philippines. We don&rsquo;t have bus or jeepney stops. We also wouldn&rsquo;t have realtime data to make the app particularly useful.</p>
|
|
|
-
|
|
|
-<p>You can try it out for yourself by following their <a href="https://github.com/OneBusAway/onebusaway-application-modules/wiki/OneBusAway-Quickstart-Guide">Quickstart Guide</a>. One caveat is you will have to add <code>-P tripEntriesFactory.throwExceptionOnInvalidStopToShapeMappingException=false</code> when building the bundle. This has to do with the OneBusAway having difficulty matching the <a href="https://github.com/OneBusAway/onebusaway-application-modules/wiki/Stop-to-Shape-Matching">stops to the shape data</a>.</p>
|
|
|
-
|
|
|
-<p>Here&rsquo;s some screenshots of the app with the Philippine data. Notice how you only see the stops but there isn&rsquo;t a line for the route. This is a problem with our GTFS data. Also, at some points it&rsquo;s hard to tell where the jeep is going to pass since there isn&rsquo;t any indication of order either. This is more of a OneBusAway problem. It usually expects there to be shape data available.</p>
|
|
|
-
|
|
|
-<p><a href="../galleries/transit/onebusaway1.png"><img src="../galleries/transit/onebusaway1.png" alt="OneBusAway" title="All the stops along Katipunan Avenue are named Katipunan Avenue." /></a></p>
|
|
|
-
|
|
|
-<p>It doesn&rsquo;t really handle too many routes passing through a stop. The list just overflows past the bubble. You can still actually read it by panning the map. It&rsquo;s just a bit weird though.</p>
|
|
|
-
|
|
|
-<p>If you also noticed, there are usually 2 of each route. This is how the jeepney data was modeled as jeep routes might be different going one way and going back. This isn&rsquo;t the case for all jeeps though, so it might also be an implementation issue with the GTFS editor.</p>
|
|
|
-
|
|
|
-<p><a href="../galleries/transit/onebusaway2.png"><img src="../galleries/transit/onebusaway2.png" alt="OneBusAway" /></a></p>
|
|
|
-
|
|
|
-<p><a href="../galleries/transit/onebusaway3.png"><img src="../galleries/transit/onebusaway3.png" alt="OneBusAway" /></a></p>
|
|
|
</description>
|
|
|
</item>
|
|
|
|