Wifi requests always times out on Android


#1

Hi there,

Is it normal for the Theta V to always time out when trying to execute commands?

I’m just trying to connect from an Android app, take a picture, download and save it. I used the code from the SDK and imported it, but it’s not very stable. Timeouts occur literally all the time. When setting the capture mode, taking the picture and downloading it. Sometimes it works without any hitch, but that’s about once in every 10 tries.

Is there something I’m missing with the development of apps using this product. I’m connecting via Wifi, then using HttpAsyncClient to post and get responses from the device.


#2

It should be a stable connection. You may need to upgrade your THETA V firmware, Android camera OS, or other component.

To test the basic camera stability, connect your camera to a laptop or desktop computer with Wi-Fi.

Then, run some tests from this guide:

Unofficial Guides

If you’re using the Wi-Fi API, you cannot have the THETA V plugged into your computer with a USB cable. You need to plug it into a wall socket USB charger. Unit from your Android phone will work.

Please confirm that you can run the API commands from a laptop or other device first. The connection between the device and the camera should be stable and not time out.

You can test the commands with curl, Postman, or other HTTP testing tool.

You can also use a browser:

http://192.168.1.1/osc/info

If it works on the laptop, but not on your Android device, please post the OS version, such as Android 7.1.

This article may be helpful.

Please provide the version number of the SDK you are using.


#3

Adding a screenshot of the available mobile SDKs.

From the SDK download page:

The RICOH THETA SDK includes a library and sample code that enable development in iOS or Android. Agree to the conditions of the end user license agreement below to download RICOH THETA SDK.

I did that, and then these are the options for mobile SDKs:


#4

Thank you so much for your replies guys. I appreciate the fast feedback. I’ll connect to the laptop now and report back.

I also have downloaded all those SDK’s and samples and I’m using the code from there to try and perform all my actions. It all times out. But I’ll get back to you in a bit.


#5

So the Theta V when connected to my PC works perfectly fine. No interruptions, command runs every time. When using the HttpConnector from the sample app in v2.1 API sample It times out on setImageCaptureMode everytime when trying to take a picture. Below is the info about the device I’m testing on.

I tried to use startSession on the Theta V but that doesn’t work as well. I thought maybe I needed to do that but that made no difference.

I always get “java.net.ConnectException: Failed to connect to /192.168.1.1:80”


#6

Can you confirm that you’re using the SDK for API 2.1 (which is the one that THETA V uses). It is Android v0.1.0.

The version numbering of the SDKs is weird and not obvious.

When the Android phone is connected to the THETA with Wi-Fi, there is a security window that pops up and asks if you want to stay connected to a Wi-Fi connection that has no Internet access. Did you select, “Stay Connected?”


#7

I can confirm that I am using the indicated SDK above. There’s a method in the sample called forceConnectToWifi() which I copied over and called in my capture activity.

This increased the stability to almost no timeouts.

And I didn’t accept that popup, I don’t get anything at the moment so didn’t have the option to stay connected. I also increased the sleep time to never sleep which also helps.

That function call made the stability much better.


#8

That is probably serving the same purpose. thanks for this additional information. I’ve seen the problem with disconnect on different Android devices, but usually there’s a way to resolve it.

The notification window comes from the Android OS. I’m not sure it comes up on all phones. I’ll find a screenshot and post it here.

Hopefully, the forceConnectToWifi() will resolve your problem.

BTW, as you like to tinker with the camera, you should join the partner program to put your THETA V into developer mode. Start the process here. The main advantage is that you can then put your camera into developer mode and access the internal Android OS. The partner program is free. There doesn’t appear to be a downside to joining as far as I can tell.


#9

Thanks for the time @codetricity I appreciate it.


#10

See this contribution from a community member.

It appears to be an issue with the Android device that I am working with, but that’s not to say it can’t happen on other devices. I’m on a Samsung Galaxy S7 Edge .

After selecting the Theta from the Wifi Settings Screen , there is a small period of time where the device is determining Internet connectivity. During this period of time, all queries to the Theta appear to be blocked, hence the SocketException I was receiving. Once the device has established the connectivity to the Internet (which is none, when connected to the Theta), I can communicate with the Theta.

Some points to note, I was using the WifiManager class to determine whether I was connected, halting all communication until it reported a state of COMPLETED through WifiManager.connectionInfo.supplicantState . Though the connection was COMPLETED, it still would fail. This is because of the Internet connection testing as I described above. It happens after the connection is fully established.

I thought a more elegant solution would be to look at the supplicantState in more detail using WiFiInfo.getDetailedStateOf(…), but it never reached a fully completed state here either, always returning OBTAINING_IPADDR even after Internet connectivity had been determined.

Ultimately, my solution was to attempt ‘camera.startSession’ over and over again until it succeeded, or the WiFi SSID changed to a host other than a Ricoh Theta. It doesn’t take more than a few seconds for the connection to get established, and though its brute force, it works.

I posted in the forums the other day, hoping someone else had a solution. I’ll follow up my post with this answer, so it can help the developer community.


Unrelated to above.

Regarding the above picture, there was discussion around this:

It’s in Japanese, but you can use translate.google.com to copy and paste the short Japanese text into English. The code itself and variables are nicely in English. It’s an old article and may no longer be relevant.

With the new features of Android 5.0 / Lollipop, even if you connect to a Wi - Fi pointer that is not connected to the Internet, it will switch to mobile data communication.
→ Reference: Function introduction of Android 5.0 (Lollipop): Function to automatically switch to mobile data communication when Wi-Fi can not access the Internet added | Gadget communication