Tip: Developing THETA "Client Mode" Applications

Jay Goldman suggested this on a comment in DZone. I have not tested this yet:

If someone gets node or some type of JavaScript working with Digest Authentication to the THETA in Client Mode, please post a working example.

Thanks.

Update December 11, 2019

Update May 19, 2020

I moved the key points of the discussion to this article.

https://www2.theta360.guide/doc/article/19

There are two ways to connect your mobile app to the RICOH THETA with Wi-Fi.

  1. Access Point (AP) mode where the THETA camera functions as a hotspot. The mobile phone connects to the THETA as if the camera were a hotspot or Wi-Fi router

  2. Client Mode (CM) where the THETA camera connects to your home or office router. Your mobile phone connects to the same router

Authentication

The RICOH THETA requires Digest Authentication for client mode. When you use client mode, you must use Digest Authentication in addition to the username and password.

On the THETA V, the username is similar to this: THETAYL00105377

The password is the numerical digits. Example: 00105377

HTTP GET example

In the example below, I am using curl on Linux Ubuntu 20.04 from the command line to test a HTTP GET command to a RICOH THETA V. You can also run curl on Mac or Windows.

$ curl --digest --user "THETAYL00105377:00105377" -X GET http://192.168.2.101/osc/info

Response

{"api":["/osc/info","/osc/state","/osc/checkForUpdates","/osc/commands/execute","/osc/commands/status"],"apiLevel":[2],"_bluetoothMacAddress":"00:26:73:D5:4C:40","endpoints":{"httpPort":80,"httpUpdatesPort":80},"firmwareVersion":"3.21.1","gps":false,"gyro":true,"manufacturer":"RICOH","model":"RICOH THETA V","serialNumber":"00105377","supportUrl":"https://theta360.com/en/support/","uptime":1555858,"_wlanMacAddress":"00:26:73:D5:AA:64"}

HTTP POST example

When you use POST, you must include the header.

curl --digest --user "THETAYL00105377:00105377" -H "Content-Type:application/json" -X POST http://192.168.2.101/osc/state

Response

{"fingerprint":"FIG_0067","state":{"_apiVersion":2,"batteryLevel":1.0,"_batteryState":"charged","_cameraError":[],"_captureStatus":"idle","_capturedPictures":0,"_latestFileUrl":"http://192.168.2.101/files/150100525831424d42079d18e0b6c300/100RICOH/R0010048.JPG","_pluginRunning":false,"_pluginWebServer":false,"_recordableTime":0,"_recordedTime":0,"storageUri":"http://192.168.2.101/files/150100525831424d42079d18e0b6c300/"}}

HTTP POST with data payload

The next example takes a picture.

curl -d '{"name":"camera.takePicture"}' --digest --user "THETAYL00105377:00105377" -H "Content-Type:application/json; charset=utf-8;" -X POST http://192.168.2.101/osc/commands/execute

Response

{"id":"29","name":"camera.takePicture","progress":{"completion":0.00},"state":"inProgress"}


December 19, 2021 notes on trying to get Digest Auth working with Flutter.

https://issueexplorer.com/issue/dart-lang/http/605

try using dart:io directly with preserveHeaderCase.

I’m exploring using the camera in Client mode (model THETA Z1). I am able to run osc/info and osc/status fine (Digest auth is working) but it times out when attempting any kind of osc/commands/execute. If I switch to Direct mode all the commands work perfectly… is Client mode intended only for info, status and perhaps downloading the images?

What’s more is that if I run the command without digest authentication it does immediately return with Unauthorized, but once I add digest authentication it just hangs… and only on commands/execute, on osc/info and osc/status it works.

Edit: Okay, I got it to work. For some reason the info and status end points would accept the way I programmed my digest authentication, however commands/execute wouldn’t. I reworked my authentication code and now it works.

You need to send the HTTP header as follows:

Content-Type: application/json;charset=utf-8

See this:

Example using free tool Insomnia, which is similar to postman.


Post again if you have problems.

Z1 Test with curl

curl -H "Content-Type: application/json" -X POST "http://192.168.2.200/osc/commands/execute" -d $'{"name": "camera.takePicture"}'

Please try the headers and post again.

Usually, the state (POST) and info (GET) work without the headers. There may be some difference in how the HTTP header is sent in the two versions of your code.

2 Likes

I see! Thank you for your help craig. I will try to figure out which headers are different and why.

2 Likes

I am curious as to what people are using client mode for. If you have a moment, can you either post your use case here or send me a DM.

I am interested in use cases as I am thinking of building a client mode desktop demonstration for the THETA X connected to Ethernet. As the THETA X can run indefinitely over Ethernet, I am thinking of building a desktop kiosk demo, either on Windows or Linux desktop or both as a “get ideas started” type of demo for using the THETA X for commercial use.

2 Likes