Forums - updateControls() in LightControlFragmen class in "CSRmesh Control Application v1.3 for Android" can't update control properly

1 post / 0 new
updateControls() in LightControlFragmen class in "CSRmesh Control Application v1.3 for Android" can't update control properly
terrannara
Join Date: 10 Aug 16
Posts: 8
Posted: Wed, 2016-08-10 06:58

HI.

I have a problem, please help.

updateControls() in LightControlFragmenin class in "CSRmesh Control Application v1.3 for Android" can't update control properly

Here is a strange code. the part of LightControlFragment class. I did not fix anything.

-----------------------------------------------------------------------------------------------------

protected void updateControls(int selectedDeviceId) {

    Device dev = mController.getDevice(selectedDeviceId);
    
    if (dev != null) {
       LightState state = (LightState)dev.getState(StateType.LIGHT);
       PowState powState = (PowState)dev.getState(StateType.POWER);
        // Set UI to reflect the selected light's state if the state is valid.
        mEnableEvents = false;
        mEnablePowerSwitchEvent = false;
        mPowerSwitch.setChecked(powState.getPowerState() == PowerState.ON);
        mEnablePowerSwitchEvent = true;
        if (state.isStateKnown()) {
            int r = (int) state.getRed() & 0xFF;
            int g = (int) state.getGreen() & 0xFF;
            int b = (int) state.getBlue() & 0xFF;
            float[] hsv = new float[3];
            Color.RGBToHSV(r, g, b, hsv);
            mColorWheel.setCursor(hsv[0], hsv[1]);
            mBrightSlider.setProgress((int) (hsv[2] * 100.0f));
            mCurrentColor = Color.rgb(r, g, b);
            mColorWheel.invalidate();
        }
        else {
            mColorWheel.setCursor(0, 0);
            mColorWheel.invalidate();
        }
        mEnableEvents = true;
    }
    else {
        mEnableEvents = false;
        mBrightSlider.setProgress(100);
        mEnableEvents = true;
    }
}

-----------------------------------------------------------------------------------------------------

state.getRed(), state.getGreen(), state.getBlue() and powState.getPowerState() always return 0, whatever the light state is.

and thus updateControls() function can't update controls properly.

 

this is my situation. I am seeing this link https://wiki.csr.com/wiki/CSRmesh.

I have a CSRmesh development kit   

I am working with "CSRMeshLight" in CSRmesh v1.3 - Libraries (56025_CSRmesh-1.3-Examples-Applications_icp)

and Android Application (CSRmesh Control Application v1.3 for Android)

 "CSRMeshLight" in CSRmesh v1.3 - Libraries   is compiled with CSR xIDE and download to development kit succesfully.

and android Application is installed on Android phone (SM-N910S, Android v6.0) succesfully.

The problem is..

getState() returns LightState(or PowState) type casted data(state or powState) with Insignificant data in it

and powState.getPowerState(), state.getRed(), state.getGreen() and state.getBlue() always return 0, each time updateControls called.

 

There is some explanation about getState() in API documentation (in 55945_CSRmesh-1.3-Android-Application_icp/doc)

Class LightModelApi

getState(int deviceId)

Get the state of a light.

 

When i saw the that explanationI thought,

if Android App request the "DATA about state of light" to NODE at first, then it will be transfered from NODE to Android App over the air. 

but actually nothing is transfered over the air when getState() is called. nothing is happend. 

help me. Please tell me what is wrong..

 

 

  • Up0
  • Down0

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.