Wednesday, December 11, 2019

YI Dash Car Camera API


Why

A friend asked me if I could create an android app using his new Yi Dash Car Camera. Camera's parameters look very good and the price was quite low. He showed me a native Android app that was already on Google Play. He needed to download a list of video files and search them by specific time.

About camera

  • Camera has its own wifi. So If you want to do something, you need to be connected to its wifi. 
  • Camera automatically starts to record a video (each about 3 min long) when it's turned on.
  • During download or changing settings recording is stopped.
  • In the official app, there is also an option to take a picture (this is done via screenshot from the stream).

What I did

First, I've tried some SDK from the camera's company, but it was not supporting this one. After quick mail to support, I got confirmed that this camera does not have any official SDK. My next move was to download their app and look at the source code. I've used online decompiler and got lucky. The source code was not obfuscated. Yay! After 20 minutes of searching through the source code I was still not sure how to get what I wanted. I didn't want to spend few days reading and testing. I was looking for another shortcut. I've connected the phone to an android IDE console and filter the package messages. And there it was. All the requests were logged into the console. In combination with source code, it was pretty easy to achieve what I needed.

How does it work

Every time you want to access camera, you need to call open stream request. It most probably opens a session and allows you to call another requests. I'm just guessing because there is no documentation. This session lasts for about 10-15 seconds. Responses are in XML format.

For example, to download video files you need to make 3 requests in order.

  • open stream http://192.168.1.254/?custom=1&cmd=8001
  • change mode to media http://192.168.1.254/?custom=1&cmd=3001&par=2
  • request for file list http://192.168.1.254/?custom=1&cmd=3015


For downloading video, you don't need to do anything. You just need to be connected to camera's wifi.


What I've learned

Aside from downloading videos, I was also searching for how to capture and download image from camera. For my surprise, there was no capture image feature. They were using a snapshot from the video stream.

Result

I've created a github example project that shows how you can download files from the camera. It's just few simple calls to download the files. There are still plenty of other settings that can be done via API. If someone would be interested in this camera, this might save him a few hours.

Share: