Compare commits

...

2 Commits

Author SHA1 Message Date
56d8a0f2cf add resetGPIO 2026-01-15 13:28:23 -06:00
bec3d91d98 Add mac address and other info to BLE. 2026-01-10 23:19:31 -06:00
11 changed files with 38 additions and 9 deletions

View File

@@ -132,7 +132,6 @@ CONFIG_SOC_GPIO_DEEP_SLEEP_WAKE_VALID_GPIO_MASK=0
CONFIG_SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT=8 CONFIG_SOC_GPIO_DEEP_SLEEP_WAKE_SUPPORTED_PIN_CNT=8
CONFIG_SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK=0x000000007FFFFF00 CONFIG_SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK=0x000000007FFFFF00
CONFIG_SOC_GPIO_SUPPORT_FORCE_HOLD=y CONFIG_SOC_GPIO_SUPPORT_FORCE_HOLD=y
CONFIG_SOC_GPIO_SUPPORT_HOLD_IO_IN_DSLP=y
CONFIG_SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP=y CONFIG_SOC_GPIO_SUPPORT_HOLD_SINGLE_IO_IN_DSLP=y
CONFIG_SOC_GPIO_CLOCKOUT_BY_GPIO_MATRIX=y CONFIG_SOC_GPIO_CLOCKOUT_BY_GPIO_MATRIX=y
CONFIG_SOC_CLOCKOUT_HAS_SOURCE_GATE=y CONFIG_SOC_CLOCKOUT_HAS_SOURCE_GATE=y
@@ -2344,13 +2343,6 @@ CONFIG_LIBC_TIME_SYSCALL_USE_RTC_HRT=y
# #
# CONFIG_OPENTHREAD_ENABLED is not set # CONFIG_OPENTHREAD_ENABLED is not set
#
# Thread Console
#
CONFIG_OPENTHREAD_CLI=y
CONFIG_OPENTHREAD_CONSOLE_COMMAND_PREFIX="ot"
# end of Thread Console
# #
# OpenThread Spinel # OpenThread Spinel
# #

View File

@@ -6,6 +6,7 @@
#include "defines.h" #include "defines.h"
#include <mutex> #include <mutex>
#include "bmHTTP.hpp" #include "bmHTTP.hpp"
#include "esp_mac.h"
std::atomic<bool> flag_scan_requested{false}; std::atomic<bool> flag_scan_requested{false};
std::atomic<bool> credsGiven{false}; std::atomic<bool> credsGiven{false};
@@ -28,6 +29,7 @@ std::atomic<NimBLECharacteristic*> authConfirmChar = nullptr;
std::atomic<NimBLECharacteristic*> credsChar = nullptr; std::atomic<NimBLECharacteristic*> credsChar = nullptr;
std::atomic<NimBLECharacteristic*> tokenChar = nullptr; std::atomic<NimBLECharacteristic*> tokenChar = nullptr;
std::atomic<NimBLECharacteristic*> ssidRefreshChar = nullptr; std::atomic<NimBLECharacteristic*> ssidRefreshChar = nullptr;
std::atomic<NimBLECharacteristic*> deviceInfoChar = nullptr;
NimBLEAdvertising* initBLE() { NimBLEAdvertising* initBLE() {
finalAuth = false; finalAuth = false;
@@ -93,6 +95,27 @@ NimBLEAdvertising* initBLE() {
); );
connectConfirmChar.load()->createDescriptor("2902"); // Add BLE2902 descriptor for notifications connectConfirmChar.load()->createDescriptor("2902"); // Add BLE2902 descriptor for notifications
// 0x0006 - Device Info (READ) - MAC address and other device details
deviceInfoChar = pService->createCharacteristic(
"0006",
NIMBLE_PROPERTY::READ
);
// Build device info JSON with MAC address
uint8_t mac[6];
esp_read_mac(mac, ESP_MAC_WIFI_STA);
char macStr[18];
snprintf(macStr, sizeof(macStr), "%02X:%02X:%02X:%02X:%02X:%02X",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
cJSON *infoRoot = cJSON_CreateObject();
cJSON_AddStringToObject(infoRoot, "mac", macStr);
cJSON_AddStringToObject(infoRoot, "firmware", "1.0.0");
cJSON_AddStringToObject(infoRoot, "model", "BlindMaster-C6");
char *infoJson = cJSON_PrintUnformatted(infoRoot);
deviceInfoChar.load()->setValue(std::string(infoJson));
cJSON_Delete(infoRoot);
free(infoJson);
// Start // Start
pService->start(); pService->start();

View File

@@ -1,7 +1,7 @@
# This file was automatically generated for projects # This file was automatically generated for projects
# without default 'CMakeLists.txt' file. # without default 'CMakeLists.txt' file.
FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.* ${CMAKE_SOURCE_DIR}/include/*.cpp) FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*)
idf_component_register(SRCS ${app_sources} idf_component_register(SRCS ${app_sources}
INCLUDE_DIRS "." INCLUDE_DIRS "."

View File

@@ -18,6 +18,17 @@ Encoder* bottomEnc = new Encoder(InputEnc_PIN_A, InputEnc_PIN_B);
// Global calibration instance // Global calibration instance
Calibration calib; Calibration calib;
void switchOnOffServo() {
while (1) {
printf("Servo On\n");
servoOn(CCW, manual);
vTaskDelay(pdMS_TO_TICKS(2000));
printf("Servo Off\n");
servoOff();
vTaskDelay(pdMS_TO_TICKS(2000));
}
}
void mainApp() { void mainApp() {
esp_err_t ret = nvs_flash_init(); // change to secure init logic soon!! esp_err_t ret = nvs_flash_init(); // change to secure init logic soon!!
// 2. If NVS is full or corrupt (common after flashing new code), erase and retry // 2. If NVS is full or corrupt (common after flashing new code), erase and retry
@@ -35,6 +46,8 @@ void mainApp() {
bottomEnc->init(); bottomEnc->init();
servoInit(); servoInit();
// switchOnOffServo();
setupLoop(); setupLoop();
statusResolved = false; statusResolved = false;

View File

@@ -38,6 +38,7 @@ void servoInit() {
ESP_ERROR_CHECK(ledc_channel_config(&ledc_channel)); ESP_ERROR_CHECK(ledc_channel_config(&ledc_channel));
// Configure servo power switch pin as output // Configure servo power switch pin as output
gpio_reset_pin(servoSwitch);
gpio_set_direction(servoSwitch, GPIO_MODE_OUTPUT); gpio_set_direction(servoSwitch, GPIO_MODE_OUTPUT);
gpio_set_level(servoSwitch, 0); // Start with servo power off gpio_set_level(servoSwitch, 0); // Start with servo power off