3 Replies Latest reply on Sep 14, 2020 1:37 AM by NiA_4003596

    How to restore previous state of GPIO after power cycle in mesh OnOff server CYW20706

    NiA_4003596

      Hi,

      Could anyone please suggest how to restore previous state of GPIO after power cycle in mesh OnOff server application code for CYW20706 based CYBT-343026 module. I have enabled this element .onpowerup_state = WICED_BT_MESH_ON_POWER_UP_STATE_RESTORE in the application code but it didn't work out for me.

      State of GPIO (RELAY_GPIO_1), which I configured as output, should be switched by pressing On/Off button on the mobile application. I want to keep the same state (last status by mobile application) of RELAY_GPIO_1 after power goes off and comes back. In order to do that, I have used NVRAM function. Is there any other good way of doing this?

       

      Please check the attachment for entire code written in Modustoolbox with 2.7 SDK release.

      void mesh_onoff_server_process_status(uint8_t element_idx, wiced_bt_mesh_onoff_status_data_t *p_status)

      {

          wiced_result_t status;

          uint8_t powerState = 0;

       

          /* Write status change to NVRAM */

          powerState = p_status->present_onoff;

          wiced_hal_write_nvram( 0x05, 1, &powerState, &status );

       

       

          /* Process relay with the status changed */

          if(p_status->present_onoff)

          {

              wiced_hal_gpio_set_pin_output( RELAY_GPIO_1, GPIO_PIN_OUTPUT_HIGH);

          }

          else

          {

              wiced_hal_gpio_set_pin_output( RELAY_GPIO_1, GPIO_PIN_OUTPUT_LOW);

          }

      }

       

       

       

      Regards,

      NK