Other Parts Discussed in Thread: SYSCONFIG, Z-STACK
Hi,
I am starting with the project zr_sw. I added the code for a OMROM d6t-8l temperature sensor which I will use as a occupancy sensor. I created a submenu option where I want to see the temperature at the moment, so while I am in this submenu, I can see the temperature updating itself displayed in the CUI.
In zcl_sampleapps_ui.c I created this function called uiActionSetSensorPresencia. I call readSensor and it gets the temperature. Then I call checkOccupancy and it return "1" if it detects a person or "0" if not.
This is what I am trying to do:
1. When I enter this submenu, on the first line I want the temperature to be shown until I get off this submenu. At this moment, when I get into this submenu I just see the temperature value once.
2. As it is reading the temperature value and checking if there is occupied, if it detects "occupied" I want to toggle the light. I should not use "zclGeneral_SendOnOff_CmdToggle" in there but I do not know how to do it.
I tried adding while loops but it does not work like that.
Thank you.
static void uiActionSetSensorPresencia(const char _input, char* _pLines[3], CUI_cursorInfo_t* _pCurInfo);
CUI_MENU_ITEM_INT_ACTION("< READ SENSOR >", (CUI_pFnIntercept_t) uiActionSetSensorPresencia)
static void uiActionSetSensorPresencia(const char _input, char* _pLines[3], CUI_cursorInfo_t* _pCurInfo)
{
if (CUI_ITEM_INTERCEPT_START == _input) {
char tmpPtat[8] = ""; char tmp1[8] = ""; char tmpInt[8] = "";
zstack_getZCLFrameCounterRsp_t Rsp;
//Zstackapi_getZCLFrameCounterReq(appServiceTaskId, &Rsp);
char tmpEntera[8] = ".";char tmpDouble[8];
double *value = readSensor();
int occupied = checkOccupancy();
if (occupied == 1) {
strcpy(tmpInt, "OCUPADO");
} else {
strcpy(tmpInt, "NO_OCUP");
}
doubleToString(value[0], tmpPtat, tmpEntera, tmpDouble);
doubleToString(value[1], tmp1, tmpEntera, tmpDouble);
strncpy(_pLines[0], "Mostrando valores:", MAX_MENU_LINE_LEN);
strncpy(_pLines[1], value[0], MAX_MENU_LINE_LEN);
strncpy(_pLines[2], tmpInt, MAX_MENU_LINE_LEN);
if (occupied == 1) {
zclGeneral_SendOnOff_CmdToggle( SAMPLESW_ENDPOINT, &listBulbs[FBBulbsFound-1], TRUE, Rsp.zclFrameCounter );
}
}
}








