diff options
Diffstat (limited to 'usr/space_light/src/device.c')
| -rw-r--r-- | usr/space_light/src/device.c | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/usr/space_light/src/device.c b/usr/space_light/src/device.c index 30bcf9e..8b87879 100644 --- a/usr/space_light/src/device.c +++ b/usr/space_light/src/device.c @@ -1,3 +1,28 @@ +/* + * The BLE code and the stripped down version of the SDK was taken and modified + * from here + * https://www.elektroda.com/rtvforum/topic3989434.html#20742145 + * + * Copyright (C) 2023 jitsirakowsk (Alex) + * + * The original code was taken modified and used for this project by + * Copyright (C) 2025 Bernhard Guillon <Bernhard.Guillon@begu.org> + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see <https://www.gnu.org/licenses/>. + * + * SPDX: GPL-3.0 + * + */ #include "ble.h" #include "ble_api.h" @@ -20,10 +45,6 @@ #include "mcu_ps_pub.h" #include "start_type_pub.h" -#include "FreeRTOS.h" -#include "task.h" -#include "timers.h" - #include "space_light.h" #define ATT_DB_LENGTH 5 @@ -73,10 +94,6 @@ bk_attm_desc_t btl_att_db[ATT_DB_LENGTH] = { beken_semaphore_t app_sema = NULL; beken_semaphore_t ext_init_sema = NULL; -TimerHandle_t xOneShotTimer; - -static void oneShotTimerCallback(TimerHandle_t xTimer) { power_save_mode(); } - static void ble_event_callback(ble_event_t event, void *param) { switch (event) { case BLE_STACK_OK: @@ -165,11 +182,14 @@ static void ble_event_callback(ble_event_t event, void *param) { static void ble_write_callback(write_req_t *write_req) { switch (write_req->value[0]) { case 0x1: { + if (write_req->len != 6) { + return; + } struct RGBCW rgbcw = { write_req->value[1], write_req->value[2], write_req->value[3], write_req->value[4], write_req->value[5], }; - setRGBCW(&rgbcw); + set_rgbcw(&rgbcw); break; } case 0x2: @@ -177,11 +197,7 @@ static void ble_write_callback(write_req_t *write_req) { return; } uint16_t seconds = write_req->value[1] << 8 | write_req->value[2]; - xOneShotTimer = xTimerCreate("OneShot", seconds * 1000, pdFALSE, 0, - oneShotTimerCallback); - if ((xOneShotTimer != NULL)) { - xTimerStart(xOneShotTimer, 0); - } + set_timer(seconds); break; case 0xFF: setPWM(&write_req->value[1], write_req->len - 1); |
