Tip: Developing THETA "Client Mode" Applications


#1

Update Sept 2018: If you read to the bottom of this thread, you will see that we finally figured out the authentication is Digest Authentication and that you can find the IP address with DNS-SD. These are the two main tips. It seems to work for most developers. The main problem was in in figuring out the authentication mechanism


Ricoh released client mode access for the THETA V last month. This allows the THETA V to connect to your home or office WiFi router directly. The THETA mobile app then connects to the same router with WiFi and then connects to the THETA V to take pictures/videos and manage media. Several of us in the community are trying to build our own mobile app to connect to the THETA V in client mode. If you have an example, please share it.

Here’s what we know

Authentication

The mobile app needs to use DigestAuthentication to connection to the THETA V.
The default SSID and password format are based off the serial number of the THETA camera:

“THETAYLXXXXXXXX”, passwd is “XXXXXXXX”

ServiceName of THETA V

@felislynx contributed this information.

val mNsdManager = getSystemService(Context.NSD_SERVICE) as (NsdManager)
...
mNsdManager.discoverServices("_osc._tcp", NsdManager.PROTOCOL_DNS_SD, mNsdListener)
...
NsdServiceInfo.serviceName 

Authentication is problematic because DigestAuthentication is not supported in Retrofit or event android as is. I’ll test one of solutions (is it reliable or not).

Additional information on NetworkService Discovery is here.

Wireshark for Traffic Analysis

A friend of mine has client mode working and is using Wireshark for testing.

QT for testing

A community member is using Qt for testing on Windows, Mac OS, iOS, and Android. The Qt framework supports Digest Authentication as default. On Windows, Bonjour service is needed to resolve DNS-SD. “Bonjour Print Services (Windows)” is available here https://support.apple.com/downloads/bonjour_for_windows .

Next Steps and Help Needed

I will try and build a test app myself with Qt. If successful, I will post the results here. If anyone has any success, please post your results here.


RICOH THETA App Adds Client Mode WiFi
#2

There’s an extensive discussion of the Postman Digest Auth here:

An interesting point is that the Realm and Nonce for Digest Auth needs to be filled in. Right now, I don’t know what this means:


I person I know created a Qt test framework and has it working. I don’t have the code to his Qt test framework, so I’m trying to use Postman for my own test.

I’m not sure what the pollingDelay is:

image

I believe the Digest realm is “RICOH THETA V”
and the nonce is generated on a per session basis.

I’m now getting this in my headers.


#3

I have a working Python script for client mode with Digest Authentication. Here’s the gist.

Here’s the log from the script. I verified the the picture was taken.


Proper steps for working on Theta API v2.1
#4

I’m now using Python zeroconf for discovery during testing.

https://pypi.python.org/pypi/zeroconf

With this script

This is what I’m getting back:

Service THETAYL00101082._osc._tcp.local. of type _osc._tcp.local. state changed: 
ServiceStateChange.Added
Address: 192.168.2.101:80
Weight: 0, priority: 0
Server: THETAYL00101082.local.
No properties

#5

curl examples

Curl works on Windows 10 with the THETA in client mode.

GET example for osc/info

$ curl -D - --digest -u "THETAYL00101082:00101082" 'http://192.168.2.101/osc/info'

POST example for osc/state

POST Example
Note the use of -H for the header

$ curl -H "Content-Type:application/json" -D - --digest -u "THETAYL00101082:00101082" -X POST 'http://192.168.2.101/osc/state'

POST Example with data payload to takePicture with osc/execute

$ curl -d '{"name":"camera.takePicture"}' -H "Content-Type:application/json" -D - --digest -u "THETAYL00101082:00101082" -X POST 'http://192.168.2.101/osc/commands/execute'


RICOH THETA Factory Reset Using API
New THETA API version 2.1
#6

@codetricity we noticed very strange behaviour from Theta V (on 2 devices)
It is randomly hanging. If we are asking every 10 seconds or every few minutes for list of files in some time it stops responding. It is answering to mDNS requests but not TCP or ICMP requests. Sometimes we can call few hundred times sometimes few times until this hang. It is not responding to any device asking. Only shutting down and turning it on again fixes issue until next hang.


#7

Can you confirm that you are having this problem in client mode?

What are you using to test the THETA V API? Is it an Android app on a mobile phone?

Can you provide more information on your test configuration, especially the client command with digest-auth that you’re using to send the request?


#8

Yes, only in client mode. On direct mode it works like charm.
Restlet client, mobile app, python code.
After it hangs it wont respond to osc/info or
/osc/commands/execute

with body:

{
  name: "camera.listFiles",
  parameters: {fileType: "image", entryCount: 120, maxThumbSize: 640}
}

My colleague even made requests from router to check if it will work. So two cameras have same behaviour.
And it doesn’t matter what is making a calls, it will always hang itself


#9

thank you for this detailed response. I will try some tests myself. If I can replicate the failure, I will submit a report to Ricoh. Thanks for the good detail.


#10

Did you try DNS-SD, not mDNS? If you’re on Windows, you can use Bonjour Print Services for Windows to support DNS-SD.

I’ll try and get more info on this, but I think that the camera may not support mDNS right now, only DNS-SD.


#11

Theta is responding to DNS calls while being hung. Which means, we can discover it over network but we can’t call any API because it will timeout. As far as i remember Android NSD uses DNS-SD. Python code used mDNS


#12

I’ve updated camera to latest update (so update was made today). Issue persist. After some random time(and number of requests), camera stops responding to any api calls but it is still visible in network
i’m also checking it via: “avahi-discover” command on my linux.


#13

From my further tests, when camera hangs, i was able to discover via avahi, but while clicking for more details avahi also returns timeout: “Error: org.freedesktop.Avahi.TimeoutError: Timeout reached”. It looks like internal server is shutting down


#14

You have a great point here. I believe the THETA V client mode now works with mDNS as well as DNS-SD.

Testing is difficult right now as there are differences in the network which makes the problems difficult to replicate. I’ll keep trying and will also send this information to a guy I know at Ricoh.


#15

I’ve been thinking about this more. As the THETA V is using Network Service Discovery, I think that DNS-SD is the main supported method.

NSD implements the DNS-based Service Discovery (DNS-SD) mechanism, which allows your app to request services by specifying a type of service and the name of a device instance that provides the desired type of service. DNS-SD is supported both on Android and on other mobile platforms.

While mDNS does work, it is probably not tested as thoroughly. I’m still thinking that we should try and use DNS-SD when possible.

I know a developer that is using this for testing:

https://doc.qt.io/archives/qq/qq23-bonjour.html


#16

Testing dns-sd from Mac OS X

find available THETA V cameras

dns-sd -B _osc._tcp

find IP address

ping Instance_name.local

Example of finding IP address with ping for testing

image

Alternate way to find IP address with dns-sd

 dns-sd -G v4 THETAYLXXXXXXXX.local

Example of finding IP address using dns-sd

image


Dual-fisheye Images With THETA V Plug-in
#17

New video provides an introduction to the basic concepts of developing a client mode application.


#18

Hello, I saw this Address written in Python for THETA, sorry I am not familiar with Python, may I ask, how do I implement this with JAVA?


#19

Are you writing a Java (plug-in or Android) application? Or, are you just looking for the IP address?

https://developer.android.com/training/connect-devices-wirelessly/nsd

You can probably find the device if you look for the string below.

    _osc._tcp.

Once you locate the device, use digest authentication when you send the OSC (WebAPI) commands.

For digest auth, I have not tried the solutions below myself, but other people seem to have it working. If you implement something, please post an example.

https://issuetracker.google.com/issues/36919136#comment13

https://www.example-code.com/android/http_authentication.asp

Important If you are developing a plug-in, there is a different method to use the WebAPI. The above assumes you are working on an Android mobile application.


#20

Thank you for your reply, haha, I am developing the Android mobile terminal. The client mode of THETA V has been bothering me for a long time, until I saw your post yesterday. That Android Developers page is very helpful to me, thank you very much.