added default gateway token to database and myems_modbus_tcp

pull/79/MERGE
13621160019@163.com 2021-11-06 15:43:06 +08:00
parent 4329569bb1
commit a27d5762e1
7 changed files with 40 additions and 7 deletions

View File

@ -395,7 +395,6 @@ USE `myems_system_db`;
INSERT INTO `myems_system_db`.`tbl_gateways` INSERT INTO `myems_system_db`.`tbl_gateways`
(`id`, `name`, `uuid`, `token`, `last_seen_datetime_utc`) (`id`, `name`, `uuid`, `token`, `last_seen_datetime_utc`)
VALUES VALUES
(1, '网关1', 'dc681934-5053-4660-98ed-266c54227231', '983427af-1c35-42ba-8b4d-288675550225', null),
(2, '网关2', '8f75c0ab-9296-49c7-9058-8139febd0c31', 'd3860971-e6e0-4c98-9eba-5492869c5b19', null); (2, '网关2', '8f75c0ab-9296-49c7-9058-8139febd0c31', 'd3860971-e6e0-4c98-9eba-5492869c5b19', null);
COMMIT; COMMIT;

View File

@ -396,7 +396,6 @@ USE `myems_system_db`;
INSERT INTO `myems_system_db`.`tbl_gateways` INSERT INTO `myems_system_db`.`tbl_gateways`
(`id`, `name`, `uuid`, `token`, `last_seen_datetime_utc`) (`id`, `name`, `uuid`, `token`, `last_seen_datetime_utc`)
VALUES VALUES
(1, 'MyEMS Gateway 1', 'dc681934-5053-4660-98ed-266c54227231', '983427af-1c35-42ba-8b4d-288675550225', null),
(2, 'MyEMS Gateway 2', '8f75c0ab-9296-49c7-9058-8139febd0c31', 'd3860971-e6e0-4c98-9eba-5492869c5b19', null); (2, 'MyEMS Gateway 2', '8f75c0ab-9296-49c7-9058-8139febd0c31', 'd3860971-e6e0-4c98-9eba-5492869c5b19', null);
COMMIT; COMMIT;

View File

@ -396,7 +396,6 @@ USE `myems_system_db`;
INSERT INTO `myems_system_db`.`tbl_gateways` INSERT INTO `myems_system_db`.`tbl_gateways`
(`id`, `name`, `uuid`, `token`, `last_seen_datetime_utc`) (`id`, `name`, `uuid`, `token`, `last_seen_datetime_utc`)
VALUES VALUES
(1, 'MyEMS Gateway 1', 'dc681934-5053-4660-98ed-266c54227231', '983427af-1c35-42ba-8b4d-288675550225', null),
(2, 'MyEMS Gateway 2', '8f75c0ab-9296-49c7-9058-8139febd0c31', 'd3860971-e6e0-4c98-9eba-5492869c5b19', null); (2, 'MyEMS Gateway 2', '8f75c0ab-9296-49c7-9058-8139febd0c31', 'd3860971-e6e0-4c98-9eba-5492869c5b19', null);
COMMIT; COMMIT;

View File

@ -359,10 +359,25 @@ CREATE TABLE IF NOT EXISTS `myems_system_db`.`tbl_gateways` (
`name` VARCHAR(255) NOT NULL, `name` VARCHAR(255) NOT NULL,
`uuid` CHAR(36) NOT NULL, `uuid` CHAR(36) NOT NULL,
`token` CHAR(36) NOT NULL, `token` CHAR(36) NOT NULL,
`last_seen_datetime_utc` DATETIME NULL COMMENT 'The last seen date time in UTC via PING, TELNET or Heatbeat', `last_seen_datetime_utc` DATETIME NULL COMMENT 'The last seen date time in UTC via PING, TELNET or Heartbeat',
PRIMARY KEY (`id`)); PRIMARY KEY (`id`));
CREATE INDEX `tbl_gateways_index_1` ON `myems_system_db`.`tbl_gateways` (`name`); CREATE INDEX `tbl_gateways_index_1` ON `myems_system_db`.`tbl_gateways` (`name`);
-- ---------------------------------------------------------------------------------------------------------------------
-- Default Data for table `myems_system_db`.`tbl_gateways`
-- This gateway's token is used by myems-modbus-tcp service
-- ---------------------------------------------------------------------------------------------------------------------
START TRANSACTION;
USE `myems_system_db`;
INSERT INTO `myems_system_db`.`tbl_gateways`
(`id`, `name`, `uuid`, `token`, `last_seen_datetime_utc`)
VALUES
(1, 'Gateway1', 'dc681938-5053-8660-98ed-266c58227231', '983427af-1c35-42ba-8b4d-288675550225', null);
COMMIT;
-- --------------------------------------------------------------------------------------------------------------------- -- ---------------------------------------------------------------------------------------------------------------------
-- Table `myems_system_db`.`tbl_knowledge_files` -- Table `myems_system_db`.`tbl_knowledge_files`
-- --------------------------------------------------------------------------------------------------------------------- -- ---------------------------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,21 @@
-- PLEASE CHECK YOUR DATABASE TABLE myems_system_db.tbl_gateway,
-- If the tbl_gateways is empty
-- then run the statement below to insert the default gateway data
-- else please ignore and only run the update version number statement.
-- ---------------------------------------------------------------------------------------------------------------------
-- Default Data for table `myems_system_db`.`tbl_gateways`
-- This gateway's token is used by myems-modbus-tcp service
-- ---------------------------------------------------------------------------------------------------------------------
START TRANSACTION;
USE `myems_system_db`;
INSERT INTO `myems_system_db`.`tbl_gateways`
(`id`, `name`, `uuid`, `token`, `last_seen_datetime_utc`)
VALUES
(1, 'MyEMS Gateway 1', 'dc681938-5053-8660-98ed-266c58227231', '983427af-1c35-42ba-8b4d-288675550225', null);
COMMIT;
-- UPDATE VERSION NUMBER
UPDATE myems_system_db.tbl_versions SET version='1.3.4', release_date='2021-11-06' WHERE id=1;

View File

@ -14,8 +14,8 @@ MYEMS_HISTORICAL_DB_USER = config('MYEMS_HISTORICAL_DB_USER', default='root')
MYEMS_HISTORICAL_DB_PASSWORD = config('MYEMS_HISTORICAL_DB_PASSWORD', default='!MyEMS1') MYEMS_HISTORICAL_DB_PASSWORD = config('MYEMS_HISTORICAL_DB_PASSWORD', default='!MyEMS1')
INTERVAL_IN_SECONDS = config('INTERVAL_IN_SECONDS', default=600, cast=int) INTERVAL_IN_SECONDS = config('INTERVAL_IN_SECONDS', default=600, cast=int)
GATEWAY_ID = config('GATEWAY_ID', cast=int) GATEWAY_ID = config('GATEWAY_ID', default=1, cast=int)
GATEWAY_TOKEN = config('GATEWAY_TOKEN') GATEWAY_TOKEN = config('GATEWAY_TOKEN', default='983427af-1c35-42ba-8b4d-288675550225')
myems_system_db = { myems_system_db = {
'host': MYEMS_SYSTEM_DB_HOST, 'host': MYEMS_SYSTEM_DB_HOST,

View File

@ -18,4 +18,4 @@ INTERVAL_IN_SECONDS=600
# Get the gateway ID and token from MyEMS Admin # Get the gateway ID and token from MyEMS Admin
# This is used for getting data sources associated with the gateway # This is used for getting data sources associated with the gateway
GATEWAY_ID=1 GATEWAY_ID=1
GATEWAY_TOKEN=AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA GATEWAY_TOKEN=983427af-1c35-42ba-8b4d-288675550225