SteveyO/Hue-Emulator

Not working with Physical devices

Closed this issue · 10 comments

From the Android Virtual Devices it is working fine, but the same App when I try to run from Phone App, its detecting the Lights but Setting colors not working.

This isn't a great deal of information. What is not working exactly? Can you at least post the JSON that is being sent to to the emulator.

Sorry for not given the complete information.
Here is the function calling on button click which is executing but not reflecting on Emulator. No error message shown, however same thing works on Android AVD (Virtual Devices).
In the following code, it loops each virtual light as expected (listing out all the lights properly).

public void randomLights() {
PHBridge bridge = phHueSDK.getSelectedBridge();

    List<PHLight> allLights = bridge.getResourceCache().getAllLights();
    Random rand = new Random();

    for (PHLight light : allLights) {
        PHLightState lightState = new PHLightState();
        int x = rand.nextInt(MAX_HUE);
        lightState.setHue(x);
        // To validate your lightstate is valid (before sending to the bridge) you can use:  
        // String validState = lightState.validateState();

        TextView vw = (TextView)findViewById(R.id.sound);
        vw.setText(String.valueOf(x));

        bridge.updateLightState(light, lightState, listener);
        //  bridge.updateLightState(light, lightState);   // If no bridge response is required then use this simpler form.
    }
}

Thanks. This is a bit better and gives me something to go on. The Java code looks fine to me and this works with the emulator.

How are you connecting to the Hue Emulator from your code?
Are you using code similar to this:
PHAccessPoint lastAccessPoint = new PHAccessPoint();
lastAccessPoint.setIpAddress("192.168.1.1:8000");
lastAccessPoint.setUsername("newdeveloper");
phHueSDK.connect(lastAccessPoint);

The only thing I can think of (why it would work on your Android Virtual Machine and not a real device) is you are probably using a local connection to the bridge (127.0.0.1 or localhost).

A local connection would work on your AVD as they are both on the same physical machine, but for a device you need your machine IP Address (i.e. use ipconfig/all if on windows or ifconfig on Unix to find your IP). Let me know if this is the issue.

Steve
p.s. In the Java SDK, you can see your bridge IP with:
System.out.println("Bridge IP: " + bridge.getResourceCache().getBridgeConfiguration().getIpAddress());

Thank you so much. Actually I am using the ip address and not 127.0.0.1 or
local host. Also as I mentioned it is enumarting the lights correctly with
their properties. Only thing is the colors not changing.
On 27 Nov 2015 16:30, "Steve" notifications@github.com wrote:

Thanks. This is a bit better and gives me something to go on. The Java
code looks fine to me and this works with the emulator.

How are you connecting to the Hue Emulator from your code?
Are you using code similar to this:
PHAccessPoint lastAccessPoint = new PHAccessPoint();
lastAccessPoint.setIpAddress("192.168.1.1:8000");
lastAccessPoint.setUsername("newdeveloper");
phHueSDK.connect(lastAccessPoint);

The only thing I can think of (why it would work on your Android Virtual
Machine and not a real device) is you are probably using a local connection
to the bridge (127.0.0.1 or localhost).

A local connection would work on your AVD as they are both on the same
physical machine, but for a device you need your machine IP Address (i.e.
use ipconfig/all if on windows or ifconfig on Unix to find your IP). Let me
know if this is the issue.

Steve
p.s. In the Java SDK, you can see your bridge IP with:
System.out.println("Bridge IP: " +
bridge.getResourceCache().getBridgeConfiguration().getIpAddress());


Reply to this email directly or view it on GitHub
#21 (comment)
.

when you call the bridge.updateUpdateLightSate call, do you see any JSON in the Emulator console?
All JSON (Requests and Responses) is by default are displayed in the console, so this will help you isolate the problem.

I see the json debug message while enumerations of less but not getting
anything while setting the colors. That means the request is not sending to
the emulator properly. However I see them using Android avd.
Thank you for your kind help.
On 27 Nov 2015 20:19, "Steve" notifications@github.com wrote:

when you call the bridge.updateUpdateLightSate call, do you see any JSON
in the Emulator console?
All JSON (Requests and Responses) is by default are displayed in the
console, so this will help you isolate the problem.


Reply to this email directly or view it on GitHub
#21 (comment)
.

Am not sure what you mean by "enumeration of less"? Please can you clarify. If the request is not sending to the emulator properly then the issue is in your code, what makes you think it is an emulator problem?

Yes first request for listing led lights are sending properly. May be I
need to check the code from phone as it's working through virtual device.
As you mentioned it may not be the issue with emulator.
On 27 Nov 2015 20:37, "Steve" notifications@github.com wrote:

Am not sure what you mean by "enumeration of less"? Please can you
clarify. If the request is not sending to the emulator properly then the
issue is in your code, what makes you think it is an emulator problem?


Reply to this email directly or view it on GitHub
#21 (comment)
.

Ok, If you are getting Lights in Enumeration (bridge resources cache) then obviously you have managed to connect to the Emulator so not a network/IP Address issue. Are you sure your bridge.updateLightState code is getting fired? Maybe try removing your TextView code temporarily and add some debugging and monitor LogCat.

Am closing this issues as it doesn't look like an emulator issue. If you prove otherwise, please re-open and explain.
Thanks.