diff --git a/.gitignore b/.gitignore index 72f4d988a193beb765562c75acff22c1b9ebe460..9ea85e7dda1069338672c8f8676cacefb975a985 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,5 @@ fabric.properties # Android studio 3.1+ serialized cache file .idea/caches/build_file_checksums.ser +target +logs \ No newline at end of file diff --git a/.idea/$PROJECT_FILE$ b/.idea/$PROJECT_FILE$ new file mode 100644 index 0000000000000000000000000000000000000000..58b7e3e570f8289344d345f6e3634608e74c690d --- /dev/null +++ b/.idea/$PROJECT_FILE$ @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..26d33521af10bcc7fd8cea344038eaaeb78d0ef5 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000000000000000000000000000000000000..9c791871ecf6b33b1d6cf7e20614799e3c36295a --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000000000000000000000000000000000000..aa00ffab7828f4818589659c804ec2cfd99baed3 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/google-java-format.xml b/.idea/google-java-format.xml new file mode 100644 index 0000000000000000000000000000000000000000..8b57f4527ab2bb586db85ec1471ea7926cee6c05 --- /dev/null +++ b/.idea/google-java-format.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000000000000000000000000000000000000..6560a98983ec708cf9d8b5c5c3776d7bd39c475b --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,36 @@ + + + + \ No newline at end of file diff --git a/.idea/iotos-soft-gateway-demo.iml b/.idea/iotos-soft-gateway-demo.iml new file mode 100644 index 0000000000000000000000000000000000000000..65eb2b6be21c2c2c53bac26eb23668082cb55d0f --- /dev/null +++ b/.idea/iotos-soft-gateway-demo.iml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000000000000000000000000000000000000..3757d9c31574901a1bfd124e5ef351adfbc9346e --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000000000000000000000000000000000000..edd11c1b4a4ab58a242abeddca90dfc5b2f763b8 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..61230f4242b0f91429aeb7357f3aed314d3d87c5 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/qaplug_profiles.xml b/.idea/qaplug_profiles.xml new file mode 100644 index 0000000000000000000000000000000000000000..c1ac4dcc78c9278b58cac4838295ee5f08247dc1 --- /dev/null +++ b/.idea/qaplug_profiles.xml @@ -0,0 +1,763 @@ + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..35eb1ddfbbc029bcab630581847471d7f238ec53 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 639ba0af4e4ea5179f7f8d31f84af6ecf619b1a5..0000000000000000000000000000000000000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# iotos-soft-gateway-demo - -#### Description -使用 iotos-soft-gateway 开发的驱动 demo - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md index 246be4e6205bc2dc32daa9c4fab0696bb8b60a33..d2e1db01eb559191522a74808b8aa5bce06239b3 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,16 @@ # iotos-soft-gateway-demo -#### 介绍 -使用 iotos-soft-gateway 开发的驱动 demo +本项目依赖 [iotos-soft-gateway](https://gitee.com/geekhekr/iotos-soft-gateway),是一个基于 IotOS 平台的软网关驱动示例。 -#### 软件架构 -软件架构说明 +## 介绍 +详细设计参考 [软网关驱动说明](https://gitee.com/geekhekr/iotos-soft-gateway/blob/master/README.md) -#### 安装教程 +## 开发 -1. xxxx -2. xxxx -3. xxxx +参考 [软网关开发说明](https://gitee.com/geekhekr/iotos-soft-gateway/blob/master/README.md#%E4%B8%9A%E5%8A%A1%E5%BC%80%E5%8F%91) -#### 使用说明 +## 打包 -1. xxxx -2. xxxx -3. xxxx - -#### 参与贡献 - -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request - - -#### 特技 - -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +开发完成后,将网关和子设备产品导出,(如果有其他文件也可以)放到 docs 文件夹下, +执行命令 `mvn clean package -Dmaven.test.skip=true` 会打包 jar 并将 README,docs 文件夹下的文件一并打包成 zip,生产的文件在 `target` 目录下。 diff --git a/assembly.xml b/assembly.xml new file mode 100644 index 0000000000000000000000000000000000000000..915163b37ea69f55c7da78e369328d7e4cf825ac --- /dev/null +++ b/assembly.xml @@ -0,0 +1,38 @@ + + full + + + + zip + + + + false + + + ${basedir}/target + . + + *.jar + + 0755 + + + + ${maven.multiModuleProjectDirectory} + . + + README.md + + + + ${maven.multiModuleProjectDirectory}/docs + . + + * + + + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..2b5719acfb69ef4d99ca243214017c0393e8df4c --- /dev/null +++ b/pom.xml @@ -0,0 +1,63 @@ + + + + iotos-soft-gateway + me.hekr.iotos.softgateway + 0.0.1 + + 4.0.0 + jar + iotos-soft-gateway-demo + + + 8 + 8 + + + + + hekr-iotos-soft-gateway + https://gitee.com/geekhekr/iotos-soft-gateway/raw/master/maven/repository + + + + + + + me.hekr.iotos.softgateway + framework-core + 0.0.1 + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.3.0 + + + assembly.xml   + + + + + make-assembly + package + + single + + + + + + + \ No newline at end of file diff --git a/src/main/java/me/hekr/iotos/softgateway/subsystem/IoTGatewayApplication.java b/src/main/java/me/hekr/iotos/softgateway/subsystem/IoTGatewayApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..40d3be60b2014dbcdaf08bcc353c813fc4758994 --- /dev/null +++ b/src/main/java/me/hekr/iotos/softgateway/subsystem/IoTGatewayApplication.java @@ -0,0 +1,16 @@ +package me.hekr.iotos.softgateway.subsystem; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableScheduling; + +/** @author iotos */ +@SuppressWarnings("AlibabaClassNamingShouldBeCamel") +@SpringBootApplication +@EnableScheduling +public class IoTGatewayApplication { + + public static void main(String[] args) throws Exception { + SpringApplication.run(IoTGatewayApplication.class, args); + } +} diff --git a/src/main/java/me/hekr/iotos/softgateway/subsystem/config/SpringScheduleConfig.java b/src/main/java/me/hekr/iotos/softgateway/subsystem/config/SpringScheduleConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..20c9f5afb2f5842a0b4dca45deac1b59c1a1f14e --- /dev/null +++ b/src/main/java/me/hekr/iotos/softgateway/subsystem/config/SpringScheduleConfig.java @@ -0,0 +1,36 @@ +package me.hekr.iotos.softgateway.subsystem.config; + +import java.util.concurrent.ScheduledExecutorService; +import me.hekr.iotos.softgateway.core.utils.ThreadPoolUtil; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.scheduling.annotation.SchedulingConfigurer; +import org.springframework.scheduling.config.ScheduledTaskRegistrar; + +/** + *
+ * + * @author iotos + */ +@Configuration +@EnableScheduling +public class SpringScheduleConfig implements SchedulingConfigurer { + + @Override + public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { + taskRegistrar.setScheduler(taskExecutor()); + } + + @Bean(destroyMethod = "shutdown") + public ScheduledExecutorService taskExecutor() { + return (ScheduledExecutorService) + new ThreadPoolUtil.Builder() + .setPrefix("spring-schedule") + .setCore(12) + .setMax(32) + .setQueueSize(1000) + .setScheduled(true) + .build(); + } +} diff --git a/src/main/java/me/hekr/iotos/softgateway/subsystem/package-info.java b/src/main/java/me/hekr/iotos/softgateway/subsystem/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..7e1cad727aa06278a95d816ff0c79ae6c29389c4 --- /dev/null +++ b/src/main/java/me/hekr/iotos/softgateway/subsystem/package-info.java @@ -0,0 +1,8 @@ +/** + * 子系统自定义开发在这个包 + * + * @see me.hekr.iotos.softgateway.core.config.DeviceMapper 通过网关的远程配置自动更新子系统和iot 设备缓存关系 + * @see me.hekr.iotos.softgateway.core.network.mqtt.listener.MqttConnectedListener 自定义 mqtt 连接监听器 + * @see me.hekr.iotos.softgateway.core.network.mqtt.listener.CoreMqttConnectedListenerImpl 内置连接监听器 + */ +package me.hekr.iotos.softgateway.subsystem; diff --git a/src/main/java/me/hekr/iotos/softgateway/subsystem/service/DemoSubSystemCommandServiceImpl.java b/src/main/java/me/hekr/iotos/softgateway/subsystem/service/DemoSubSystemCommandServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..4de854e1b76083582ba21f07a964875185984a87 --- /dev/null +++ b/src/main/java/me/hekr/iotos/softgateway/subsystem/service/DemoSubSystemCommandServiceImpl.java @@ -0,0 +1,24 @@ +package me.hekr.iotos.softgateway.subsystem.service; + +import lombok.extern.slf4j.Slf4j; +import me.hekr.iotos.softgateway.core.config.DeviceMapper; +import me.hekr.iotos.softgateway.core.klink.ModelData; +import me.hekr.iotos.softgateway.core.subsystem.SubsystemCommandService; +import org.springframework.stereotype.Service; + +/** + * demo 命令测试用例,如果需要处理,则需要在 iot 上物模型中定义一个 demo 的命令 + * + * @see me.hekr.iotos.softgateway.core.subsystem.SubsystemCommandService#handle(DeviceMapper, + * ModelData) + * @author iot + */ +@Service("demoSubSystemCommandService") +@Slf4j +public class DemoSubSystemCommandServiceImpl implements SubsystemCommandService { + + @Override + public void handle(DeviceMapper device, ModelData data) { + log.info("设备收到命令, 设备:{},命令:{}", device, data); + } +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000000000000000000000000000000000000..ecf6bf0c7eceae9f48d37e5822659c9e145dbc7c --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,42 @@ +server: + port: 8070 + +connect: + mqtt: + endpoint: 'tcp://106.75.50.110:1883' + # 链接超时时间,秒 + connectionTimeout: 10 + # 心跳保持,秒 + keepAliveTime: 60 + +gateway: + pk: 'b6e2cc8aaf6c4255a15106d4806cd7ec' + devId: 'demo_gateway' + devSecret: 'ae0122eeb6cd48e4b10405d04987946f' + +# 日志配置,注意仅针对 springboot 项目有效 +logging: + # 日志级别 + # 如果要加其他日志过滤,格式为: level.包名: LEVEL + # 比如 level.me.hekr.iotos: DEBUG + level: + root: INFO + me.hekr.iotos: INFO + io.netty: INFO + + # 日志文件保存位置 + file: logs/iotos-soft-gateway.log + pattern: + file: '%date{"yyyy-MM-dd HH:mm:ss.SSS"} %-5level [%thread] %logger{128}.%M:%line - %msg %n' + console: '%date{"yyyy-MM-dd HH:mm:ss.SSS"} %-5level [%thread] %logger{128}.%M:%line - %msg %n' + charset: + console: UTF-8 + file: UTF-8 + logback: + rollingpolicy: + file-name-pattern: ${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz + clean-history-on-start: true + # 日志文件大小 + max-file-size: '500mb' + # 历史日志文件保存天数 + max-history: 7 \ No newline at end of file