Capturing data traffic between a Sony DSC-QX10 and a smartphone - page 2 - Non-CANON cameras development - CHDK Forum supplierdeeply

Capturing data traffic between a Sony DSC-QX10 and a smartphone

  • 23 Replies
  • 20611 Views
Re: Capturing data traffic between a Sony DSC-QX10 and a smartphone
« Reply #10 on: 12 / December / 2013, 18:05:40 »
Advertisements
Guys, I just pushed something to github you might enjoy.

It turns:

Quote
Smite@Tank:~/dev/sony-camera-api> POST /sony/camera '{"method":"setCameraFunction", "params":["Contents Transfer"], "id":1, "version":"1.0"}'
{"error":[403,"setCameraFunction"],"id":1}

into:

Quote
Smite@Tank:~/dev/sony-camera-api> POST /sony/camera '{"method":"setCameraFunction", "params":["Contents Transfer"], "id":1, "version":"1.0"}'
{"id":1,"result":[0]}

https://github.com/erik-smit/sony-camera-api

Enjoy.

Re: Capturing data traffic between a Sony DSC-QX10 and a smartphone
« Reply #11 on: 14 / December / 2013, 08:34:20 »
Enjoy.

I'm indeed enjoying it  :D

These are really, really great results! So, basically, you just need to create a SHA256 hash by first feeding the "magic string" to the hash generator, next feed the "DG" challenge, and finally send back a base64 representation of the hash digest back to the camera.

I could reproduce your results with a little Python script. (BTW, it seems that the "methods" field of the request must contain exactly the value as used by your script. I tried to enable either just one method, or all methods as returned by getMethodTypes -- but that just resulted in an "illegal request" error.)

So, finally, we can begin to use these camera as we like. Well... we need to figure out what exactly all these freshly enabled methods do, but we already have a good starting point.

Thanks for your great work, smite!

Re: Capturing data traffic between a Sony DSC-QX10 and a smartphone
« Reply #12 on: 16 / December / 2013, 04:56:10 »
So, basically, you just need to create a SHA256 hash by first feeding the "magic string" to the hash generator, next feed the "DG" challenge, and finally send back a base64 representation of the hash digest back to the camera.

Yes. I have one detail to add:

Libtp.so derives the 'magic string' from the certificate that signed the Sony PlayMemories application.
I wasn't able to reproduce this proces, but shortcircuiting it by just storing the result.

Try unpacking and rebuilding the apk with apktool. You will get an error after connecting to the camera.

Re: Capturing data traffic between a Sony DSC-QX10 and a smartphone
« Reply #13 on: 27 / December / 2013, 12:42:27 »
Using smite's nice discovery how the locked part of the API can be unlocked, I played a bit with with a Python class that implements the camera API. The class itself is sort of an exercise how far you can get without writing a single special method for each API call, but instead try to get awy with just using __getattr__(). This worked quite well, but dealing with the results of the API calls can be a bit annoying because the JSON data returned by the camera can for example be a nested list with exactly one "inner element", like [["foo"]] -- even for calls where returning more that one string would not make much sense.

Anyway, I attach this class and a few related unit tests to this post. The unit test show what I figured out about the API. Most things was quite easy because the API call getMethodTypes() returns nice descriptions of the API calls.

Everything is based on work done with a DSC-QX10. I assume that it would be possible to get more interesting results with cameras from the NEX series.

In order to successfully run the tests, you'll need to unlock the API with smite's actEnableMethods.sh script. (two requests issued by the script would be easy to integrate into the Python class, but I was too lazy to do it up to now ;))

Notes about some details:

I could not figure out how to successfully call getFNumber, getSupportedFNumber, getAvailableFNumber, setFNumber, getFocusMode, getSupportedFocusMode, getAvailableFocusMode, setFocusMode, getAvailableShutterSpeed, getSupportedShutterSpeed, getShutterSpeed. (Also note that getMethodTypes does not return anything about a call like setShutterSpeed).

I suspect that this just shows limitations of what the API for the QX10 supports -- the camera is probably just not supposed to be used by people who like to tweak the settings even a little bit. The API for NEX models hopefully supports the calls mentioned above -- but since I don't have one, I can't tell for sure...

A really odd detail:

When I wrote the test for touchAFPosition, I first got an error in another, already existing, test that worked fine before: test_whiteBalance.

It turned out that getAvailableWhiteBalance() returns an empty list of white balance mode, when an AF position has been selected by calling setTouchAFPosition(). Cancelling the AF posititon again removes the error. Other API calls may be affected too, but I did not check this.

Anyway, I wonder if this weirdness is the only one that might lurk in the API, and if Sony deemed it too embarassing to describe it in the API docs but instead just locked down the API...


Re: Capturing data traffic between a Sony DSC-QX10 and a smartphone
« Reply #14 on: 25 / January / 2014, 15:14:09 »

Enjoy.

Wow this is great! I do enjoy it!

I use A7 camera and this works or so it seems. I do not have the getAvailableCameraFunctions on the A7.

But it seems other things like ISO settings, aperture and speed work well.

Does anyone know if and how I can download the real files form the SD card? Not the 2M preview files.

I would like to download the RAW files when possible.  That will be great for tethered shooting.

Re: Capturing data traffic between a Sony DSC-QX10 and a smartphone
« Reply #15 on: 25 / January / 2014, 15:19:57 »

Notes about some details:

I could not figure out how to successfully call getFNumber, getSupportedFNumber, getAvailableFNumber, setFNumber, getFocusMode, getSupportedFocusMode, getAvailableFocusMode, setFocusMode, getAvailableShutterSpeed, getSupportedShutterSpeed, getShutterSpeed. (Also note that getMethodTypes does not return anything about a call like setShutterSpeed).

I suspect that this just shows limitations of what the API for the QX10 supports -- the camera is probably just not supposed to be used by people who like to tweak the settings even a little bit. The API for NEX models hopefully supports the calls mentioned above -- but since I don't have one, I can't tell for sure...

 cameras have modes. A mode essentially allows you to set/get certain type of setting. Do you have Shooting mode to something that allows you to control aperture (FNumber), speed or iso? I suppose there is all auto mode where you cannot set anything. If you switch to Program, Aperture, Speed, manual then may be more things will work.

As well I believe Sony issued QX firmware update to unlock bit more of the settings. So give that a try too.

Re: Capturing data traffic between a Sony DSC-QX10 and a smartphone
« Reply #16 on: 25 / January / 2014, 18:33:09 »

Does anyone know if and how I can download the real files form the SD card? Not the 2M preview files.

I would like to download the RAW files when possible.  That will be great for tethered shooting.

From the "data exchange logs" I gathered as described in the first and second post in this thread, it seems that the camera supports UPnP. I haven't yet looked into details, but aside from the "excessive bureaucracy" that is typical for XML it should not be too hard to retrieve the image and movie files from the camera. I can also show some examples of the stuff I found tomorrow (too late for me to do it right now ;)


 cameras have modes. A mode essentially allows you to set/get certain type of setting. Do you have Shooting mode to something that allows you to control aperture (FNumber), speed or iso? I suppose there is all auto mode where you cannot set anything. If you switch to Program, Aperture, Speed, manual then may be more things will work.

The only call I found for the QX10 that comes somewhat close to selecting some sort of mode is getAvailableExposureMode(). I suppose that this call returns things like Tv, Av, Program etc for "real" cameras, but the QX10 returns nothing more than 'Intelligent Auto', 'Superior Auto', 'Program Auto'. And I have no clue what exactly the differences between these modes are...

Quote
As well I believe Sony issued QX firmware update to unlock bit more of the settings. So give that a try too.

Thanks for the heads-up! I'll have a look tomorrow.

Re: Capturing data traffic between a Sony DSC-QX10 and a smartphone
« Reply #17 on: 26 / January / 2014, 08:48:14 »
From the "data exchange logs" I gathered as described in the first and second post in this thread, it seems that the camera supports UPnP. I haven't yet looked into details, but aside from the "excessive bureaucracy" that is typical for XML it should not be too hard to retrieve the image and movie files from the camera. I can also show some examples of the stuff I found tomorrow (too late for me to do it right now ;)

Seems that my memory deceived me. My logger does _not_ record the UPnP data (but it could with a few patches...). Anyway, I had also used tcpdump to record the commuication between playmemories  and the QX10. Some filtered results from copying an image file are attached.

To sum up, the client sends several POST requests to the camera's HTTP UPnP server (http://10.0.0.1:64321/upnp/control/ContentDirectory for the QX10). In line 224 of the attached file starts a request that finally returns a bunch of image URLs (looking like http://10.0.0.1:60151/LRG_DSC00020.JPG?%21...). A similar request follows in line 254, and in line 305 the client finally begins the download of an image file.

I have no clue if you can access raw images files this way on the A7 -- I am pretty sure that the QX10 just can't store raw files, so I even did not bother to try...

Thanks for the heads-up! I'll have a look tomorrow.

I've found a few articles on the web reporting that Sony announced a firmware update, but could not find anything on Sony's supoort web sites. But the update was announced for January, and this month is not yet over.


Re: Capturing data traffic between a Sony DSC-QX10 and a smartphone
« Reply #18 on: 26 / January / 2014, 20:21:54 »
Adeuring,

What you are looking at in filetrans.txt is a filetransfer via the DLNA protocol.
This is a standard. A very verbose, bureaucratic one as you noticed.

Use method 'SetCameraFunction' with parameter 'Contents Transfer' on the QX10 and it will retract its lens and enable DLNA.

Regarding the firmware: This has not yet been released by SONY. I'm waiting anxiously for it. ;)

Re: Capturing data traffic between a Sony DSC-QX10 and a smartphone
« Reply #19 on: 27 / January / 2014, 15:43:03 »


Use method 'SetCameraFunction' with parameter 'Contents Transfer' on the QX10 and it will retract its lens and enable DLNA.

Just FYI A7 actually is quite bad with these function and mode things. It has a mode dial on top of the camera and the API simply tells me I cannot set shoot mode (it even does not list setShotMode API although calling such method tells you that it is not accessible). I only get the following

            "getShootMode",
            "getAvailableShootMode",
            "getSupportedShootMode",

Also I have no setCameraFunction API on A7....seems QX wins there :-)

The unlock worked well in Java! Thank you a lot!

Do you think I can capture one of those secrets from A7? I mean the first part you have as constant in the script? I wonder if there may be A7 functions that are simply not included in your list and thus I am not seeing/enabling them now.

I am new to Android programming. I have a nexus phone so hope it will not be hard.

 

Related Topics