Skip to content

RainMaker - Add switch example using array #7920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed

RainMaker - Add switch example using array #7920

wants to merge 6 commits into from

Conversation

FernandoGarcia
Copy link

Hi!

I have spent some time searching for example with multiple switches using arrays but I couldn't find.

After some trouble with compiling error I have managed to make it work with help of Arduino forum's user.

So I would like to add this example here to help other user to make a clean and easily editable code.

I have tested the code and it works as expected.

Best regards.

@FernandoGarcia FernandoGarcia changed the title Add switch example using array RainMaker - Add switch example using array Mar 2, 2023
@CLAassistant
Copy link

CLAassistant commented Mar 2, 2023

CLA assistant check
All committers have signed the CLA.

@pipi61
Copy link

pipi61 commented Mar 2, 2023

Please add lots of comments

@FernandoGarcia
Copy link
Author

Hi!

It's done.

Best regards.

@pipi61
Copy link

pipi61 commented Mar 2, 2023

great, thanks

@VojtechBartoska VojtechBartoska added Type: Example Issue is related to specific example. Area: Rainmaker Issue is related to ESP Rainmaker. labels Mar 3, 2023
@VojtechBartoska
Copy link
Contributor

Thanks for the contibution @FernandoGarcia, we'll review it soon.

@FernandoGarcia
Copy link
Author

FernandoGarcia commented Mar 3, 2023

Hi!

There's an error in partition scheme in build check,

It should be PartitionScheme=rainmaker

Building Sketch Index 5 - BLE5_extended_scan
Building BLE5_extended_scan with arduino-cli and FQBN=espressif:esp32:esp32s3:PSRAM=opi,USBMode=default,PartitionScheme=huge_app
Error: The operation was canceled.

Maybe related to #7893 (comment)

Best regards.

@sanketwadekar
Copy link
Contributor

@FernandoGarcia
First of all, you have included AceButton library, which is not a part of this repo. Using third-party libraries in examples will cause issues for users who don't have them installed.
Secondly, Rainmaker examples are meant to introduce the different APIs and functionalities provided by the SDK. This example is basically an extension of the Switch example. In most cases, users start off with the Switch example and then continue to add their own devices and parameters in the sketch that suit their requirements (just as you might have done😄). Other than the number of switches, this example is no different from the existing Switch example.
Also, as I have mentioned here, using random output pins might cause issues that might go unnoticed.
For consistency, we create an example in the Rainmaker repo first and then replicate it in Arduino.

@FernandoGarcia
Copy link
Author

First of all, you have included AceButton library, which is not a part of this repo. Using third-party libraries in examples will cause issues for users who don't have them installed.

Can I specify library dependency in read me? We can find libraries with third part dependencies all time.

Secondly, Rainmaker examples are meant to introduce the different APIs and functionalities provided by the SDK. This example is basically an extension of the Switch example. In most cases, users start off with the Switch example and then continue to add their own devices and parameters in the sketch that suit their requirements (just as you might have donesmile). Other than the number of switches, this example is no different from the existing Switch example.

Yes, but it's doesn't help beginners improve their skills because all code that I can find is like the code below including RMakerSonoffDualR3 example.

LightSwitch switch_ch1 = {gpio_switch1, false};
LightSwitch switch_ch2 = {gpio_switch2, false};
LightSwitch switch_ch3 = {gpio_switch3, false}
LightSwitch switch_ch4 = {gpio_switch4, false}
LightSwitch switch_ch5 = {gpio_switch5, false}
LightSwitch switch_ch6 = {gpio_switch6, false}
LightSwitch switch_ch7 = {gpio_switch7, false}

static Switch my_switch1;
static Switch my_switch2;
static Switch my_switch3;
static Switch my_switch4;
static Switch my_switch5;
static Switch my_switch6;
static Switch my_switch7;

void write_callback(Device *device, Param *param, const param_val_t val, void *priv_data, write_ctx_t *ctx)
{
  const char *device_name = device->getDeviceName();
  const char *param_name = param->getParamName();

  if(strcmp(device_name, "Switch_ch1") == 0) 
  {
  } 
  else if(strcmp(device_name, "Switch_ch2") == 0) 
  {
  }
  else if(strcmp(device_name, "Switch_ch3") == 0) 
  {
  }
  else if(strcmp(device_name, "Switch_ch4") == 0) 
  {
  }
  else if(strcmp(device_name, "Switch_ch5") == 0) 
  {
  }
  else if(strcmp(device_name, "Switch_ch6") == 0) 
  {
  }
  else if(strcmp(device_name, "Switch_ch7") == 0) 
  {
  }
}

Also, as I have mentioned #7893 (comment), using random output pins might cause issues that might go unnoticed.
For consistency, we create an example in the Rainmaker repo first and then replicate it in Arduino.

For this reason I'm talking with you about sanity check here.

@FernandoGarcia
Copy link
Author

FernandoGarcia commented Mar 3, 2023

Regarding library dependencies, I could add a YAML file with the list of dependencies so the build check could do a git clone or search for it in Arduino library registry before try build.

@sanketwadekar
Copy link
Contributor

@shahpiyushv Please take a look

Add ARDUINO_EVENT_PROV_INIT and ARDUINO_EVENT_PROV_CRED_SUCCESS back
@FernandoGarcia
Copy link
Author

Hi @shahpiyushv @sanketwadekar !

Any news?

Best regards.

@VojtechBartoska VojtechBartoska added the Status: Review needed Issue or PR is awaiting review label Mar 22, 2023
@me-no-dev
Copy link
Member

Because this example uses external library, CI will always fail. Please rewrite it to not require AceButton

@FernandoGarcia
Copy link
Author

Because this example uses external library, CI will always fail. Please rewrite it to not require AceButton

Hi!

Have you considered my suggestion above to use YML file to specify dependencies?

Best regards.

@me-no-dev
Copy link
Member

Because this example uses external library, CI will always fail. Please rewrite it to not require AceButton

Hi!

Have you considered my suggestion above to use YML file to specify dependencies?

Best regards.

Yes we are considering it, but still, this is a very basic functionality that does not warrant external library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Rainmaker Issue is related to ESP Rainmaker. Status: Review needed Issue or PR is awaiting review Type: Example Issue is related to specific example.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants