Merge pull request 'feat/switch' (#1) from feat/switch into main
Reviewed-on: #1
This commit was merged in pull request #1.
This commit is contained in:
101
.github/ISSUE_TEMPLATE/01_compile_bug.yml
vendored
101
.github/ISSUE_TEMPLATE/01_compile_bug.yml
vendored
@@ -1,101 +0,0 @@
|
||||
name: Compilation error report
|
||||
description: Report build issues
|
||||
labels: ['Type: Bug']
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checklist
|
||||
attributes:
|
||||
label: Answers checklist.
|
||||
description: Before submitting a new issue, please follow the checklist and try to find the answer.
|
||||
options:
|
||||
- label: I have read the [Rainmaker documentation](https://rainmaker.espressif.com/docs/get-started.html) and the issue is not addressed there.
|
||||
required: true
|
||||
- label: I have updated my IDF branch (release/vX.Y) to the latest version and checked that the issue is present there. This is not applicable if you are using Rainmaker with Arduino.
|
||||
required: true
|
||||
- label: I have searched the [Rainmaker forum](https://www.esp32.com/viewforum.php?f=41) and issue tracker for a similar issue and not found a similar issue.
|
||||
required: true
|
||||
- type: input
|
||||
id: idf_version
|
||||
attributes:
|
||||
label: IDF / ESP32-Arduino version.
|
||||
description: On which IDF version does this issue occur on? Run `git describe --tags` or `idf.py --version` to find it. For Arduino users, mention the version of ESP32-Arduino (from Boards manager).
|
||||
placeholder: ex. v3.2-dev-1148-g96cd3b75c / ESP32-Arduino 2.0.6
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: operating_system
|
||||
attributes:
|
||||
label: Operating System used.
|
||||
multiple: false
|
||||
options:
|
||||
- Windows
|
||||
- Linux
|
||||
- macOS
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: build
|
||||
attributes:
|
||||
label: How did you build your project?
|
||||
multiple: false
|
||||
options:
|
||||
- Command line with Make
|
||||
- Command line with CMake
|
||||
- Command line with idf.py
|
||||
- Arduino IDE
|
||||
- Other (please specify in More Information)
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: devkit
|
||||
attributes:
|
||||
label: Development Kit.
|
||||
description: On which Development Kit does this issue occur on?
|
||||
placeholder: ex. ESP32-Wrover-Kit v2 | Custom Board
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: What is the expected behavior?
|
||||
description: Please provide a clear and concise description of the expected behavior.
|
||||
placeholder: I expected it to...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: actual
|
||||
attributes:
|
||||
label: What is the actual behavior?
|
||||
description: Please describe actual behavior.
|
||||
placeholder: Instead it...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: steps
|
||||
attributes:
|
||||
label: Steps to reproduce.
|
||||
description: 'How do you trigger this bug? Please walk us through it step by step. Please attach sdkconfig file (from your project folder). Please attach your code here or the name of the rainmaker example.'
|
||||
value: |
|
||||
1. Step
|
||||
2. Step
|
||||
3. Step
|
||||
...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: debug_logs
|
||||
attributes:
|
||||
label: Build Logs.
|
||||
description: Compilation log goes here, should contain the backtrace, as well as the reset source if it is a crash.
|
||||
placeholder: Your log goes here.
|
||||
render: plain
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: more-info
|
||||
attributes:
|
||||
label: More Information.
|
||||
description: Do you have any other information from investigating this?
|
||||
placeholder: ex. I tried on my friend's Windows 10 PC and the command works there.
|
||||
validations:
|
||||
required: false
|
||||
101
.github/ISSUE_TEMPLATE/02_runtime_bug.yml
vendored
101
.github/ISSUE_TEMPLATE/02_runtime_bug.yml
vendored
@@ -1,101 +0,0 @@
|
||||
name: Runtime bug report
|
||||
description: Report runtime bugs/crashes
|
||||
labels: ['Type: Bug']
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checklist
|
||||
attributes:
|
||||
label: Answers checklist.
|
||||
description: Before submitting a new issue, please follow the checklist and try to find the answer.
|
||||
options:
|
||||
- label: I have read the [Rainmaker documentation](https://rainmaker.espressif.com/docs/get-started.html) and the issue is not addressed there.
|
||||
required: true
|
||||
- label: I have updated my IDF branch (release/vX.Y) to the latest version and checked that the issue is present there. This is not applicable if you are using Rainmaker with Arduino.
|
||||
required: true
|
||||
- label: I have searched the [Rainmaker forum](https://www.esp32.com/viewforum.php?f=41) and issue tracker for a similar issue and not found a similar issue.
|
||||
required: true
|
||||
- type: input
|
||||
id: idf_version
|
||||
attributes:
|
||||
label: IDF / ESP32-Arduino version.
|
||||
description: On which IDF version does this issue occur on? Run `git describe --tags` or `idf.py --version` to find it. For Arduino users, mention the version of ESP32-Arduino (from Boards manager).
|
||||
placeholder: ex. v3.2-dev-1148-g96cd3b75c / ESP32-Arduino 2.0.6
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: operating_system
|
||||
attributes:
|
||||
label: Operating System used.
|
||||
multiple: false
|
||||
options:
|
||||
- Windows
|
||||
- Linux
|
||||
- macOS
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: build
|
||||
attributes:
|
||||
label: How did you build your project?
|
||||
multiple: false
|
||||
options:
|
||||
- Command line with Make
|
||||
- Command line with CMake
|
||||
- Command line with idf.py
|
||||
- Arduino IDE
|
||||
- Other (please specify in More Information)
|
||||
validations:
|
||||
required: false
|
||||
- type: input
|
||||
id: devkit
|
||||
attributes:
|
||||
label: Development Kit.
|
||||
description: On which Development Kit does this issue occur on?
|
||||
placeholder: ex. ESP32-Wrover-Kit v2 | Custom Board
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: What is the expected behavior?
|
||||
description: Please provide a clear and concise description of the expected behavior.
|
||||
placeholder: I expected it to...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: actual
|
||||
attributes:
|
||||
label: What is the actual behavior?
|
||||
description: Please describe actual behavior.
|
||||
placeholder: Instead it...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: steps
|
||||
attributes:
|
||||
label: Steps to reproduce.
|
||||
description: 'How do you trigger this bug? Please walk us through it step by step. Please attach your code here or the name of the rainmaker example.'
|
||||
value: |
|
||||
1. Step
|
||||
2. Step
|
||||
3. Step
|
||||
...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: debug_logs
|
||||
attributes:
|
||||
label: Debug Logs.
|
||||
description: Debug log goes here, should contain the backtrace, as well as the reset source if it is a crash.
|
||||
placeholder: Your log goes here.
|
||||
render: plain
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: more-info
|
||||
attributes:
|
||||
label: More Information.
|
||||
description: Do you have any other information from investigating this?
|
||||
placeholder: ex. I tried on my friend's Windows 10 PC and the command works there.
|
||||
validations:
|
||||
required: false
|
||||
31
.github/ISSUE_TEMPLATE/03_feature_request.yml
vendored
31
.github/ISSUE_TEMPLATE/03_feature_request.yml
vendored
@@ -1,31 +0,0 @@
|
||||
name: Feature request
|
||||
description: Suggest an idea for this project.
|
||||
labels: ['Type: Feature Request']
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: We welcome any ideas or feature requests! It’s helpful if you can explain exactly why the feature would be useful.
|
||||
- type: textarea
|
||||
id: problem-related
|
||||
attributes:
|
||||
label: Is your feature request related to a problem?
|
||||
description: Please provide a clear and concise description of what the problem is.
|
||||
placeholder: ex. I'm always frustrated when ...
|
||||
- type: textarea
|
||||
id: solution
|
||||
attributes:
|
||||
label: Describe the solution you'd like.
|
||||
description: Please provide a clear and concise description of what you want to happen.
|
||||
placeholder: ex. When using the Rainmaker app ...
|
||||
- type: textarea
|
||||
id: alternatives
|
||||
attributes:
|
||||
label: Describe alternatives you've considered.
|
||||
description: Please provide a clear and concise description of any alternative solutions or features you've considered.
|
||||
placeholder: ex. Choosing other approach wouldn't work, because ...
|
||||
- type: textarea
|
||||
id: context
|
||||
attributes:
|
||||
label: Additional context.
|
||||
description: Please add any other context or screenshots about the feature request here.
|
||||
placeholder: ex. This would work only when ...
|
||||
23
.github/ISSUE_TEMPLATE/04_other_issue.yml
vendored
23
.github/ISSUE_TEMPLATE/04_other_issue.yml
vendored
@@ -1,23 +0,0 @@
|
||||
name: General issue / query report
|
||||
description: File an issue report
|
||||
body:
|
||||
- type: checkboxes
|
||||
id: checklist
|
||||
attributes:
|
||||
label: Answers checklist.
|
||||
description: Before submitting a new issue, please follow the checklist and try to find the answer.
|
||||
options:
|
||||
- label: I have read the [Rainmaker documentation](https://rainmaker.espressif.com/docs/get-started.html) and the issue is not addressed there.
|
||||
required: true
|
||||
- label: I have updated my IDF branch (release/vX.Y) to the latest version and checked that the issue is present there. This is not applicable if you are using Rainmaker with Arduino.
|
||||
required: true
|
||||
- label: I have searched the [Rainmaker forum](https://www.esp32.com/viewforum.php?f=41) and issue tracker for a similar issue and not found a similar issue.
|
||||
required: true
|
||||
- type: textarea
|
||||
id: issue
|
||||
attributes:
|
||||
label: General issue report
|
||||
description: Your issue report goes here.
|
||||
placeholder: ex. How do I run...
|
||||
validations:
|
||||
required: true
|
||||
11
.github/ISSUE_TEMPLATE/config.yml
vendored
11
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -1,11 +0,0 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Getting Started - ESP Rainmaker
|
||||
url: https://rainmaker.espressif.com/docs/get-started.html
|
||||
about: Guide for getting started with Rainmaker
|
||||
- name: ESP Rainmaker API Guide
|
||||
url: https://rainmaker.espressif.com/docs/api.html
|
||||
about: Documentation for using Rainmaker APIs
|
||||
- name: Espressif Rainmaker Forum
|
||||
url: https://www.esp32.com/viewforum.php?f=41
|
||||
about: For asking questions to the community about using ESP Rainmaker, create a discussion topic here.
|
||||
20
.github/workflows/issue_comment.yml
vendored
20
.github/workflows/issue_comment.yml
vendored
@@ -1,20 +0,0 @@
|
||||
name: Sync issue comments to JIRA
|
||||
|
||||
# This workflow will be triggered when new issue comment is created (including PR comments)
|
||||
on: issue_comment
|
||||
|
||||
jobs:
|
||||
sync_issue_comments_to_jira:
|
||||
name: Sync Issue Comments to Jira
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Sync issue comments to JIRA
|
||||
uses: espressif/github-actions/sync_issues_to_jira@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
JIRA_PASS: ${{ secrets.JIRA_PASS }}
|
||||
JIRA_PROJECT: MEGH
|
||||
JIRA_COMPONENT: GitHub
|
||||
JIRA_URL: ${{ secrets.JIRA_URL }}
|
||||
JIRA_USER: ${{ secrets.JIRA_USER }}
|
||||
138
.github/workflows/launchpad.yml
vendored
138
.github/workflows/launchpad.yml
vendored
@@ -1,138 +0,0 @@
|
||||
# Copyright 2024 Espressif Systems (Shanghai) PTE LTD
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# This workflow build examples, store the artifacts and deploy them to github pages.
|
||||
# Generates the launchpad configuration file that can be used with the url.
|
||||
|
||||
name: Build Examples
|
||||
|
||||
on:
|
||||
# Runs on pushes targeting the default branch
|
||||
push:
|
||||
branches: ["master"]
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
# Allow one concurrent deployment
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
Build:
|
||||
# Disable the job in forks
|
||||
if: ${{ github.repository_owner == 'espressif' }}
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: espressif/idf:v5.3.1
|
||||
strategy:
|
||||
matrix:
|
||||
example: [fan, led_light, multi_device, switch, temperature_sensor]
|
||||
target: [esp32, esp32c3, esp32c6, esp32s3]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
|
||||
- run: mkdir -p images
|
||||
|
||||
- name: build application
|
||||
run: |
|
||||
. $IDF_PATH/export.sh
|
||||
export ESP_RMAKER_PATH=$PWD
|
||||
cd examples/${{ matrix.example }}
|
||||
|
||||
# Lets use the assisted claim by default for launchpad examples
|
||||
echo "CONFIG_ESP_RMAKER_ASSISTED_CLAIM=y" >> sdkconfig.defaults
|
||||
|
||||
idf.py set-target ${{ matrix.target }} build
|
||||
|
||||
cd build
|
||||
TARGET_CHIP=`cat project_description.json | python3 -c 'import sys,json; print(json.load(sys.stdin)["target"])'`
|
||||
APP_BIN=`cat project_description.json | python3 -c 'import sys,json; print(json.load(sys.stdin)["app_bin"])'`
|
||||
|
||||
OUT_BIN=$ESP_RMAKER_PATH/images/"$TARGET_CHIP"_RainMaker_"$APP_BIN"
|
||||
esptool.py --chip $TARGET_CHIP merge_bin -o $OUT_BIN @flash_args
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: build-images-${{ matrix.target }}-${{ matrix.example }}
|
||||
path: images
|
||||
|
||||
deploy:
|
||||
# Disable the job in forks
|
||||
if: ${{ github.repository_owner == 'espressif' }}
|
||||
|
||||
needs: Build
|
||||
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: espressif/esp-matter:latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
id: checkout
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
|
||||
- name: Download builds
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: build-images-*
|
||||
path: images/
|
||||
merge-multiple: true
|
||||
|
||||
- name: generate launchpad config
|
||||
run: |
|
||||
export ESP_RMAKER_PATH=$PWD
|
||||
|
||||
cd images
|
||||
$ESP_RMAKER_PATH/tools/launchpad/generate_launchpad_config.sh ${{ github.repository_owner }} `basename ${{ github.repository }}`
|
||||
|
||||
echo "#### Build Config" >> build_cfg.md
|
||||
echo "" >> build_cfg.md
|
||||
echo "" >> build_cfg.md
|
||||
echo "- ESP-IDF: [`git -C $IDF_PATH rev-parse HEAD`](https://github.com/espressif/esp-idf/tree/`git -C $IDF_PATH rev-parse HEAD`)" >> build_cfg.md
|
||||
echo "- ESP-RainMaker: [${{steps.checkout.outputs.commit}}](https://github.com/espressif/esp-rainmaker/tree/${{steps.checkout.outputs.commit}})" >> build_cfg.md
|
||||
echo "" >> build_cfg.md
|
||||
echo "" >> build_cfg.md
|
||||
|
||||
cat $ESP_RMAKER_PATH/tools/launchpad/app_link_guide.md >> build_cfg.md
|
||||
|
||||
tree -H '.' -L 1 --noreport -T 'ESP RainMaker Launchpad Artifacts' -shi --charset utf-8 -I "index.html" -o index.html
|
||||
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v4
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: images/
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
20
.github/workflows/new_issues.yml
vendored
20
.github/workflows/new_issues.yml
vendored
@@ -1,20 +0,0 @@
|
||||
name: Sync issues to Jira
|
||||
|
||||
# This workflow will be triggered when a new issue is opened
|
||||
on: issues
|
||||
|
||||
jobs:
|
||||
sync_issues_to_jira:
|
||||
name: Sync issues to Jira
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Sync GitHub issues to Jira project
|
||||
uses: espressif/github-actions/sync_issues_to_jira@master
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
JIRA_PASS: ${{ secrets.JIRA_PASS }}
|
||||
JIRA_PROJECT: MEGH
|
||||
JIRA_COMPONENT: GitHub
|
||||
JIRA_URL: ${{ secrets.JIRA_URL }}
|
||||
JIRA_USER: ${{ secrets.JIRA_USER }}
|
||||
25
.github/workflows/new_prs.yml
vendored
25
.github/workflows/new_prs.yml
vendored
@@ -1,25 +0,0 @@
|
||||
name: Sync remain PRs to Jira
|
||||
|
||||
# This workflow will be triggered every hour, to sync remaining PRs (i.e. PRs with zero comment) to Jira project
|
||||
# Note that, PRs can also get synced when new PR comment is created
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 * * * *"
|
||||
|
||||
jobs:
|
||||
sync_prs_to_jira:
|
||||
name: Sync PRs to Jira
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
- name: Sync PRs to Jira project
|
||||
uses: espressif/github-actions/sync_issues_to_jira@master
|
||||
with:
|
||||
cron_job: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
JIRA_PASS: ${{ secrets.JIRA_PASS }}
|
||||
JIRA_PROJECT: MEGH
|
||||
JIRA_COMPONENT: GitHub
|
||||
JIRA_URL: ${{ secrets.JIRA_URL }}
|
||||
JIRA_USER: ${{ secrets.JIRA_USER }}
|
||||
20
.github/workflows/upload_components.yml
vendored
20
.github/workflows/upload_components.yml
vendored
@@ -1,20 +0,0 @@
|
||||
name: Push components to Espressif Component Service
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
upload_components:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Upload ESP RainMaker components to Component Registry
|
||||
uses: espressif/upload-components-ci-action@v1
|
||||
with:
|
||||
directories: >
|
||||
components/esp_schedule;
|
||||
components/esp_rainmaker;
|
||||
namespace: "espressif"
|
||||
api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }}
|
||||
@@ -13,4 +13,4 @@ set(EXTRA_COMPONENT_DIRS ${RMAKER_PATH}/examples/common)
|
||||
|
||||
set(PROJECT_VER "1.0")
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(gpio)
|
||||
project(rmaker_multi_device)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# GPIO Example
|
||||
|
||||
This example is a modified version of the GPIO example. The modification is made according to the [ESP Rainmaker Multi Device Laboratory](https://redmine.kozmotronik.com.tr/projects/espressif-sistemleri-laboratuvari/wiki/Multi_Device). Briefly, 2 more devices added over the GPIO device: RGB Light and Switch.
|
||||
|
||||
## Build and Flash firmware
|
||||
|
||||
Follow the ESP RainMaker Documentation [Get Started](https://rainmaker.espressif.com/docs/get-started.html) section to build and flash this firmware. Just note the path of this example.
|
||||
|
||||
@@ -13,9 +13,12 @@
|
||||
|
||||
#include <app_reset.h>
|
||||
#include <ws2812_led.h>
|
||||
#include "esp_attr.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_rmaker_core.h"
|
||||
#include "esp_rmaker_standard_types.h"
|
||||
#include "esp_rmaker_standard_params.h"
|
||||
#include "iot_button.h"
|
||||
#include "app_priv.h"
|
||||
|
||||
#define RMT_TX_CHANNEL RMT_CHANNEL_0
|
||||
@@ -31,18 +34,25 @@
|
||||
#define WIFI_RESET_BUTTON_TIMEOUT 3
|
||||
#define FACTORY_RESET_BUTTON_TIMEOUT 10
|
||||
|
||||
// These values correspond to H,S,V = 120,100,10
|
||||
#define RGB_DEFAULT_RED 0
|
||||
#define RGB_DEFAULT_GREEN 25
|
||||
#define RGB_DEFAULT_BLUE 0
|
||||
|
||||
|
||||
static uint16_t rgb_hue = RGB_HUE_DEFAULT;
|
||||
static uint16_t rgb_saturation = RGB_SATURATION_DEFAULT;
|
||||
static uint16_t rgb_brightness = RGB_BRIGHTNESS_DEFAULT;
|
||||
static bool rgb_power = RGB_POWER_DEFAULT;
|
||||
static bool switch_state = false;
|
||||
|
||||
esp_err_t app_driver_set_gpio(const char *name, bool state)
|
||||
{
|
||||
if (strcmp(name, "Red") == 0) {
|
||||
if (strcmp(name, GPIO_DEVICE_OUT1_NAME) == 0) {
|
||||
gpio_set_level(OUTPUT_GPIO_RED, state);
|
||||
} else if (strcmp(name, "Green") == 0) {
|
||||
} else if (strcmp(name, GPIO_DEVICE_OUT2_NAME) == 0) {
|
||||
gpio_set_level(OUTPUT_GPIO_GREEN, state);
|
||||
} else if (strcmp(name, "Blue") == 0) {
|
||||
} else if (strcmp(name, GPIO_DEVICE_OUT3_NAME) == 0) {
|
||||
gpio_set_level(OUTPUT_GPIO_BLUE, state);
|
||||
} else {
|
||||
return ESP_FAIL;
|
||||
@@ -106,10 +116,40 @@ esp_err_t app_light_set_saturation(uint16_t saturation)
|
||||
return app_light_set_led(rgb_hue, saturation, rgb_brightness);
|
||||
}
|
||||
|
||||
static void app_indicator_set(bool state)
|
||||
{
|
||||
if (state) {
|
||||
app_driver_set_gpio(GPIO_DEVICE_OUT1_NAME, true);
|
||||
app_driver_set_gpio(GPIO_DEVICE_OUT2_NAME, true);
|
||||
app_driver_set_gpio(GPIO_DEVICE_OUT3_NAME, true);
|
||||
} else {
|
||||
app_driver_set_gpio(GPIO_DEVICE_OUT1_NAME, false);
|
||||
app_driver_set_gpio(GPIO_DEVICE_OUT2_NAME, false);
|
||||
app_driver_set_gpio(GPIO_DEVICE_OUT3_NAME, false);
|
||||
}
|
||||
esp_rmaker_param_update(esp_rmaker_device_get_param_by_name(gpio_device, GPIO_DEVICE_OUT1_NAME), esp_rmaker_bool(state));
|
||||
esp_rmaker_param_update(esp_rmaker_device_get_param_by_name(gpio_device, GPIO_DEVICE_OUT2_NAME), esp_rmaker_bool(state));
|
||||
esp_rmaker_param_update(esp_rmaker_device_get_param_by_name(gpio_device, GPIO_DEVICE_OUT3_NAME), esp_rmaker_bool(state));
|
||||
}
|
||||
|
||||
static void push_button_cb(void *arg)
|
||||
{
|
||||
bool new_state = !switch_state;
|
||||
app_switch_set_state(new_state);
|
||||
|
||||
esp_rmaker_param_update_and_report(
|
||||
esp_rmaker_device_get_param_by_name(switch_device, ESP_RMAKER_DEF_POWER_NAME),
|
||||
esp_rmaker_bool(new_state));
|
||||
}
|
||||
|
||||
|
||||
void app_driver_init()
|
||||
{
|
||||
app_reset_button_register(app_reset_button_create(BUTTON_GPIO, BUTTON_ACTIVE_LEVEL),
|
||||
WIFI_RESET_BUTTON_TIMEOUT, FACTORY_RESET_BUTTON_TIMEOUT);
|
||||
button_handle_t btn_handle = iot_button_create(BUTTON_GPIO, BUTTON_ACTIVE_LEVEL);
|
||||
// Register a callback for a button tap (short press) event
|
||||
iot_button_set_evt_cb(btn_handle, BUTTON_CB_TAP, push_button_cb, NULL);
|
||||
// Register Wi-Fi reset and factory reset functionality on the same button
|
||||
app_reset_button_register(btn_handle, WIFI_RESET_BUTTON_TIMEOUT, FACTORY_RESET_BUTTON_TIMEOUT);
|
||||
|
||||
/* Configure power */
|
||||
gpio_config_t io_conf = {
|
||||
@@ -126,3 +166,17 @@ void app_driver_init()
|
||||
|
||||
app_light_init();
|
||||
}
|
||||
|
||||
int IRAM_ATTR app_switch_set_state(bool state)
|
||||
{
|
||||
if (switch_state != state) {
|
||||
switch_state = state;
|
||||
app_indicator_set(state);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
bool app_switch_get_state(void)
|
||||
{
|
||||
return switch_state;
|
||||
}
|
||||
@@ -22,10 +22,17 @@
|
||||
#include <app_insights.h>
|
||||
|
||||
#include "app_priv.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
static const char *TAG = "app_main";
|
||||
|
||||
static const char *gpio_device_name = "GPIO";
|
||||
static const char *rgb_device_name = "RGB-Light";
|
||||
static const char *switch_device_name = "Switch";
|
||||
|
||||
esp_rmaker_device_t *gpio_device;
|
||||
esp_rmaker_device_t *light_device;
|
||||
esp_rmaker_device_t *switch_device;
|
||||
|
||||
#ifdef CONFIG_ESP_RMAKER_CMD_RESP_ENABLE
|
||||
|
||||
@@ -127,9 +134,23 @@ static esp_err_t write_cb(const esp_rmaker_device_t *device, const esp_rmaker_pa
|
||||
if (ctx) {
|
||||
ESP_LOGI(TAG, "Received write request via : %s", esp_rmaker_device_cb_src_to_str(ctx->src));
|
||||
}
|
||||
if (app_driver_set_gpio(esp_rmaker_param_get_name(param), val.val.b) == ESP_OK) {
|
||||
esp_rmaker_param_update(param, val);
|
||||
const char *device_name = esp_rmaker_device_get_name(device);
|
||||
// const char *param_name = esp_rmaker_param_get_name(param);
|
||||
esp_err_t ret = ESP_OK;
|
||||
|
||||
if (strcmp(device_name, gpio_device_name) == 0) {
|
||||
ret = app_driver_set_gpio(esp_rmaker_param_get_name(param), val.val.b);
|
||||
}
|
||||
else if (strcmp(device_name, switch_device_name) == 0) {
|
||||
ret = app_switch_set_state(val.val.b);
|
||||
}
|
||||
else {
|
||||
ESP_LOGI(TAG, "Unexpected device %s", device_name);
|
||||
}
|
||||
|
||||
if (ret == ESP_OK)
|
||||
esp_rmaker_param_update(param, val);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@@ -159,7 +180,7 @@ void app_main()
|
||||
esp_rmaker_config_t rainmaker_cfg = {
|
||||
.enable_time_sync = false,
|
||||
};
|
||||
esp_rmaker_node_t *node = esp_rmaker_node_init(&rainmaker_cfg, "ESP RainMaker Device", "GPIO-Device");
|
||||
esp_rmaker_node_t *node = esp_rmaker_node_init(&rainmaker_cfg, "ESP RainMaker Multi Device", "Multi Device");
|
||||
if (!node) {
|
||||
ESP_LOGE(TAG, "Could not initialise node. Aborting!!!");
|
||||
vTaskDelay(5000/portTICK_PERIOD_MS);
|
||||
@@ -167,25 +188,25 @@ void app_main()
|
||||
}
|
||||
|
||||
/* Create a device and add the relevant parameters to it */
|
||||
esp_rmaker_device_t *gpio_device = esp_rmaker_device_create("GPIO-Device", NULL, NULL);
|
||||
gpio_device = esp_rmaker_device_create(gpio_device_name, NULL, NULL);
|
||||
esp_rmaker_device_add_cb(gpio_device, write_cb, NULL);
|
||||
|
||||
esp_rmaker_param_t *red_param = esp_rmaker_param_create("Red", NULL, esp_rmaker_bool(false), PROP_FLAG_READ | PROP_FLAG_WRITE);
|
||||
esp_rmaker_param_t *red_param = esp_rmaker_param_create(GPIO_DEVICE_OUT1_NAME, NULL, esp_rmaker_bool(false), PROP_FLAG_READ | PROP_FLAG_WRITE);
|
||||
esp_rmaker_param_add_ui_type(red_param, ESP_RMAKER_UI_TOGGLE);
|
||||
esp_rmaker_device_add_param(gpio_device, red_param);
|
||||
|
||||
esp_rmaker_param_t *green_param = esp_rmaker_param_create("Green", NULL, esp_rmaker_bool(false), PROP_FLAG_READ | PROP_FLAG_WRITE);
|
||||
esp_rmaker_param_t *green_param = esp_rmaker_param_create(GPIO_DEVICE_OUT2_NAME, NULL, esp_rmaker_bool(false), PROP_FLAG_READ | PROP_FLAG_WRITE);
|
||||
esp_rmaker_param_add_ui_type(green_param, ESP_RMAKER_UI_TOGGLE);
|
||||
esp_rmaker_device_add_param(gpio_device, green_param);
|
||||
|
||||
esp_rmaker_param_t *blue_param = esp_rmaker_param_create("Blue", NULL, esp_rmaker_bool(false), PROP_FLAG_READ | PROP_FLAG_WRITE);
|
||||
esp_rmaker_param_t *blue_param = esp_rmaker_param_create(GPIO_DEVICE_OUT3_NAME, NULL, esp_rmaker_bool(false), PROP_FLAG_READ | PROP_FLAG_WRITE);
|
||||
esp_rmaker_param_add_ui_type(blue_param, ESP_RMAKER_UI_TOGGLE);
|
||||
esp_rmaker_device_add_param(gpio_device, blue_param);
|
||||
|
||||
esp_rmaker_node_add_device(node, gpio_device);
|
||||
|
||||
// Create the light device
|
||||
light_device = esp_rmaker_lightbulb_device_create("Light", NULL, RGB_POWER_DEFAULT);
|
||||
light_device = esp_rmaker_lightbulb_device_create(rgb_device_name, NULL, RGB_POWER_DEFAULT);
|
||||
esp_rmaker_device_add_bulk_cb(light_device, bulk_write_cb, NULL);
|
||||
|
||||
esp_rmaker_device_add_param(light_device, esp_rmaker_brightness_param_create(ESP_RMAKER_DEF_BRIGHTNESS_NAME, RGB_BRIGHTNESS_DEFAULT));
|
||||
@@ -194,6 +215,11 @@ void app_main()
|
||||
|
||||
esp_rmaker_node_add_device(node, light_device);
|
||||
|
||||
// Create the switch device
|
||||
switch_device = esp_rmaker_switch_device_create(switch_device_name, NULL, false);
|
||||
esp_rmaker_device_add_cb(switch_device, write_cb, NULL);
|
||||
esp_rmaker_node_add_device(node, switch_device);
|
||||
|
||||
/* Enable OTA */
|
||||
esp_rmaker_ota_enable_default();
|
||||
|
||||
|
||||
@@ -15,7 +15,13 @@
|
||||
#define RGB_SATURATION_DEFAULT 100
|
||||
#define RGB_BRIGHTNESS_DEFAULT 25
|
||||
|
||||
#define GPIO_DEVICE_OUT1_NAME "Output-1"
|
||||
#define GPIO_DEVICE_OUT2_NAME "Output-2"
|
||||
#define GPIO_DEVICE_OUT3_NAME "Output-3"
|
||||
|
||||
extern esp_rmaker_device_t *gpio_device;
|
||||
extern esp_rmaker_device_t *light_device;
|
||||
extern esp_rmaker_device_t *switch_device;
|
||||
|
||||
void app_driver_init(void);
|
||||
esp_err_t app_driver_set_gpio(const char *name, bool state);
|
||||
@@ -23,4 +29,6 @@ esp_err_t app_light_set(uint32_t hue, uint32_t saturation, uint32_t brightness);
|
||||
esp_err_t app_light_set_power(bool power);
|
||||
esp_err_t app_light_set_brightness(uint16_t brightness);
|
||||
esp_err_t app_light_set_hue(uint16_t hue);
|
||||
esp_err_t app_light_set_saturation(uint16_t saturation);
|
||||
esp_err_t app_light_set_saturation(uint16_t saturation);
|
||||
int app_switch_set_state(bool state);
|
||||
bool app_switch_get_state(void);
|
||||
Reference in New Issue
Block a user