pypavlok
pypavlok copied to clipboard
API not fully exposed
I'm in the process of making an Android-compatible version of this, and would like to offer my efforts in reverse-engineering the GATT interface. By my count, there are 4 proprietary characteristics available, but there's at least 15 more not exposed. Is there a plan to implement the rest? If so, should we create a separate documentation system for a project-independent viewpoint?
AffectiveMan, do you have a public project available for this?. I was just going to start on something like this as well. Was just chatting with Maneesh on Facebook about Bluetooth API. (No direct information from him on that, other than pointing to this project). I'm an Android programming newbie (although lots of programming experience otherwise).
@AffectiveMan, yes, Pavlok exposes 28 characteristics, but only 12 of them are used in the official Android app (reliable information from jadx :)).
Some of them are not yet ported to pypavlok, but I'm planning to implement them this week:
- Alarm function (e6b17021-195d-4e84-b216-034caeb05498)
- Firmware updates (about five related characteristics)
- Hand movement checks (accelerometer, b641c9b0-62e0-4cea-983e-498550c27305)
There are also several services that I haven't checked yet, it will be the next stage:
- DEVICE_INFORMATION_SERVICE = "0000180a-0000-1000-8000-00805f9b34fb"
- ACCELEROMETER_SERVICES = "F211B484-50CD-4DBD-97EF-BAF1CBA7B36A"
- BATTERY_POOL_PERIOD = "26CB603D-0F79-4E5E-BB9C-B56C84761537"
- CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb"
- DEVICE_INFORMATION_SERVICE = "0000180a-0000-1000-8000-00805f9b34fb"
I don't know anything about remaining characteristics, but I think that maybe they are exported by base firmware or are required by BLE standard.
@flagist0 Thanks for letting me know your info! I've worked with GATT protocols before, so I can explain a few things. "Services" have "Characteristics" and both have a UUID, so the "DEVICE_INFORMATION_SERVICE" service contains things like the "Hardware Revision String" characteristic that you already implemented. (There are generic industry standards for the basic items and for things like battery charge percent, etc.) Also, the "CLIENT_CHARACTERISTIC_CONFIG" is for reading and writing values, so you can ignore that.
I've created a hierarchy of the standard and proprietary services and characteristics, filling it in with all of the information that you've reverse-engineered so far. If we spend time working on it, I'm sure we could figure out the remaining items as well. My data would work great in a Wiki page, but that feature isn't turned on here.
I'm making an Android version locally but could push it up to Github, and could then turn on the Wiki feature on my page. Would you mind having two separate projects that we can coordinate together?
Also @tabletguy , let me know what you're thinking. The more we work together, the more we can get done. And yes, Maneesh is a cool guy. :) He'd be intrigued by what we come up with, and he seems open to discussing ideas we have on future directions of the hardware/firmware.
@AffectiveMan Ok, thank you for explanation! I've never worked with Bluetooth before and GATT terms were rather confusing for me.
I enabled the wiki for the project.
And of course it would be cool to coordinate, but I'm not sure if it's possible to make some reusable parts here except the documentation.
@flagist0 Thanks for enabling the wiki. I'll add my docs in now. Reusing documentation is huge, since that's the real meat of this project and counts for more than language particulars.
And if you have any questions about GATT let me know. I'm not a world expert but I've implemented some FW and Android apps using it, so I've covered a lot of ground.
@flagist0 Just FYI, I don't think I have write access to the wiki. If that's not possible, I'll work on pushing my Android test code to another project later today and can put a copy up there.
@AffectiveMan Yes, sorry, I added you as a project collaborator now. Thank you! The main thing I'm not sure about is characteristic 'type'. As far as I understand, there is some kind of introspection in GATT that describes the data type read/written by characteristic. But I couldn't find how to determine it.
@flagist0 and @tabletguy I've done my data dump to the wiki (https://github.com/flagist0/pypavlok/wiki/PavlokGATT). I'll finish it up tonight with the permission, properties, and descriptors.
The 'type' as in data input-out requirements for a GATT interface is unknown, in that the server requires the client to know how to handle it. Thus, it allows for proprietary protocols to maintain secrecy by lack of transparency. The process of reverse-engineering is to experiment with random data to find something that works, then to do boundary testing, then to conjecture on what the data is supposed to mean. It's rough, but that's what RE is all about.
I was concerned/scared about doing RE for the Pavlok since I didn't want to fool with something that's intentionally designed to cause an electrical shock, but you have already figured out the API for the shock functionality. I'll have a full random-data generator for the rest of the characteristics up and running by this weekend, then I'll start updating the Wiki with my findings.
Or... Maneesh and the Pavlok crew could give us some pointers on how to avoid problem areas (like the FLASH programming interface) or even to letting us know the API directly so that we can focus on making this project semi-official and to allow for usability over hack-and-slash. :)
Can you add me as a collaborator too??
@AffectiveMan, we had a talk with Maneesh yesterday, and he said that there are some not yet revealed features in Pavlok that we could accidentally expose. Could you please contact him?
Hi, thanks for details so far. I assume you're planning on links to general resources regarding GATT, etc.
I'm located in the USA, but am in Rishikesh, India until middle of April.
I used to work on drivers, etc. but that was almost 40 years ago (in assembler). I am interested in writing direct to Pavlok, partly because internet here is spotty at the best of times, and the current reliance on a middle man type of website isn't a good long term solution for stand-alone apps, IMO.
Also, my interest is in exploring ways to use Pavlok in a "positive" manner, such as language study, developing good habits (via reminder and queries), etc. Although I have a lot of software development experience, none to speak of with Android or Bluetooth, so I'd probably be more passive at this time.
I'd be surprised if Pavlok didn't have some simple encryption on at least parts of their interface, such as unlocking for flashing, etc. I don't want to mess up their development plans by exposing things prematurely as well.
I'm subscribed to this, so I see all the messages.
@ tabletguy Your needs are sound, since not everyone can guarantee access to the internet at all times. I'm going to focus my attention from now on to getting an Android API class implemented with the features we have as of now. I can use that with some self-automation software I've been working on in my spare time.
Let me know if you'd like the same API to be ported to another OS. iPhone and other Apple products are a possibility since I can code iOS, but you'd have to deal with the auth problems yourself as that's beyond my skill-set.
@AffectiveMan Thanks! I'm developing in Xamarin, but focused on Android for now, since that's what I have for real hardware.
If it's documented, I might want to run the same or similar app on Windows, since my language study software is on those two platforms.
On Thu, Jan 21, 2016 at 8:18 PM, AffectiveMan [email protected] wrote:
@ tabletguy Your needs are sound, since not everyone can guarantee access to the internet at all times. I'm going to focus my attention from now on to getting an Android API class implemented with the features we have as of now. I can use that with some self-automation software I've been working on in my spare time.
Let me know if you'd like the same API to be ported to another OS. iPhone and other Apple products are a possibility since I can code iOS, but you'd have to deal with the auth problems yourself as that's beyond my skill-set.
— Reply to this email directly or view it on GitHub https://github.com/flagist0/pypavlok/issues/1#issuecomment-173593282.
@tabletguy Windows development will work, but you have to make it a UWP/Metro app, since the BS (BLE) API isn't available in .Net for Windows Forms. Check out here: https://msdn.microsoft.com/en-us/library/mt270288.aspx
Thanks for link. I will check it out tomorrow.
Since I don't have access to Wiki, perhaps add this link to a FAQ section?
On Thu, Jan 21, 2016 at 9:42 PM, AffectiveMan [email protected] wrote:
@tabletguy https://github.com/tabletguy Windows development will work, but you have to make it a UWP/Metro app, since the BS (BLE) API isn't available in .Net for Windows Forms. Check out here: https://msdn.microsoft.com/en-us/library/mt270288.aspx
— Reply to this email directly or view it on GitHub https://github.com/flagist0/pypavlok/issues/1#issuecomment-173620131.
Is it possible to add discussion pages to the wiki that would be available to all Github registered users?
Is there a reason to separate ID definitions into "pyPavlok" and "AndroidPavlok"? I would think the ID string could be the same, regardless of which programming language?
@tabletguy Sorry for delay, I added you as a collaborator
Thanks. No worries :) We both have other jobs too! haha
On Fri, Jan 22, 2016 at 12:35 PM, Alexander Presnyakov < [email protected]> wrote:
@tabletguy https://github.com/tabletguy Sorry for delay, I added you as a collaborator
— Reply to this email directly or view it on GitHub https://github.com/flagist0/pypavlok/issues/1#issuecomment-173829570.
@tabletguy I added the original data to the Wiki page, so there's a lot of info from what I was doing (specifically making an Android version of this project). There's a lot more I intend to add, but I've been real busy the last couple of days. With the snow storm coming along, I should have free time over the weekend and plan to organize everything nice and neat.