Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions sql/AddDelayedGeneralPurposeTextValueBasedTrigger.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
INSERT INTO supla_dev_channel (
id,
iodevice_id,
user_id,
channel_number,
caption,
type,
func,
flist,
param1,
param2,
param3,
text_param1,
text_param2,
text_param3,
alt_icon,
hidden,
location_id,
flags,
user_icon_id,
user_config,
param4,
properties,
sub_device_id,
conflict_details
)
VALUES (
320,
83,
2,
100,
'GPT delayed',
9020,
540,
0,
0,
0,
0,
NULL,
NULL,
NULL,
NULL,
0,
NULL,
0,
NULL,
'[]',
0,
NULL,
0,
NULL
);

INSERT INTO supla_push_notification(id, user_id, channel_id, iodevice_id, managed_by_device, title, body, sound)
VALUES(500, 2, 320, 83, 0, 'Abcd', 'Efgh', 11);

INSERT INTO supla_value_based_trigger (id, user_id, owning_channel_id, channel_id, channel_group_id, scene_id, schedule_id, push_notification_id, `trigger`, action, action_param, enabled)
VALUES(34, 2, 320, NULL, NULL, NULL, NULL, 500, '{"on_change_to":{"eq":"match","duration_sec":1}}', 220, NULL, 1);
23 changes: 23 additions & 0 deletions sql/AddGeneralPurposeText.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- Supla general_purpose_text channel type - MariaDB migration
-- v. >= 29

CREATE TABLE IF NOT EXISTS `supla_gp_text_log` (
`channel_id` int(11) NOT NULL,
`date` datetime NOT NULL COMMENT '(DC2Type:stringdatetime)',
`value` varchar(255) NOT NULL,
PRIMARY KEY (`channel_id`,`date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

DROP PROCEDURE IF EXISTS `supla_add_gp_text_log_item`;

DELIMITER ;;
CREATE DEFINER=`supla`@`localhost` PROCEDURE `supla_add_gp_text_log_item`(
IN `_channel_id` INT,
IN `_value` VARCHAR(255)
)
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
INSERT INTO `supla_gp_text_log`(`channel_id`, `date`, `value`)
VALUES (_channel_id, UTC_TIMESTAMP(), _value) ;;
DELIMITER ;
81 changes: 81 additions & 0 deletions sql/AddGeneralPurposeTextValueBasedTrigger.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
INSERT INTO supla_dev_channel (
id,
iodevice_id,
user_id,
channel_number,
caption,
type,
func,
flist,
param1,
param2,
param3,
text_param1,
text_param2,
text_param3,
alt_icon,
hidden,
location_id,
flags,
user_icon_id,
user_config,
param4,
properties,
sub_device_id,
conflict_details
)
VALUES (
320,
83,
2,
99,
'GPT Trigger Channel',
9020,
540,
0,
0,
0,
0,
NULL,
NULL,
NULL,
NULL,
0,
NULL,
0,
NULL,
'[]',
0,
NULL,
0,
NULL
);

INSERT INTO supla_value_based_trigger (
id,
user_id,
owning_channel_id,
channel_id,
channel_group_id,
scene_id,
schedule_id,
push_notification_id,
`trigger`,
action,
action_param,
enabled
)
VALUES (
34,
2,
320,
NULL,
NULL,
NULL,
NULL,
500,
'{"on_change_to":{"eq":"match"}}',
220,
NULL,
1
);
11 changes: 11 additions & 0 deletions sql/TSDB_AddGeneralPurposeText.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Supla general_purpose_text channel type - TimescaleDB (TSDB) migration
-- v. >= 29

CREATE TABLE IF NOT EXISTS supla_gp_text_log (
channel_id INT NOT NULL,
date TIMESTAMPTZ(0) NOT NULL,
value VARCHAR(255) NOT NULL,
PRIMARY KEY(channel_id, date)
);
COMMENT ON COLUMN supla_gp_text_log.date IS '(DC2Type:stringdatetime)';
SELECT create_hypertable('supla_gp_text_log', 'date', if_not_exists => TRUE);
3 changes: 3 additions & 0 deletions sql/TSDB_TestDatabaseStructureAndData.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ SELECT create_hypertable('supla_temphumidity_log', 'date');
CREATE TABLE supla_thermostat_log (channel_id INT NOT NULL, date TIMESTAMPTZ(0) NOT NULL, "on" BOOLEAN NOT NULL, measured_temperature NUMERIC(5, 2) NOT NULL, preset_temperature NUMERIC(5, 2) NOT NULL, PRIMARY KEY(channel_id, date));
COMMENT ON COLUMN supla_thermostat_log.date IS '(DC2Type:stringdatetime)';
SELECT create_hypertable('supla_thermostat_log', 'date');
CREATE TABLE supla_gp_text_log (channel_id INT NOT NULL, date TIMESTAMPTZ(0) NOT NULL, value VARCHAR(255) NOT NULL, PRIMARY KEY(channel_id, date));
COMMENT ON COLUMN supla_gp_text_log.date IS '(DC2Type:stringdatetime)';
SELECT create_hypertable('supla_gp_text_log', 'date');

CREATE OR REPLACE FUNCTION supla_add_em_log_item(
_channel_id INT,
Expand Down
41 changes: 41 additions & 0 deletions sql/TestDatabaseStructureAndData.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,30 @@ LOCK TABLES `supla_gp_meter_log` WRITE;
/*!40000 ALTER TABLE `supla_gp_meter_log` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `supla_gp_text_log`
--

DROP TABLE IF EXISTS `supla_gp_text_log`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `supla_gp_text_log` (
`channel_id` int(11) NOT NULL,
`date` datetime NOT NULL COMMENT '(DC2Type:stringdatetime)',
`value` varchar(255) NOT NULL,
PRIMARY KEY (`channel_id`,`date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `supla_gp_text_log`
--

LOCK TABLES `supla_gp_text_log` WRITE;
/*!40000 ALTER TABLE `supla_gp_text_log` DISABLE KEYS */;
/*!40000 ALTER TABLE `supla_gp_text_log` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `supla_ic_log`
--
Expand Down Expand Up @@ -2564,6 +2588,23 @@ DELIMITER ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `supla_add_gp_text_log_item` */;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
/*!50003 SET @saved_cs_results = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client = utf8mb4 */ ;
/*!50003 SET character_set_results = utf8mb4 */ ;
/*!50003 SET collation_connection = utf8mb4_general_ci */ ;
DELIMITER ;;
CREATE DEFINER=`supla`@`localhost` PROCEDURE `supla_add_gp_text_log_item`(IN `_channel_id` INT, IN `_value` VARCHAR(255))
INSERT INTO `supla_gp_text_log`(`channel_id`, `date`, `value`) VALUES (_channel_id, UTC_TIMESTAMP(), _value) ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
/*!50003 SET character_set_client = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection = @saved_col_connection */ ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 DROP PROCEDURE IF EXISTS `supla_add_ic_log_item` */;
ALTER DATABASE `supla_test` CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
Expand Down
1 change: 1 addition & 0 deletions supla-client/Android/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ LOCAL_SRC_FILES := supla.cpp \
channel_config_weekly_schedule.cpp \
channel_config_general_purpose_measurement.cpp \
channel_config_general_purpose_meter.cpp \
channel_config_general_purpose_text.cpp \
channel_config_roller_shutter.cpp \
channel_config_facade_blind.cpp \
channel_config_container.cpp \
Expand Down
9 changes: 9 additions & 0 deletions supla-client/Android/jni/channel_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "channel_config_facade_blind.h"
#include "channel_config_general_purpose_measurement.h"
#include "channel_config_general_purpose_meter.h"
#include "channel_config_general_purpose_text.h"
#include "channel_config_hvac.h"
#include "channel_config_roller_shutter.h"
#include "channel_config_weekly_schedule.h"
Expand Down Expand Up @@ -111,6 +112,14 @@ jobject supla_channel_config_to_jobject(JNIEnv *env, TSCS_ChannelConfig *config,
(TChannelConfig_GeneralPurposeMeter *)config->Config);
}
break;
case SUPLA_CHANNELFNC_GENERAL_PURPOSE_TEXT:
if (config->ConfigType == SUPLA_CONFIG_TYPE_DEFAULT &&
sizeof(TChannelConfig_GeneralPurposeText) == config->ConfigSize) {
return supla_cc_gp_text_to_jobject(
env, config->ChannelId, config->Func, crc32,
(TChannelConfig_GeneralPurposeText *)config->Config);
}
break;
case SUPLA_CHANNELFNC_CONTROLLINGTHEROLLERSHUTTER:
case SUPLA_CHANNELFNC_CONTROLLINGTHEROOFWINDOW:
if (config->ConfigType == SUPLA_CONFIG_TYPE_DEFAULT &&
Expand Down
42 changes: 42 additions & 0 deletions supla-client/Android/jni/channel_config_general_purpose_text.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright (C) AC SOFTWARE SP. Z O.O.

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; either version 2
of the License, or (at your option) any later version.

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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include "channel_config_general_purpose_text.h"

#include "supla.h"

jobject supla_cc_gp_text_to_jobject(JNIEnv *env, _supla_int_t channel_id,
_supla_int_t func, jlong crc32,
TChannelConfig_GeneralPurposeText *config) {
jclass config_cls = env->FindClass(
"org/supla/android/data/source/remote/gpt/"
"SuplaChannelGeneralPurposeTextConfig");

jmethodID method_init = env->GetMethodID(
config_cls, "<init>",
"(ILjava/lang/Integer;JZI)V");

jobject result = env->NewObject(
config_cls, method_init, channel_id, supla_NewInt(env, func), crc32,
config->KeepHistory ? JNI_TRUE : JNI_FALSE,
(jint)config->RefreshIntervalMs);

env->DeleteLocalRef(config_cls);

return result;
}
37 changes: 37 additions & 0 deletions supla-client/Android/jni/channel_config_general_purpose_text.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
Copyright (C) AC SOFTWARE SP. Z O.O.

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; either version 2
of the License, or (at your option) any later version.

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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#ifndef CHANNEL_CONFIG_GENERAL_PURPOSE_TEXT_H_
#define CHANNEL_CONFIG_GENERAL_PURPOSE_TEXT_H_

#include <jni.h>

#include "proto.h"

#ifdef __cplusplus
extern "C" {
#endif

jobject supla_cc_gp_text_to_jobject(JNIEnv *env, _supla_int_t channel_id,
_supla_int_t func, jlong crc32,
TChannelConfig_GeneralPurposeText *config);

#ifdef __cplusplus
}
#endif
#endif /*CHANNEL_CONFIG_GENERAL_PURPOSE_TEXT_H_*/
Loading