Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ademco_hb
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
ademco_hb
Commits
b28a56d2
Commit
b28a56d2
authored
Jul 30, 2022
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save
parent
3051b102
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
0 additions
and
2349 deletions
+0
-2349
ademco.vcxproj
examples/ademco/ademco.vcxproj
+0
-164
ademco.vcxproj.filters
examples/ademco/ademco.vcxproj.filters
+0
-30
ademco.vcxproj.user
examples/ademco/ademco.vcxproj.user
+0
-4
dllmain.c
examples/ademco/dllmain.c
+0
-21
ademco_hb.h
examples/ademco_hb/ademco_hb.h
+0
-64
ademco_hb.vcxproj
examples/ademco_hb/ademco_hb.vcxproj
+0
-186
ademco_hb.vcxproj.filters
examples/ademco_hb/ademco_hb.vcxproj.filters
+0
-36
ademco_hb.vcxproj.user
examples/ademco_hb/ademco_hb.vcxproj.user
+0
-4
dllmain.cpp
examples/ademco_hb/dllmain.cpp
+0
-65
framework.h
examples/ademco_hb/framework.h
+0
-16
pch.cpp
examples/ademco_hb/pch.cpp
+0
-5
pch.h
examples/ademco_hb/pch.h
+0
-13
Program.cs
examples/csharp_dll_demo/Program.cs
+0
-155
FolderProfile.pubxml
..._dll_demo/Properties/PublishProfiles/FolderProfile.pubxml
+0
-15
FolderProfile.pubxml.user
...demo/Properties/PublishProfiles/FolderProfile.pubxml.user
+0
-9
csharp_dll_demo.csproj
examples/csharp_dll_demo/csharp_dll_demo.csproj
+0
-14
csharp_dll_demo.csproj.user
examples/csharp_dll_demo/csharp_dll_demo.csproj.user
+0
-6
demo.cpp
examples/demo/demo.cpp
+0
-125
demo.vcxproj
examples/demo/demo.vcxproj
+0
-145
demo.vcxproj.filters
examples/demo/demo.vcxproj.filters
+0
-36
demo.vcxproj.user
examples/demo/demo.vcxproj.user
+0
-4
dll_demo.cpp
examples/dll_demo/dll_demo.cpp
+0
-64
dll_demo.vcxproj
examples/dll_demo/dll_demo.vcxproj
+0
-136
dll_demo.vcxproj.filters
examples/dll_demo/dll_demo.vcxproj.filters
+0
-22
dll_demo.vcxproj.user
examples/dll_demo/dll_demo.vcxproj.user
+0
-4
examples.sln
examples/examples.sln
+0
-121
ademco_java.vcxproj
examples/javademo/cpp/ademco_java.vcxproj
+0
-177
ademco_java.vcxproj.filters
examples/javademo/cpp/ademco_java.vcxproj.filters
+0
-39
ademco_java.vcxproj.user
examples/javademo/cpp/ademco_java.vcxproj.user
+0
-4
dllmain.cpp
examples/javademo/cpp/dllmain.cpp
+0
-172
framework.h
examples/javademo/cpp/framework.h
+0
-13
javademo_jni_AdemcoHbLibrary.h
examples/javademo/cpp/javademo_jni_AdemcoHbLibrary.h
+0
-61
javademo_jni_AdemcoHbLibrary_ParseResult.h
...s/javademo/cpp/javademo_jni_AdemcoHbLibrary_ParseResult.h
+0
-13
pch.cpp
examples/javademo/cpp/pch.cpp
+0
-5
pch.h
examples/javademo/cpp/pch.h
+0
-13
AdemcoHbLibrary.java
examples/javademo/jni/AdemcoHbLibrary.java
+0
-96
SimpleServer.java
examples/javademo/jni/SimpleServer.java
+0
-141
SimpleServerThread.java
examples/javademo/jni/SimpleServerThread.java
+0
-151
No files found.
examples/ademco/ademco.vcxproj
deleted
100644 → 0
View file @
3051b102
<?xml version="1.0" encoding="utf-8"?>
<Project
DefaultTargets=
"Build"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ItemGroup
Label=
"ProjectConfigurations"
>
<ProjectConfiguration
Include=
"Debug|Win32"
>
<Configuration>
Debug
</Configuration>
<Platform>
Win32
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Release|Win32"
>
<Configuration>
Release
</Configuration>
<Platform>
Win32
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Debug|x64"
>
<Configuration>
Debug
</Configuration>
<Platform>
x64
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Release|x64"
>
<Configuration>
Release
</Configuration>
<Platform>
x64
</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup
Label=
"Globals"
>
<VCProjectVersion>
16.0
</VCProjectVersion>
<Keyword>
Win32Proj
</Keyword>
<ProjectGuid>
{d0015e82-053e-431e-95d6-41e9ac9c1342}
</ProjectGuid>
<RootNamespace>
ademco
</RootNamespace>
<WindowsTargetPlatformVersion>
10.0
</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.Default.props"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
DynamicLibrary
</ConfigurationType>
<UseDebugLibraries>
true
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
DynamicLibrary
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
Label=
"Configuration"
>
<ConfigurationType>
DynamicLibrary
</ConfigurationType>
<UseDebugLibraries>
true
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
Label=
"Configuration"
>
<ConfigurationType>
DynamicLibrary
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.props"
/>
<ImportGroup
Label=
"ExtensionSettings"
>
</ImportGroup>
<ImportGroup
Label=
"Shared"
>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<PropertyGroup
Label=
"UserMacros"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<LinkIncremental>
true
</LinkIncremental>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<LinkIncremental>
false
</LinkIncremental>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<LinkIncremental>
true
</LinkIncremental>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<LinkIncremental>
false
</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
WIN32;_DEBUG;ADEMCO_EXPORTS;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
<PrecompiledHeader>
NotUsing
</PrecompiledHeader>
<PrecompiledHeaderFile>
pch.h
</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>
Windows
</SubSystem>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<EnableUAC>
false
</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
WIN32;NDEBUG;ADEMCO_EXPORTS;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
<PrecompiledHeader>
NotUsing
</PrecompiledHeader>
<PrecompiledHeaderFile>
pch.h
</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>
Windows
</SubSystem>
<EnableCOMDATFolding>
true
</EnableCOMDATFolding>
<OptimizeReferences>
true
</OptimizeReferences>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<EnableUAC>
false
</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
_DEBUG;ADEMCO_EXPORTS;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
<PrecompiledHeader>
NotUsing
</PrecompiledHeader>
<PrecompiledHeaderFile>
pch.h
</PrecompiledHeaderFile>
<LanguageStandard_C>
Default
</LanguageStandard_C>
</ClCompile>
<Link>
<SubSystem>
Windows
</SubSystem>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<EnableUAC>
false
</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
NDEBUG;ADEMCO_EXPORTS;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
<PrecompiledHeader>
NotUsing
</PrecompiledHeader>
<PrecompiledHeaderFile>
pch.h
</PrecompiledHeaderFile>
</ClCompile>
<Link>
<SubSystem>
Windows
</SubSystem>
<EnableCOMDATFolding>
true
</EnableCOMDATFolding>
<OptimizeReferences>
true
</OptimizeReferences>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<EnableUAC>
false
</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile
Include=
"..\..\c\ademco.c"
/>
<ClCompile
Include=
"dllmain.c"
/>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"..\..\c\ademco.h"
/>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<ImportGroup
Label=
"ExtensionTargets"
>
</ImportGroup>
</Project>
\ No newline at end of file
examples/ademco/ademco.vcxproj.filters
deleted
100644 → 0
View file @
3051b102
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"4.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ItemGroup>
<Filter
Include=
"Source Files"
>
<UniqueIdentifier>
{4FC737F1-C7A5-4376-A066-2A32D752A2FF}
</UniqueIdentifier>
<Extensions>
cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
</Extensions>
</Filter>
<Filter
Include=
"Header Files"
>
<UniqueIdentifier>
{93995380-89BD-4b04-88EB-625FBE52EBFB}
</UniqueIdentifier>
<Extensions>
h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
</Extensions>
</Filter>
<Filter
Include=
"Resource Files"
>
<UniqueIdentifier>
{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
</UniqueIdentifier>
<Extensions>
rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"dllmain.c"
>
<Filter>
Source Files
</Filter>
</ClCompile>
<ClCompile
Include=
"..\..\c\ademco.c"
>
<Filter>
Source Files
</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"..\..\c\ademco.h"
>
<Filter>
Source Files
</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
examples/ademco/ademco.vcxproj.user
deleted
100644 → 0
View file @
3051b102
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"Current"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<PropertyGroup
/>
</Project>
\ No newline at end of file
examples/ademco/dllmain.c
deleted
100644 → 0
View file @
3051b102
// dllmain.cpp : Defines the entry point for the DLL application.
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files
#include <windows.h>
BOOL
APIENTRY
DllMain
(
HMODULE
hModule
,
DWORD
ul_reason_for_call
,
LPVOID
lpReserved
)
{
switch
(
ul_reason_for_call
)
{
case
DLL_PROCESS_ATTACH
:
case
DLL_THREAD_ATTACH
:
case
DLL_THREAD_DETACH
:
case
DLL_PROCESS_DETACH
:
break
;
}
return
TRUE
;
}
examples/ademco_hb/ademco_hb.h
deleted
100644 → 0
View file @
3051b102
#
pragma
once
#ifdef ADEMCOHB_EXPORTS
#define DLL_FUNC extern "C" _declspec(dllexport)
#else
#define DLL_FUNC extern "C" _declspec(dllimport)
#endif
/*
* @brief 解析网络数据
* @param[in] pack 网络数据流
* @param[in] pack_len 网络数据流有效长度
* @param[in|out] cb_commited 可以正确解析的包长(单次函数调用最多解析一包)
* @return 0 解析到正确、完整的一包;1 解析到正确、不完整的一包,需要缓存数据,下次继续处理;2 解析到错误的数据,需要清空缓冲区
*/
DLL_FUNC
int
parse
(
const
char
*
pack
,
int
pack_len
,
int
*
cb_commited
);
/*
* @brief 将远程控制命令打包成网络传输数据
* @param[in|out] buff 缓冲区
* @param[in] buff_len 缓冲区长度
* @param[in] seq 序号
* @param[in] ademco_id 安定宝ID
* @param[in] ademco_event 安定宝事件码
* @param[in] zone 防区号
* @param[in] gg 分防区号
* @return 大于0 成功,返回值代表包长;0 buff空间不足
*/
DLL_FUNC
int
pack
(
char
*
buff
,
int
buff_len
,
int
seq
,
int
ademco_id
,
int
ademco_event
,
int
zone
,
int
gg
);
/*
* @brief 将远程控制命令打包成网络传输数据
* @param[in|out] buff 缓冲区
* @param[in] buff_len 缓冲区长度
* @param[in] seq 序号
* @param[in] acct 主机账号
* @param[in] ademco_id 安定宝ID
* @param[in] ademco_event 安定宝事件码
* @param[in] zone 防区号
* @param[in] gg 分防区号
* @return 大于0 成功,返回值代表包长;0 buff空间不足
*/
DLL_FUNC
int
pack2
(
char
*
buff
,
int
buff_len
,
int
seq
,
const
char
*
acct
,
int
ademco_id
,
int
ademco_event
,
int
zone
,
int
gg
);
/*
* @brief 打包ACK
* @param[in|out] buff 缓冲区
* @param[in] buff_len 缓冲区长度
* @param[in] seq 序号
* @param[in] ademco_id 安定宝ID
* @return 大于0 成功,返回值代表包长;0 buff空间不足
*/
DLL_FUNC
int
pack_ack
(
char
*
buff
,
int
buff_len
,
int
seq
,
int
ademco_id
);
/*
* @brief 打包ACK
* @param[in|out] buff 缓冲区
* @param[in] buff_len 缓冲区长度
* @param[in] seq 序号
* @param[in] acct 主机账号
* @return 大于0 成功,返回值代表包长;0 buff空间不足
*/
DLL_FUNC
int
pack_ack2
(
char
*
buff
,
int
buff_len
,
int
seq
,
const
char
*
acct
);
examples/ademco_hb/ademco_hb.vcxproj
deleted
100644 → 0
View file @
3051b102
<?xml version="1.0" encoding="utf-8"?>
<Project
DefaultTargets=
"Build"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ItemGroup
Label=
"ProjectConfigurations"
>
<ProjectConfiguration
Include=
"Debug|Win32"
>
<Configuration>
Debug
</Configuration>
<Platform>
Win32
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Release|Win32"
>
<Configuration>
Release
</Configuration>
<Platform>
Win32
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Debug|x64"
>
<Configuration>
Debug
</Configuration>
<Platform>
x64
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Release|x64"
>
<Configuration>
Release
</Configuration>
<Platform>
x64
</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup
Label=
"Globals"
>
<VCProjectVersion>
16.0
</VCProjectVersion>
<ProjectGuid>
{EF267749-DA49-433D-BF4E-742D4BC7F1DA}
</ProjectGuid>
<Keyword>
Win32Proj
</Keyword>
<RootNamespace>
ademcohb
</RootNamespace>
<WindowsTargetPlatformVersion>
10.0
</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.Default.props"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
DynamicLibrary
</ConfigurationType>
<UseDebugLibraries>
true
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<CharacterSet>
Unicode
</CharacterSet>
<CLRSupport>
false
</CLRSupport>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
DynamicLibrary
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<CharacterSet>
Unicode
</CharacterSet>
<CLRSupport>
false
</CLRSupport>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
Label=
"Configuration"
>
<ConfigurationType>
DynamicLibrary
</ConfigurationType>
<UseDebugLibraries>
true
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
Label=
"Configuration"
>
<ConfigurationType>
DynamicLibrary
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.props"
/>
<ImportGroup
Label=
"ExtensionSettings"
>
</ImportGroup>
<ImportGroup
Label=
"Shared"
>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<PropertyGroup
Label=
"UserMacros"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<LinkIncremental>
false
</LinkIncremental>
<OutDir>
$(SolutionDir)$(Platform)\$(Configuration)\
</OutDir>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<LinkIncremental>
true
</LinkIncremental>
<TargetName>
$(ProjectName)d
</TargetName>
<OutDir>
$(SolutionDir)$(Platform)\$(Configuration)\
</OutDir>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<LinkIncremental>
true
</LinkIncremental>
<TargetName>
$(ProjectName)d
</TargetName>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<LinkIncremental>
false
</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<ClCompile>
<PrecompiledHeader>
Use
</PrecompiledHeader>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
MaxSpeed
</Optimization>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
WIN32;NDEBUG;ADEMCOHB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
<PrecompiledHeaderFile>
pch.h
</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>
$(SolutionDir)..\include;%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
<CallingConvention>
Cdecl
</CallingConvention>
<CompileAs>
Default
</CompileAs>
</ClCompile>
<Link>
<SubSystem>
Windows
</SubSystem>
<EnableCOMDATFolding>
true
</EnableCOMDATFolding>
<OptimizeReferences>
true
</OptimizeReferences>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<EnableUAC>
false
</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<ClCompile>
<PrecompiledHeader>
Use
</PrecompiledHeader>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
WIN32;_DEBUG;ADEMCOHB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
<PrecompiledHeaderFile>
pch.h
</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>
$(SolutionDir)..\include;%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Windows
</SubSystem>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<EnableUAC>
false
</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<ClCompile>
<PrecompiledHeader>
Use
</PrecompiledHeader>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
_DEBUG;ADEMCOHB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
<PrecompiledHeaderFile>
pch.h
</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>
$(SolutionDir)..\include;%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Windows
</SubSystem>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<EnableUAC>
false
</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<ClCompile>
<PrecompiledHeader>
Use
</PrecompiledHeader>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
MaxSpeed
</Optimization>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
NDEBUG;ADEMCOHB_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
<PrecompiledHeaderFile>
pch.h
</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>
$(SolutionDir)..\include;%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Windows
</SubSystem>
<EnableCOMDATFolding>
true
</EnableCOMDATFolding>
<OptimizeReferences>
true
</OptimizeReferences>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<EnableUAC>
false
</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude
Include=
"ademco_hb.h"
/>
<ClInclude
Include=
"framework.h"
/>
<ClInclude
Include=
"pch.h"
/>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"dllmain.cpp"
/>
<ClCompile
Include=
"pch.cpp"
>
<PrecompiledHeader
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
Create
</PrecompiledHeader>
<PrecompiledHeader
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
Create
</PrecompiledHeader>
<PrecompiledHeader
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
Create
</PrecompiledHeader>
<PrecompiledHeader
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
Create
</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<ImportGroup
Label=
"ExtensionTargets"
>
</ImportGroup>
</Project>
\ No newline at end of file
examples/ademco_hb/ademco_hb.vcxproj.filters
deleted
100644 → 0
View file @
3051b102
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"4.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ItemGroup>
<Filter
Include=
"Source Files"
>
<UniqueIdentifier>
{4FC737F1-C7A5-4376-A066-2A32D752A2FF}
</UniqueIdentifier>
<Extensions>
cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
</Extensions>
</Filter>
<Filter
Include=
"Header Files"
>
<UniqueIdentifier>
{93995380-89BD-4b04-88EB-625FBE52EBFB}
</UniqueIdentifier>
<Extensions>
h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
</Extensions>
</Filter>
<Filter
Include=
"Resource Files"
>
<UniqueIdentifier>
{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
</UniqueIdentifier>
<Extensions>
rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"framework.h"
>
<Filter>
Header Files
</Filter>
</ClInclude>
<ClInclude
Include=
"pch.h"
>
<Filter>
Header Files
</Filter>
</ClInclude>
<ClInclude
Include=
"ademco_hb.h"
>
<Filter>
Header Files
</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"dllmain.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
<ClCompile
Include=
"pch.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
examples/ademco_hb/ademco_hb.vcxproj.user
deleted
100644 → 0
View file @
3051b102
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"Current"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<PropertyGroup
/>
</Project>
\ No newline at end of file
examples/ademco_hb/dllmain.cpp
deleted
100644 → 0
View file @
3051b102
// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
#include "ademco_hb.h"
#define DISABLE_JLIB_LOG2
#include <ademco_packet.h>
BOOL
APIENTRY
DllMain
(
HMODULE
hModule
,
DWORD
ul_reason_for_call
,
LPVOID
lpReserved
)
{
switch
(
ul_reason_for_call
)
{
case
DLL_PROCESS_ATTACH
:
case
DLL_THREAD_ATTACH
:
case
DLL_THREAD_DETACH
:
case
DLL_PROCESS_DETACH
:
break
;
}
return
TRUE
;
}
int
parse
(
const
char
*
pack
,
int
pack_len
,
int
*
cb_commited
)
{
ademco
::
AdemcoPacket
ap
;
size_t
commited
=
0
;
auto
result
=
ap
.
parse
(
pack
,
static_cast
<
size_t
>
(
pack_len
),
commited
);
*
cb_commited
=
static_cast
<
int
>
(
commited
);
return
static_cast
<
int
>
(
result
);
}
int
pack
(
char
*
buff
,
int
buff_len
,
int
seq
,
int
ademco_id
,
int
ademco_event
,
int
zone
,
int
gg
)
{
ademco
::
AdemcoPacket
ap
;
auto
res
=
ap
.
make_hb
(
buff
,
static_cast
<
size_t
>
(
buff_len
),
static_cast
<
uint16_t
>
(
seq
),
nullptr
,
static_cast
<
size_t
>
(
ademco_id
),
static_cast
<
unsigned
char
>
(
gg
),
static_cast
<
ademco
::
ADEMCO_EVENT
>
(
ademco_event
),
static_cast
<
size_t
>
(
zone
));
return
static_cast
<
int
>
(
res
);
}
int
pack2
(
char
*
buff
,
int
buff_len
,
int
seq
,
const
char
*
acct
,
int
ademco_id
,
int
ademco_event
,
int
zone
,
int
gg
)
{
ademco
::
AdemcoPacket
ap
;
auto
res
=
ap
.
make_hb
(
buff
,
static_cast
<
size_t
>
(
buff_len
),
static_cast
<
uint16_t
>
(
seq
),
acct
,
static_cast
<
size_t
>
(
ademco_id
),
static_cast
<
unsigned
char
>
(
gg
),
static_cast
<
ademco
::
ADEMCO_EVENT
>
(
ademco_event
),
static_cast
<
size_t
>
(
zone
));
return
static_cast
<
int
>
(
res
);
}
int
pack_ack
(
char
*
buff
,
int
buff_len
,
int
seq
,
int
ademco_id
)
{
ademco
::
AdemcoPacket
ap
;
auto
res
=
ap
.
make_ack
(
buff
,
static_cast
<
size_t
>
(
buff_len
),
static_cast
<
uint16_t
>
(
seq
),
nullptr
,
static_cast
<
size_t
>
(
ademco_id
));
return
static_cast
<
int
>
(
res
);
}
int
pack_ack2
(
char
*
buff
,
int
buff_len
,
int
seq
,
const
char
*
acct
)
{
ademco
::
AdemcoPacket
ap
;
auto
res
=
ap
.
make_ack
(
buff
,
static_cast
<
size_t
>
(
buff_len
),
static_cast
<
uint16_t
>
(
seq
),
acct
,
0
);
return
static_cast
<
int
>
(
res
);
}
\ No newline at end of file
examples/ademco_hb/framework.h
deleted
100644 → 0
View file @
3051b102
#pragma once
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#ifndef NOMINMAX
#define NOMINMAX
#endif
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files
#include <windows.h>
examples/ademco_hb/pch.cpp
deleted
100644 → 0
View file @
3051b102
// pch.cpp: source file corresponding to the pre-compiled header
#include "pch.h"
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
examples/ademco_hb/pch.h
deleted
100644 → 0
View file @
3051b102
// pch.h: This is a precompiled header file.
// Files listed below are compiled only once, improving build performance for future builds.
// This also affects IntelliSense performance, including code completion and many code browsing features.
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
// Do not add files here that you will be updating frequently as this negates the performance advantage.
#ifndef PCH_H
#define PCH_H
// add headers that you want to pre-compile here
#include "framework.h"
#endif //PCH_H
examples/csharp_dll_demo/Program.cs
deleted
100644 → 0
View file @
3051b102
using
System
;
using
System.Runtime.InteropServices
;
using
System.Text.RegularExpressions
;
using
System.Net
;
using
System.Net.Sockets
;
using
System.Threading
;
using
System.IO
;
namespace
csharp_dll_demo
{
class
Program
{
[
DllImport
(
@"ademco_hb.dll"
,
EntryPoint
=
"parse"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
public
static
extern
Int32
parse
(
string
buf
,
Int32
buf_len
,
ref
Int32
commited
);
[
DllImport
(
@"ademco_hb.dll"
,
EntryPoint
=
"pack"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
public
static
extern
Int32
pack
(
ref
byte
buf
,
Int32
buf_len
,
Int32
seq
,
Int32
ademco_id
,
Int32
ademco_event
,
Int32
zone
,
Int32
gg
);
[
DllImport
(
@"ademco_hb.dll"
,
EntryPoint
=
"pack"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
public
static
extern
Int32
pack2
(
ref
byte
buf
,
Int32
buf_len
,
Int32
seq
,
string
acct
,
Int32
ademco_id
,
Int32
ademco_event
,
Int32
zone
,
Int32
gg
);
[
DllImport
(
@"ademco_hb.dll"
,
EntryPoint
=
"pack_ack"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
public
static
extern
Int32
pack_ack
(
ref
byte
buf
,
Int32
buf_len
,
Int32
seq
,
Int32
ademco_id
);
[
DllImport
(
@"ademco_hb.dll"
,
EntryPoint
=
"pack_ack"
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
public
static
extern
Int32
pack_ack2
(
ref
byte
buf
,
Int32
buf_len
,
Int32
seq
,
string
acct
);
static
void
Main
(
string
[]
args
)
{
Console
.
WriteLine
(
"Hello World!"
);
// test parse
{
Console
.
WriteLine
(
"test parse"
);
string
raw
=
"\nC5C30053\"HENG-BO\"0000R000000L000000#90219125916578[#90219125916578|1737 00 000]_09:11:19,08-05-2019\r"
;
Int32
commited
=
0
;
Int32
res
=
parse
(
raw
,
raw
.
Length
,
ref
commited
);
Console
.
WriteLine
(
"res={0:D}, commited={1:D}"
,
res
,
commited
);
Console
.
WriteLine
(
"parse ademco_id/event, etc."
);
string
pattern
=
@"\#(?<acct>.+)\[\#(?<ademco_id>[0-9a-fA-F]+)\|(?<ademco_event>\d{4})\s(?<gg>\d{2})\s(?<zone>\d{3})\]"
;
foreach
(
Match
match
in
Regex
.
Matches
(
raw
,
pattern
))
{
GroupCollection
groups
=
match
.
Groups
;
foreach
(
Group
group
in
groups
)
{
Console
.
WriteLine
(
group
.
Name
+
" "
+
group
.
Value
);
}
}
Console
.
WriteLine
(
""
);
}
// test pack
{
Console
.
WriteLine
(
"test pack"
);
Byte
[]
buff
=
new
Byte
[
1024
];
Int32
res
=
pack
(
ref
buff
[
0
],
1024
,
1
,
666666
,
1400
,
0
,
0
);
Console
.
WriteLine
(
"res={0:D}"
,
res
);
string
str
=
System
.
Text
.
Encoding
.
Default
.
GetString
(
buff
,
0
,
res
);
Console
.
WriteLine
(
str
);
Console
.
WriteLine
(
"test parse packed data"
);
Int32
commited
=
0
;
res
=
parse
(
str
,
str
.
Length
,
ref
commited
);
Console
.
WriteLine
(
"res={0:D}, commited={1:D}"
,
res
,
commited
);
Console
.
WriteLine
(
str
);
Console
.
WriteLine
(
""
);
}
// test pack
// buff not enough
{
Console
.
WriteLine
(
"test pack, buff not enough"
);
Byte
[]
buff
=
new
Byte
[
10
];
Int32
res
=
pack
(
ref
buff
[
0
],
10
,
1
,
666666
,
1400
,
0
,
0
);
Console
.
WriteLine
(
"res={0:D}"
,
res
);
}
Console
.
WriteLine
(
""
);
simpleServer
(
12345
);
}
public
static
void
simpleServer
(
int
port
)
{
Console
.
WriteLine
(
"running simpleServer {0:D}"
,
port
);
try
{
Socket
serverSocekt
=
new
Socket
(
AddressFamily
.
InterNetwork
,
SocketType
.
Stream
,
ProtocolType
.
Tcp
);
serverSocekt
.
Bind
(
new
IPEndPoint
(
IPAddress
.
Any
,
port
));
serverSocekt
.
Listen
(
5
);
Socket
clientSocket
=
serverSocekt
.
Accept
();
Console
.
WriteLine
(
"client "
+
clientSocket
.
RemoteEndPoint
.
ToString
());
while
(
true
)
{
byte
[]
buff
=
new
byte
[
4096
];
int
len
=
clientSocket
.
Receive
(
buff
);
Int32
commited
=
0
;
string
data
=
System
.
Text
.
Encoding
.
Default
.
GetString
(
buff
,
0
,
len
);
Int32
res
=
parse
(
data
,
len
,
ref
commited
);
if
(
res
==
0
)
{
string
pattern
=
"\"(?<id>.+)\"(?<seq>\\d{4}).+\\#(?<acct>.+)\\["
;
Match
match
=
Regex
.
Matches
(
data
,
pattern
)[
0
];
string
id
=
match
.
Groups
[
"id"
].
Value
;
int
seq
=
Int32
.
Parse
(
match
.
Groups
[
"seq"
].
Value
);
//int ademco_id = Int32.Parse(match.Groups["ademco_id"].Value, System.Globalization.NumberStyles.HexNumber);
string
acct
=
match
.
Groups
[
"acct"
].
Value
;
// reply ack
{
Byte
[]
sendBuff
=
new
Byte
[
1024
];
res
=
pack_ack2
(
ref
sendBuff
[
0
],
1024
,
seq
,
acct
);
clientSocket
.
Send
(
sendBuff
,
0
,
res
,
SocketFlags
.
None
);
}
// handle event
if
(
id
==
"HENG-BO"
||
id
==
"ADM-CID"
)
{
pattern
=
@"\[\#(?<ademco_id>[0-9a-fA-F]+)\|(?<ademco_event>\d{4})\s(?<gg>\d{2})\s(?<zone>\d{3})\]"
;
//Console.WriteLine(Regex.Matches(data, pattern)[0].ToString());
foreach
(
Match
match2
in
Regex
.
Matches
(
data
,
pattern
))
{
GroupCollection
groups
=
match2
.
Groups
;
foreach
(
Group
group
in
groups
)
{
Console
.
WriteLine
(
group
.
Name
+
" "
+
group
.
Value
);
}
}
Console
.
WriteLine
(
""
);
}
}
}
}
catch
(
Exception
e
)
{
Console
.
WriteLine
(
e
.
Message
);
}
}
}
}
examples/csharp_dll_demo/Properties/PublishProfiles/FolderProfile.pubxml
deleted
100644 → 0
View file @
3051b102
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project
ToolsVersion=
"4.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<PropertyGroup>
<Configuration>
Release
</Configuration>
<Platform>
x64
</Platform>
<PublishDir>
bin\Release\netcoreapp2.1\publish\
</PublishDir>
<PublishProtocol>
FileSystem
</PublishProtocol>
<TargetFramework>
netcoreapp2.1
</TargetFramework>
<RuntimeIdentifier>
win-x64
</RuntimeIdentifier>
<SelfContained>
true
</SelfContained>
</PropertyGroup>
</Project>
\ No newline at end of file
examples/csharp_dll_demo/Properties/PublishProfiles/FolderProfile.pubxml.user
deleted
100644 → 0
View file @
3051b102
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project
ToolsVersion=
"4.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<PropertyGroup>
<History>
True|2021-06-28T11:04:09.4517217Z;True|2021-06-28T18:50:02.8566256+08:00;True|2021-06-28T18:45:00.6601786+08:00;True|2021-06-28T18:34:28.7493593+08:00;True|2021-06-28T18:30:14.2065837+08:00;
</History>
</PropertyGroup>
</Project>
\ No newline at end of file
examples/csharp_dll_demo/csharp_dll_demo.csproj
deleted
100644 → 0
View file @
3051b102
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="Current">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<FileUpgradeFlags>40</FileUpgradeFlags>
<UpgradeBackupLocation>D:\dev\ademco_hb\Backup\csharp_dll_demo\</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
<StartupObject>csharp_dll_demo.Program</StartupObject>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Prefer32Bit>false</Prefer32Bit>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
</Project>
\ No newline at end of file
examples/csharp_dll_demo/csharp_dll_demo.csproj.user
deleted
100644 → 0
View file @
3051b102
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"Current"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<PropertyGroup>
<_LastSelectedProfileId>
G:\dev_libs\ademco_hb\examples\csharp_dll_demo\Properties\PublishProfiles\FolderProfile.pubxml
</_LastSelectedProfileId>
</PropertyGroup>
</Project>
\ No newline at end of file
examples/demo/demo.cpp
deleted
100644 → 0
View file @
3051b102
#
ifndef
_CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#define DISABLE_JLIB_LOG2
#include <ademco_packet.h>
#include <ademco_detail.h>
using
namespace
ademco
;
#define EXPECT_EQ(a, b) assert((a) == (b))
#define EXPECT_TRUE(a) assert(a)
#define EXPECT_STREQ(a, b) assert(strcmp((a), (b)) == 0)
void
test
()
{
char
pack
[
1024
]
=
{
0
};
AdemcoPacket
ap
=
{};
// parse data from self made
{
auto
size
=
ap
.
make
(
pack
,
sizeof
(
pack
));
size_t
cb_commited
=
0
;
EXPECT_EQ
(
ap
.
parse
(
pack
,
size
,
cb_commited
),
ParseResult
::
RESULT_OK
);
EXPECT_EQ
(
cb_commited
,
size
);
}
// parse data from production
{
char
raw
[]
=
"
\n
C5C30053
\"
HENG-BO
\"
0000R000000L000000#90219125916578[#000000|1737 00 000]_09:11:19,08-05-2019
\r
"
;
size_t
cb_commited
=
0
;
EXPECT_EQ
(
ap
.
parse
(
raw
,
strlen
(
raw
),
cb_commited
),
ParseResult
::
RESULT_OK
);
EXPECT_EQ
(
cb_commited
,
strlen
(
raw
));
EXPECT_EQ
(
ap
.
crc_
.
value_
,
0xC5C3
);
EXPECT_EQ
(
ap
.
len_
.
value_
,
0x0053
);
EXPECT_EQ
(
ap
.
id_
.
eid_
,
AdemcoMsgId
::
Enum
::
id_hb
);
EXPECT_EQ
(
ap
.
seq_
.
value_
,
0
);
// 0 is not a valid seq, but...
EXPECT_TRUE
(
strncmp
(
"R000000"
,
ap
.
rrcvr_
.
data_
.
data
(),
7
)
==
0
);
EXPECT_TRUE
(
strncmp
(
"L000000"
,
ap
.
lpref_
.
data_
.
data
(),
7
)
==
0
);
EXPECT_STREQ
(
ap
.
acct_
.
acct
(),
"90219125916578"
);
EXPECT_EQ
(
ap
.
ademcoData_
.
ademco_id_
,
0
);
EXPECT_EQ
(
ap
.
ademcoData_
.
ademco_event_
,
ADEMCO_EVENT
::
EVENT_I_AM_WIRE_MACHINE
);
EXPECT_EQ
(
ap
.
ademcoData_
.
gg_
,
0
);
EXPECT_EQ
(
ap
.
ademcoData_
.
zone_
,
0
);
EXPECT_STREQ
(
ap
.
timestamp_
.
data_
,
"_09:11:19,08-05-2019"
);
}
}
void
generate_network_data
()
{
char
pack
[
1024
];
AdemcoPacket
ap
;
ap
.
make_hb
(
pack
,
sizeof
(
pack
),
1
,
"861234567890"
,
666666
,
0
,
ademco
::
EVENT_ARM
,
0
);
printf
(
"generate_network_data:%s
\n
"
,
ap
.
toString
().
data
());
}
void
handle_network_data
(
const
char
*
data_from_network
)
{
AdemcoPacket
ap
;
size_t
cb_commited
=
0
;
auto
result
=
ap
.
parse
(
data_from_network
,
strlen
(
data_from_network
),
cb_commited
);
switch
(
result
)
{
case
ademco
:
:
ParseResult
::
RESULT_OK
:
{
printf
(
"parse ok:
\n
%s
\n
"
,
ap
.
toString
().
data
());
switch
(
ap
.
id_
.
eid_
)
{
case
AdemcoMsgId
:
:
id_ack
:
// success
break
;
case
AdemcoMsgId
:
:
id_hb
:
// event report
// reply ack
{
char
ack
[
1024
];
ap
.
make_ack
(
ack
,
sizeof
(
ack
),
ap
.
seq_
.
value_
,
ap
.
acct_
.
acct
(),
ap
.
ademcoData_
.
ademco_id_
);
// send to machine via network
}
// handle event
printf
(
"%s
\n
"
,
ap
.
ademcoData_
.
toString
().
data
());
break
;
default:
break
;
}
break
;
}
case
ademco
:
:
ParseResult
::
RESULT_NOT_ENOUGH
:
printf
(
"not enough
\n
"
);
break
;
case
ademco
:
:
ParseResult
::
RESULT_DATA_ERROR
:
default:
printf
(
"cannot parse
\n
"
);
break
;
}
}
int
main
()
{
test
();
generate_network_data
();
char
data_from_network
[]
=
"
\n
C5C30053
\"
HENG-BO
\"
0000R000000L000000#90219125916578[#000000|1737 00 000]_09:11:19,08-05-2019
\r
"
;
handle_network_data
(
data_from_network
);
handle_network_data
(
"
\n
593F0034
\"
ACK
\"
0209R123ABCL456DEF#000001[]_09:00:00,04-18-2020
\r
"
);
char
buff
[
1024
];
AdemcoPacket
ap
;
ap
.
make
(
buff
,
sizeof
(
buff
));
handle_network_data
(
buff
);
ap
.
make_ack
(
buff
,
sizeof
(
buff
),
1
,
"861234567890"
,
123321
);
handle_network_data
(
buff
);
AdemcoId
ademco_id
=
123456
;
// 主机标识
AdemcoZone
zone
=
123
;
// 防区标识
auto
evnt
=
EVENT_FIRE
;
// 事件码
ap
.
make_hb
(
buff
,
sizeof
(
buff
),
1
,
nullptr
,
ademco_id
,
0
,
evnt
,
zone
);
handle_network_data
(
buff
);
}
examples/demo/demo.vcxproj
deleted
100644 → 0
View file @
3051b102
<?xml version="1.0" encoding="utf-8"?>
<Project
DefaultTargets=
"Build"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ItemGroup
Label=
"ProjectConfigurations"
>
<ProjectConfiguration
Include=
"Debug|Win32"
>
<Configuration>
Debug
</Configuration>
<Platform>
Win32
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Release|Win32"
>
<Configuration>
Release
</Configuration>
<Platform>
Win32
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Debug|x64"
>
<Configuration>
Debug
</Configuration>
<Platform>
x64
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Release|x64"
>
<Configuration>
Release
</Configuration>
<Platform>
x64
</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup
Label=
"Globals"
>
<VCProjectVersion>
16.0
</VCProjectVersion>
<ProjectGuid>
{36640D95-55AB-4DCF-9062-91A53203E6A9}
</ProjectGuid>
<RootNamespace>
demo
</RootNamespace>
<WindowsTargetPlatformVersion>
10.0
</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.Default.props"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
true
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<CharacterSet>
MultiByte
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<CharacterSet>
MultiByte
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
true
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<CharacterSet>
MultiByte
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<CharacterSet>
MultiByte
</CharacterSet>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.props"
/>
<ImportGroup
Label=
"ExtensionSettings"
>
</ImportGroup>
<ImportGroup
Label=
"Shared"
>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<PropertyGroup
Label=
"UserMacros"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<OutDir>
$(SolutionDir)$(Platform)\$(Configuration)\
</OutDir>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<OutDir>
$(SolutionDir)$(Platform)\$(Configuration)\
</OutDir>
</PropertyGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<SDLCheck>
true
</SDLCheck>
<ConformanceMode>
true
</ConformanceMode>
<AdditionalIncludeDirectories>
$(SolutionDir)..\include;%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<SDLCheck>
true
</SDLCheck>
<ConformanceMode>
true
</ConformanceMode>
<AdditionalIncludeDirectories>
$(SolutionDir)..\include;%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
MaxSpeed
</Optimization>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<SDLCheck>
true
</SDLCheck>
<ConformanceMode>
true
</ConformanceMode>
<AdditionalIncludeDirectories>
$(SolutionDir)..\include;%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<EnableCOMDATFolding>
true
</EnableCOMDATFolding>
<OptimizeReferences>
true
</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
MaxSpeed
</Optimization>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<SDLCheck>
true
</SDLCheck>
<ConformanceMode>
true
</ConformanceMode>
<AdditionalIncludeDirectories>
$(SolutionDir)..\include;%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<EnableCOMDATFolding>
true
</EnableCOMDATFolding>
<OptimizeReferences>
true
</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile
Include=
"demo.cpp"
/>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"..\include\ademco_detail.h"
/>
<ClInclude
Include=
"..\include\ademco_event.h"
/>
<ClInclude
Include=
"..\include\ademco_packet.h"
/>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<ImportGroup
Label=
"ExtensionTargets"
>
</ImportGroup>
</Project>
\ No newline at end of file
examples/demo/demo.vcxproj.filters
deleted
100644 → 0
View file @
3051b102
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"4.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ItemGroup>
<Filter
Include=
"Source Files"
>
<UniqueIdentifier>
{4FC737F1-C7A5-4376-A066-2A32D752A2FF}
</UniqueIdentifier>
<Extensions>
cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
</Extensions>
</Filter>
<Filter
Include=
"Header Files"
>
<UniqueIdentifier>
{93995380-89BD-4b04-88EB-625FBE52EBFB}
</UniqueIdentifier>
<Extensions>
h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
</Extensions>
</Filter>
<Filter
Include=
"Resource Files"
>
<UniqueIdentifier>
{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
</UniqueIdentifier>
<Extensions>
rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
</Extensions>
</Filter>
<Filter
Include=
"include"
>
<UniqueIdentifier>
{9cddb4df-0c1d-4f36-a814-5412a486e938}
</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"demo.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"..\include\ademco_detail.h"
>
<Filter>
include
</Filter>
</ClInclude>
<ClInclude
Include=
"..\include\ademco_event.h"
>
<Filter>
include
</Filter>
</ClInclude>
<ClInclude
Include=
"..\include\ademco_packet.h"
>
<Filter>
include
</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
examples/demo/demo.vcxproj.user
deleted
100644 → 0
View file @
3051b102
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"Current"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<PropertyGroup
/>
</Project>
\ No newline at end of file
examples/dll_demo/dll_demo.cpp
deleted
100644 → 0
View file @
3051b102
#
include
"../ademco_hb/ademco_hb.h"
#include <stdio.h>
#include <string.h>
#include <assert.h>
#ifdef _WIN64
#ifdef _DEBUG
#pragma comment(lib, "../x64/Debug/ademco_hbd.lib")
#else
#pragma comment(lib, "../x64/Release/ademco_hb.lib")
#endif
#else // WIN32
#ifdef _DEBUG
#pragma comment(lib, "../Win32/Debug/ademco_hbd.lib")
#else
#pragma comment(lib, "../Win32/Release/ademco_hb.lib")
#endif
#endif
int
main
()
{
int
cb_commited
=
0
;
// 解析完整数据包
{
char
raw
[]
=
"
\n
C5C30053
\"
HENG-BO
\"
0000R000000L000000#90219125916578[#000000|1737 00 000]_09:11:19,08-05-2019
\r
"
;
int
res
=
parse
(
raw
,
(
int
)
strlen
(
raw
),
&
cb_commited
);
assert
(
res
==
0
);
}
// 解析长度不足的数据包
{
char
raw_not_enough
[]
=
"
\n
C5C30053
\"
HENG-BO
\"
0000R000000L000000"
;
int
res
=
parse
(
raw_not_enough
,
(
int
)
strlen
(
raw_not_enough
),
&
cb_commited
);
assert
(
res
==
1
);
}
// 解析到错误数据包
{
char
raw_error
[]
=
"abcdeadfasdfasdfasd"
;
int
res
=
parse
(
raw_error
,
(
int
)
strlen
(
raw_error
),
&
cb_commited
);
assert
(
res
==
2
);
}
// 打包示例
{
char
buff
[
1024
];
// 对安定宝ID为666666的主机进行撤防
int
res
=
pack
(
buff
,
sizeof
(
buff
),
1
,
666666
,
1400
,
0
,
0
);
assert
(
res
>
0
);
//res = parse(buff, res, &cb_commited);
//assert(res == 0);
}
// ACK 示例
{
char
buff
[
1024
];
// 对安定宝ID为666666的主机回应ACK
int
res
=
pack_ack
(
buff
,
sizeof
(
buff
),
1
,
666666
);
assert
(
res
>
0
);
//res = parse(buff, res, &cb_commited);
//assert(res == 0);
}
}
examples/dll_demo/dll_demo.vcxproj
deleted
100644 → 0
View file @
3051b102
<?xml version="1.0" encoding="utf-8"?>
<Project
DefaultTargets=
"Build"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ItemGroup
Label=
"ProjectConfigurations"
>
<ProjectConfiguration
Include=
"Debug|Win32"
>
<Configuration>
Debug
</Configuration>
<Platform>
Win32
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Release|Win32"
>
<Configuration>
Release
</Configuration>
<Platform>
Win32
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Debug|x64"
>
<Configuration>
Debug
</Configuration>
<Platform>
x64
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Release|x64"
>
<Configuration>
Release
</Configuration>
<Platform>
x64
</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup
Label=
"Globals"
>
<VCProjectVersion>
16.0
</VCProjectVersion>
<ProjectGuid>
{76899E2F-3026-4262-8D0A-EE7CED1020CF}
</ProjectGuid>
<RootNamespace>
dlldemo
</RootNamespace>
<WindowsTargetPlatformVersion>
10.0
</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.Default.props"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
true
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<CharacterSet>
MultiByte
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<CharacterSet>
MultiByte
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
true
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<CharacterSet>
MultiByte
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<CharacterSet>
MultiByte
</CharacterSet>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.props"
/>
<ImportGroup
Label=
"ExtensionSettings"
>
</ImportGroup>
<ImportGroup
Label=
"Shared"
>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<PropertyGroup
Label=
"UserMacros"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<OutDir>
$(SolutionDir)$(Platform)\$(Configuration)\
</OutDir>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<OutDir>
$(SolutionDir)$(Platform)\$(Configuration)\
</OutDir>
</PropertyGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<SDLCheck>
true
</SDLCheck>
<ConformanceMode>
true
</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
Disabled
</Optimization>
<SDLCheck>
true
</SDLCheck>
<ConformanceMode>
true
</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
MaxSpeed
</Optimization>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<SDLCheck>
true
</SDLCheck>
<ConformanceMode>
true
</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<EnableCOMDATFolding>
true
</EnableCOMDATFolding>
<OptimizeReferences>
true
</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<Optimization>
MaxSpeed
</Optimization>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<SDLCheck>
true
</SDLCheck>
<ConformanceMode>
true
</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<EnableCOMDATFolding>
true
</EnableCOMDATFolding>
<OptimizeReferences>
true
</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile
Include=
"dll_demo.cpp"
/>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<ImportGroup
Label=
"ExtensionTargets"
>
</ImportGroup>
</Project>
\ No newline at end of file
examples/dll_demo/dll_demo.vcxproj.filters
deleted
100644 → 0
View file @
3051b102
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"4.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ItemGroup>
<Filter
Include=
"Source Files"
>
<UniqueIdentifier>
{4FC737F1-C7A5-4376-A066-2A32D752A2FF}
</UniqueIdentifier>
<Extensions>
cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
</Extensions>
</Filter>
<Filter
Include=
"Header Files"
>
<UniqueIdentifier>
{93995380-89BD-4b04-88EB-625FBE52EBFB}
</UniqueIdentifier>
<Extensions>
h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
</Extensions>
</Filter>
<Filter
Include=
"Resource Files"
>
<UniqueIdentifier>
{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
</UniqueIdentifier>
<Extensions>
rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"dll_demo.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
examples/dll_demo/dll_demo.vcxproj.user
deleted
100644 → 0
View file @
3051b102
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"Current"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<PropertyGroup
/>
</Project>
\ No newline at end of file
examples/examples.sln
View file @
b28a56d2
This diff is collapsed.
Click to expand it.
examples/javademo/cpp/ademco_java.vcxproj
deleted
100644 → 0
View file @
3051b102
<?xml version="1.0" encoding="utf-8"?>
<Project
DefaultTargets=
"Build"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ItemGroup
Label=
"ProjectConfigurations"
>
<ProjectConfiguration
Include=
"Debug|Win32"
>
<Configuration>
Debug
</Configuration>
<Platform>
Win32
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Release|Win32"
>
<Configuration>
Release
</Configuration>
<Platform>
Win32
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Debug|x64"
>
<Configuration>
Debug
</Configuration>
<Platform>
x64
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Release|x64"
>
<Configuration>
Release
</Configuration>
<Platform>
x64
</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup
Label=
"Globals"
>
<VCProjectVersion>
16.0
</VCProjectVersion>
<Keyword>
Win32Proj
</Keyword>
<ProjectGuid>
{b323151b-ad89-4545-b95e-e2442a7961bb}
</ProjectGuid>
<RootNamespace>
ademcojava
</RootNamespace>
<WindowsTargetPlatformVersion>
10.0
</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.Default.props"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
DynamicLibrary
</ConfigurationType>
<UseDebugLibraries>
true
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
DynamicLibrary
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
Label=
"Configuration"
>
<ConfigurationType>
DynamicLibrary
</ConfigurationType>
<UseDebugLibraries>
true
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
Label=
"Configuration"
>
<ConfigurationType>
DynamicLibrary
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.props"
/>
<ImportGroup
Label=
"ExtensionSettings"
>
</ImportGroup>
<ImportGroup
Label=
"Shared"
>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<PropertyGroup
Label=
"UserMacros"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<LinkIncremental>
true
</LinkIncremental>
<OutDir>
$(SolutionDir)$(Platform)\$(Configuration)\
</OutDir>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<LinkIncremental>
false
</LinkIncremental>
<OutDir>
$(SolutionDir)$(Platform)\$(Configuration)\
</OutDir>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<LinkIncremental>
true
</LinkIncremental>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<LinkIncremental>
false
</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
WIN32;_DEBUG;ADEMCOJAVA_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
<PrecompiledHeader>
Use
</PrecompiledHeader>
<PrecompiledHeaderFile>
pch.h
</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>
$(SolutionDir)..\include;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Windows
</SubSystem>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<EnableUAC>
false
</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
WIN32;NDEBUG;ADEMCOJAVA_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
<PrecompiledHeader>
Use
</PrecompiledHeader>
<PrecompiledHeaderFile>
pch.h
</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>
$(SolutionDir)..\include;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Windows
</SubSystem>
<EnableCOMDATFolding>
true
</EnableCOMDATFolding>
<OptimizeReferences>
true
</OptimizeReferences>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<EnableUAC>
false
</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
_DEBUG;ADEMCOJAVA_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
<PrecompiledHeader>
Use
</PrecompiledHeader>
<PrecompiledHeaderFile>
pch.h
</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>
$(SolutionDir)..\include;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Windows
</SubSystem>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<EnableUAC>
false
</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<SDLCheck>
true
</SDLCheck>
<PreprocessorDefinitions>
NDEBUG;ADEMCOJAVA_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
<ConformanceMode>
true
</ConformanceMode>
<PrecompiledHeader>
Use
</PrecompiledHeader>
<PrecompiledHeaderFile>
pch.h
</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>
$(SolutionDir)..\include;$(JAVA_HOME)\include;$(JAVA_HOME)\include\win32;%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>
Windows
</SubSystem>
<EnableCOMDATFolding>
true
</EnableCOMDATFolding>
<OptimizeReferences>
true
</OptimizeReferences>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<EnableUAC>
false
</EnableUAC>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude
Include=
"framework.h"
/>
<ClInclude
Include=
"javademo_jni_AdemcoHbLibrary.h"
/>
<ClInclude
Include=
"javademo_jni_AdemcoHbLibrary_ParseResult.h"
/>
<ClInclude
Include=
"pch.h"
/>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"dllmain.cpp"
/>
<ClCompile
Include=
"pch.cpp"
>
<PrecompiledHeader
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
Create
</PrecompiledHeader>
<PrecompiledHeader
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
Create
</PrecompiledHeader>
<PrecompiledHeader
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
Create
</PrecompiledHeader>
<PrecompiledHeader
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
Create
</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<ImportGroup
Label=
"ExtensionTargets"
>
</ImportGroup>
</Project>
\ No newline at end of file
examples/javademo/cpp/ademco_java.vcxproj.filters
deleted
100644 → 0
View file @
3051b102
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"4.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ItemGroup>
<Filter
Include=
"Source Files"
>
<UniqueIdentifier>
{4FC737F1-C7A5-4376-A066-2A32D752A2FF}
</UniqueIdentifier>
<Extensions>
cpp;c;cc;cxx;c++;def;odl;idl;hpj;bat;asm;asmx
</Extensions>
</Filter>
<Filter
Include=
"Header Files"
>
<UniqueIdentifier>
{93995380-89BD-4b04-88EB-625FBE52EBFB}
</UniqueIdentifier>
<Extensions>
h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
</Extensions>
</Filter>
<Filter
Include=
"Resource Files"
>
<UniqueIdentifier>
{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
</UniqueIdentifier>
<Extensions>
rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"framework.h"
>
<Filter>
Header Files
</Filter>
</ClInclude>
<ClInclude
Include=
"pch.h"
>
<Filter>
Header Files
</Filter>
</ClInclude>
<ClInclude
Include=
"javademo_jni_AdemcoHbLibrary.h"
>
<Filter>
Header Files
</Filter>
</ClInclude>
<ClInclude
Include=
"javademo_jni_AdemcoHbLibrary_ParseResult.h"
>
<Filter>
Header Files
</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"dllmain.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
<ClCompile
Include=
"pch.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
examples/javademo/cpp/ademco_java.vcxproj.user
deleted
100644 → 0
View file @
3051b102
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"Current"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<PropertyGroup
/>
</Project>
\ No newline at end of file
examples/javademo/cpp/dllmain.cpp
deleted
100644 → 0
View file @
3051b102
// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
#define DISABLE_JLIB_LOG2
#include <ademco_packet.h>
#include "javademo_jni_AdemcoHbLibrary.h"
#ifdef _WIN32
BOOL
APIENTRY
DllMain
(
HMODULE
hModule
,
DWORD
ul_reason_for_call
,
LPVOID
lpReserved
)
{
switch
(
ul_reason_for_call
)
{
case
DLL_PROCESS_ATTACH
:
case
DLL_THREAD_ATTACH
:
case
DLL_THREAD_DETACH
:
case
DLL_PROCESS_DETACH
:
break
;
}
return
TRUE
;
}
#endif
JNIEXPORT
void
JNICALL
Java_javademo_jni_AdemcoHbLibrary_testPrint
(
JNIEnv
*
,
jobject
)
{
printf
(
"native print
\n
"
);
}
JNIEXPORT
jobject
JNICALL
Java_javademo_jni_AdemcoHbLibrary_parse
(
JNIEnv
*
env
,
jobject
,
jstring
pack
,
jint
pack_len
)
{
ademco
::
AdemcoPacket
ap
;
size_t
commited
=
0
;
jboolean
iscopy
=
0
;
std
::
string
s
=
env
->
GetStringUTFChars
(
pack
,
&
iscopy
);
auto
result
=
ap
.
parse
(
s
.
data
(),
static_cast
<
size_t
>
(
pack_len
),
commited
);
// Attempt to find the Version class.
jclass
clazz
=
env
->
FindClass
(
"javademo/jni/AdemcoHbLibrary$ParseResult"
);
// If this class does not exist then return null.
if
(
clazz
==
0
)
return
0
;
// Allocate memory for a new Version class object. Do not bother calling
// the constructor (the default constructor does nothing).
jobject
obj
=
env
->
AllocObject
(
clazz
);
// Attempt to find the major field.
jfieldID
fid
=
env
->
GetFieldID
(
clazz
,
"result"
,
"I"
);
// If this field does not exist then return null.
if
(
fid
==
0
)
return
0
;
// Set the major field to the operating system's major version.
env
->
SetIntField
(
obj
,
fid
,
static_cast
<
int
>
(
result
));
// Attempt to find the minor field.
fid
=
env
->
GetFieldID
(
clazz
,
"cb_commited"
,
"I"
);
// If this field does not exist then return null.
if
(
fid
==
0
)
return
0
;
// Set the minor field to the operating system's minor version.
env
->
SetIntField
(
obj
,
fid
,
static_cast
<
int
>
(
commited
));
return
obj
;
}
JNIEXPORT
jstring
JNICALL
Java_javademo_jni_AdemcoHbLibrary_pack
(
JNIEnv
*
env
,
jobject
,
jint
seq
,
jstring
acct
,
jint
ademco_id
,
jint
ademco_event
,
jint
zone
,
jint
gg
)
{
ademco
::
AdemcoPacket
ap
;
char
buff
[
1024
];
jboolean
iscopy
=
0
;
std
::
string
sacct
=
env
->
GetStringUTFChars
(
acct
,
&
iscopy
);
auto
res
=
ap
.
make_hb
(
buff
,
sizeof
(
buff
),
static_cast
<
uint16_t
>
(
seq
),
sacct
,
static_cast
<
size_t
>
(
ademco_id
),
static_cast
<
unsigned
char
>
(
gg
),
static_cast
<
ademco
::
ADEMCO_EVENT
>
(
ademco_event
),
static_cast
<
size_t
>
(
zone
));
if
(
res
>
0
)
{
buff
[
res
]
=
0
;
return
env
->
NewStringUTF
(
buff
);
}
return
0
;
}
JNIEXPORT
jstring
JNICALL
Java_javademo_jni_AdemcoHbLibrary_pack2
(
JNIEnv
*
env
,
jobject
,
jint
seq
,
jstring
acct
,
jint
ademco_id
,
jint
ademco_event
,
jint
zone
,
jint
gg
,
jstring
xdata
)
{
jboolean
iscopy
=
0
;
std
::
string
sacct
=
env
->
GetStringUTFChars
(
acct
,
&
iscopy
);
std
::
string
s
=
env
->
GetStringUTFChars
(
xdata
,
&
iscopy
);
auto
xdata_
=
ademco
::
makeXData
(
s
.
data
(),
s
.
size
());
ademco
::
AdemcoPacket
ap
;
char
buff
[
1024
]
=
{
0
};
auto
res
=
ap
.
make_hb
(
buff
,
sizeof
(
buff
),
static_cast
<
uint16_t
>
(
seq
),
sacct
,
static_cast
<
size_t
>
(
ademco_id
),
static_cast
<
unsigned
char
>
(
gg
),
static_cast
<
ademco
::
ADEMCO_EVENT
>
(
ademco_event
),
static_cast
<
size_t
>
(
zone
),
xdata_
);
if
(
res
>
0
)
{
//buff[res] = 0;
auto
ascii
=
ademco
::
detail
::
toString
(
buff
,
res
,
ademco
::
detail
::
ToStringOption
::
ALL_CHAR_AS_HEX
,
false
,
false
);
memcpy
(
buff
,
ascii
.
data
(),
ascii
.
size
());
return
env
->
NewStringUTF
(
buff
);
}
return
0
;
}
JNIEXPORT
jcharArray
JNICALL
Java_javademo_jni_AdemcoHbLibrary_pack3
(
JNIEnv
*
env
,
jobject
,
jint
seq
,
jstring
acct
,
jint
ademco_id
,
jint
ademco_event
,
jint
zone
,
jint
gg
,
jcharArray
xdata
,
jint
xdata_len
)
{
jboolean
iscopy
=
0
;
std
::
string
sacct
=
env
->
GetStringUTFChars
(
acct
,
&
iscopy
);
jchar
*
array
=
env
->
GetCharArrayElements
(
xdata
,
nullptr
);
//复制数组元素到array内存空间
if
(
array
==
nullptr
){
return
0
;
}
jboolean
*
buf
=
(
jboolean
*
)
calloc
(
xdata_len
,
sizeof
(
jboolean
));
//开辟jboolean类型的内存空间,jboolean对应的c++类型为unsigned char
if
(
buf
==
nullptr
){
return
0
;
}
for
(
int
i
=
0
;
i
<
xdata_len
;
i
++
){
//把jcharArray的数据元素复制到buf所指的内存空间
*
(
buf
+
i
)
=
(
jboolean
)(
*
(
array
+
i
));
}
env
->
ReleaseCharArrayElements
(
xdata
,
array
,
0
);
//释放资源
auto
xdata_
=
ademco
::
makeXData
(
buf
,
xdata_len
);
free
(
buf
);
//释放内存空间
buf
=
nullptr
;
ademco
::
AdemcoPacket
ap
;
char
buff
[
1024
]
=
{
0
};
auto
res
=
ap
.
make_hb
(
buff
,
sizeof
(
buff
),
static_cast
<
uint16_t
>
(
seq
),
sacct
,
static_cast
<
size_t
>
(
ademco_id
),
static_cast
<
unsigned
char
>
(
gg
),
static_cast
<
ademco
::
ADEMCO_EVENT
>
(
ademco_event
),
static_cast
<
size_t
>
(
zone
),
xdata_
);
if
(
res
>
0
)
{
buff
[
res
]
=
0
;
//auto ascii = ademco::detail::toString(buff, res, ademco::detail::ToStringOption::ALL_CHAR_AS_HEX, false, false);
//memcpy(buff, ascii.data(), ascii.size());
//return env->NewStringUTF(buff);
jcharArray
rarray
=
env
->
NewCharArray
(
res
);
//定义数据变量
if
(
rarray
==
nullptr
){
return
0
;
}
jchar
*
pArray
=
(
jchar
*
)
calloc
(
res
,
sizeof
(
jchar
));
//开辟jchar类型内存空间
if
(
pArray
==
nullptr
){
return
0
;
}
//copy buffer to jchar array
for
(
int
i
=
0
;
i
<
res
;
i
++
)
{
*
(
pArray
+
i
)
=
buff
[
i
];
//复制bufTemp数据元素到pArray内存空间
}
env
->
SetCharArrayRegion
(
rarray
,
0
,
res
,
pArray
);
//复制pArray的jchar数据元素到jcharArray
return
rarray
;
}
return
0
;
}
JNIEXPORT
jstring
JNICALL
Java_javademo_jni_AdemcoHbLibrary_packAck
(
JNIEnv
*
env
,
jobject
,
jint
seq
,
jstring
acct
)
{
ademco
::
AdemcoPacket
ap
;
char
buff
[
1024
];
jboolean
iscopy
=
0
;
std
::
string
s
=
env
->
GetStringUTFChars
(
acct
,
&
iscopy
);
auto
res
=
ap
.
make_ack
(
buff
,
sizeof
(
buff
),
static_cast
<
uint16_t
>
(
seq
),
s
,
0
);
if
(
res
>
0
)
{
buff
[
res
]
=
0
;
return
env
->
NewStringUTF
(
buff
);
}
return
0
;
}
examples/javademo/cpp/framework.h
deleted
100644 → 0
View file @
3051b102
#pragma once
#ifdef _WIN32
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
#ifndef NOMINMAX
#define NOMINMAX
#endif
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
// Windows Header Files
#include <windows.h>
#endif
examples/javademo/cpp/javademo_jni_AdemcoHbLibrary.h
deleted
100644 → 0
View file @
3051b102
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class javademo_jni_AdemcoHbLibrary */
#ifndef _Included_javademo_jni_AdemcoHbLibrary
#define _Included_javademo_jni_AdemcoHbLibrary
#ifdef __cplusplus
extern
"C"
{
#endif
/*
* Class: javademo_jni_AdemcoHbLibrary
* Method: testPrint
* Signature: ()V
*/
JNIEXPORT
void
JNICALL
Java_javademo_jni_AdemcoHbLibrary_testPrint
(
JNIEnv
*
,
jobject
);
/*
* Class: javademo_jni_AdemcoHbLibrary
* Method: parse
* Signature: (Ljava/lang/String;I)Ljavademo/jni/AdemcoHbLibrary/ParseResult;
*/
JNIEXPORT
jobject
JNICALL
Java_javademo_jni_AdemcoHbLibrary_parse
(
JNIEnv
*
,
jobject
,
jstring
,
jint
);
/*
* Class: javademo_jni_AdemcoHbLibrary
* Method: pack
* Signature: (ILjava/lang/String;IIII)Ljava/lang/String;
*/
JNIEXPORT
jstring
JNICALL
Java_javademo_jni_AdemcoHbLibrary_pack
(
JNIEnv
*
,
jobject
,
jint
,
jstring
,
jint
,
jint
,
jint
,
jint
);
/*
* Class: javademo_jni_AdemcoHbLibrary
* Method: pack2
* Signature: (ILjava/lang/String;IIIILjava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT
jstring
JNICALL
Java_javademo_jni_AdemcoHbLibrary_pack2
(
JNIEnv
*
,
jobject
,
jint
,
jstring
,
jint
,
jint
,
jint
,
jint
,
jstring
);
/*
* Class: javademo_jni_AdemcoHbLibrary
* Method: pack3
* Signature: (ILjava/lang/String;IIII[CI)[C
*/
JNIEXPORT
jcharArray
JNICALL
Java_javademo_jni_AdemcoHbLibrary_pack3
(
JNIEnv
*
,
jobject
,
jint
,
jstring
,
jint
,
jint
,
jint
,
jint
,
jcharArray
,
jint
);
/*
* Class: javademo_jni_AdemcoHbLibrary
* Method: packAck
* Signature: (ILjava/lang/String;)Ljava/lang/String;
*/
JNIEXPORT
jstring
JNICALL
Java_javademo_jni_AdemcoHbLibrary_packAck
(
JNIEnv
*
,
jobject
,
jint
,
jstring
);
#ifdef __cplusplus
}
#endif
#endif
examples/javademo/cpp/javademo_jni_AdemcoHbLibrary_ParseResult.h
deleted
100644 → 0
View file @
3051b102
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class javademo_jni_AdemcoHbLibrary_ParseResult */
#ifndef _Included_javademo_jni_AdemcoHbLibrary_ParseResult
#define _Included_javademo_jni_AdemcoHbLibrary_ParseResult
#ifdef __cplusplus
extern
"C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif
examples/javademo/cpp/pch.cpp
deleted
100644 → 0
View file @
3051b102
// pch.cpp: source file corresponding to the pre-compiled header
#include "pch.h"
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
examples/javademo/cpp/pch.h
deleted
100644 → 0
View file @
3051b102
// pch.h: This is a precompiled header file.
// Files listed below are compiled only once, improving build performance for future builds.
// This also affects IntelliSense performance, including code completion and many code browsing features.
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
// Do not add files here that you will be updating frequently as this negates the performance advantage.
#ifndef PCH_H
#define PCH_H
// add headers that you want to pre-compile here
#include "framework.h"
#endif //PCH_H
examples/javademo/jni/AdemcoHbLibrary.java
deleted
100644 → 0
View file @
3051b102
package
javademo
.
jni
;
import
java.nio.file.FileSystems
;
public
class
AdemcoHbLibrary
{
static
{
if
(
System
.
getProperty
(
"os.name"
).
startsWith
(
"Windows"
))
{
// Windows
System
.
load
(
FileSystems
.
getDefault
()
.
getPath
(
"./x64/Release/ademco_java.dll"
)
// Dynamic link
.
normalize
().
toAbsolutePath
().
toString
());
}
else
{
// Unix based
System
.
load
(
FileSystems
.
getDefault
()
.
getPath
(
"./build/libademcojava.so"
)
// Dynamic link
.
normalize
().
toAbsolutePath
().
toString
());
}
}
public
native
void
testPrint
();
public
class
ParseResult
{
// 0 解析到正确、完整的一包;
// 1 解析到正确、不完整的一包,需要缓存数据,下次继续处理;
// 2 解析到错误的数据,需要清空缓冲区
public
int
result
;
// 可以正确解析的包长(单次函数调用最多解析一包)
public
int
cb_commited
;
}
/*
* @brief 解析网络数据
* @param[in] pack 网络数据流
* @param[in] pack_len 网络数据流有效长度
* @return ParseResult
*/
public
native
ParseResult
parse
(
String
pack
,
int
pack_len
);
/*
* @brief 将远程控制命令(不包含xdata)打包成网络传输数据
* @param[in] seq 序号
* @param[in] acct 主机账号
* @param[in] ademco_id 安定宝ID
* @param[in] ademco_event 安定宝事件码
* @param[in] zone 防区号
* @param[in] gg 分防区号
* @return String
*/
public
native
String
pack
(
int
seq
,
String
acct
,
int
ademco_id
,
int
ademco_event
,
int
zone
,
int
gg
);
/*
* @brief 将远程控制命令(包含xdata,xdata为ASC字符串)打包成网络传输数据
* @param[in] seq 序号
* @param[in] acct 主机账号
* @param[in] ademco_id 安定宝ID
* @param[in] ademco_event 安定宝事件码
* @param[in] zone 防区号
* @param[in] gg 分防区号
* @param[in] xdata xdata
* @return hex String,如字符串"123456" 表示为 "313233343536", 需手动转换为byte[] 进行发送,参考SimpleServerThread
*/
public
native
String
pack2
(
int
seq
,
String
acct
,
int
ademco_id
,
int
ademco_event
,
int
zone
,
int
gg
,
String
xdata
);
/*
* @brief 将远程控制命令(包含xdata,xdata包含非ASC字符)打包成网络传输数据
* @param[in] seq 序号
* @param[in] acct 主机账号
* @param[in] ademco_id 安定宝ID
* @param[in] ademco_event 安定宝事件码
* @param[in] zone 防区号
* @param[in] gg 分防区号
* @param[in] xdata xdata
* @param[in] xdata_len xdata长度
* @return char array,可直接用于网络传输。
*/
public
native
char
[]
pack3
(
int
seq
,
String
acct
,
int
ademco_id
,
int
ademco_event
,
int
zone
,
int
gg
,
char
[]
xdata
,
int
xdata_len
);
/*
* @brief 打包ACK
* @param[in] seq 序号
* @param[in] acct 主机账号
* @return String
*/
public
native
String
packAck
(
int
seq
,
String
acct
);
// public void testPrint(){ nativePrint(); }
// public ParseResult parse(String pack, int pack_len){return nativeParse(pack, pack_len);}
// public String pack(int seq, int ademco_id, int ademco_event, int zone, int gg){return nativePack(seq, ademco_id, ademco_event, zone, gg);}
// public String packAck(int seq, int ademco_id){return nativePackAck(seq, ademco_id);}
}
examples/javademo/jni/SimpleServer.java
deleted
100644 → 0
View file @
3051b102
package
javademo
.
jni
;
import
java.io.*
;
import
java.net.*
;
public
class
SimpleServer
{
public
static
String
printable_bytes
(
byte
[]
b
){
String
HEX_STRING
=
"0123456789ABCDEF"
;
String
s
=
""
;
for
(
int
i
=
0
;
i
<
b
.
length
;
i
++){
byte
c
=
b
[
i
];
if
(
32
<=
c
&&
c
<=
127
){
s
+=
(
char
)
c
;
}
else
{
s
+=
"\\x"
+
HEX_STRING
.
charAt
(
b
[
i
]
>>>
4
);
s
+=
HEX_STRING
.
charAt
(
b
[
i
]
&
0x0F
);
}
}
return
s
;
}
public
static
String
printable_bytes
(
char
[]
b
){
String
HEX_STRING
=
"0123456789ABCDEF"
;
String
s
=
""
;
for
(
int
i
=
0
;
i
<
b
.
length
;
i
++){
int
c
=
b
[
i
]
&
0xFF
;
if
(
32
<=
c
&&
c
<=
127
){
s
+=
(
char
)
c
;
}
else
{
s
+=
"\\x"
+
HEX_STRING
.
charAt
(
c
>>>
4
);
s
+=
HEX_STRING
.
charAt
(
c
&
0x0F
);
}
}
return
s
;
}
public
static
String
printable_bytes
(
String
b
){
String
HEX_STRING
=
"0123456789ABCDEF"
;
String
s
=
""
;
for
(
int
i
=
0
;
i
<
b
.
length
();
i
++){
char
c
=
b
.
charAt
(
i
);
if
(
32
<=
c
&&
c
<=
127
){
s
+=
(
char
)
c
;
}
else
{
s
+=
"\\x"
+
HEX_STRING
.
charAt
(
c
>>>
4
);
s
+=
HEX_STRING
.
charAt
(
c
&
0x0F
);
}
}
return
s
;
}
public
static
void
main
(
String
[]
args
)
{
AdemcoHbLibrary
lib
=
new
AdemcoHbLibrary
();
lib
.
testPrint
();
// test parse
{
System
.
out
.
println
(
"testing parse..."
);
String
data
=
"\nC5C30053\"HENG-BO\"0000R000000L000000#90219125916578[#000000|1737 00 000]_09:11:19,08-05-2019\r"
;
System
.
out
.
println
(
"using data="
+
data
);
AdemcoHbLibrary
.
ParseResult
res
=
lib
.
parse
(
data
,
data
.
length
());
assert
(
res
.
result
==
0
);
assert
(
res
.
cb_commited
==
data
.
length
());
System
.
out
.
println
(
"parse result="
+
res
.
result
+
",cb_commited="
+
res
.
cb_commited
);
}
// test pack
{
System
.
out
.
println
(
"testing pack..."
);
System
.
out
.
println
(
"using seq=1234, acct=861234567890, ademco_id=666666, event=3400, zone=0, gg=0"
);
String
data
=
lib
.
pack
(
1234
,
"861234567890"
,
666666
,
3400
,
0
,
0
);
System
.
out
.
println
(
"data="
+
data
);
}
// test pack2
{
System
.
out
.
println
(
"testing pack2..."
);
System
.
out
.
println
(
"using seq=1234, acct=861234567890, ademco_id=666666, event=3400, zone=0, gg=0, xdata=123456"
);
String
data
=
lib
.
pack2
(
1234
,
"861234567890"
,
666666
,
3400
,
0
,
0
,
"123456"
);
try
{
byte
[]
bytes
=
data
.
getBytes
(
data
);
System
.
out
.
println
(
"data="
+
printable_bytes
(
bytes
));
}
catch
(
UnsupportedEncodingException
e
){
System
.
out
.
println
(
"data="
+
printable_bytes
(
data
));
}
}
// test pack3
{
System
.
out
.
println
(
"testing pack3..."
);
System
.
out
.
println
(
"using seq=1234, acct=861234567890, ademco_id=666666, event=3400, zone=0, gg=0, xdata=EB BA 3F A1 76"
);
// byte[] xdata = new byte[5];
// xdata[0] = '\u00EB';
// xdata[1] = '\u00BA';
// xdata[2] = '\u003F';
// xdata[3] = '\u00A1';
// xdata[4] = '\u0076';
// System.out.println("xdata=");
// System.out.println(printable_bytes(xdata));
// String sx = new String(xdata);
// System.out.println("sx=" + sx);
// String xdata = "\u00EB\u00BA\u003F\u00A1\u0076";
char
[]
xdata
=
new
char
[
5
];
xdata
[
0
]
=
0xEB
;
xdata
[
1
]
=
0xBA
;
xdata
[
2
]
=
0x3F
;
xdata
[
3
]
=
0xA1
;
xdata
[
4
]
=
0x76
;
char
[]
data
=
lib
.
pack3
(
1234
,
"861234567890"
,
666666
,
3400
,
0
,
0
,
xdata
,
5
);
System
.
out
.
println
(
"data="
+
printable_bytes
(
data
));
}
// test pack ack
{
System
.
out
.
println
(
"testing packAck..."
);
System
.
out
.
println
(
"using seq=1234, acct=861234567890, "
);
String
data
=
lib
.
packAck
(
1234
,
"861234567890"
);
System
.
out
.
println
(
"data="
+
data
);
}
int
port
=
12345
;
if
(
args
.
length
>
0
){
port
=
Integer
.
parseInt
(
args
[
0
]);
}
try
(
ServerSocket
serverSocket
=
new
ServerSocket
(
port
))
{
System
.
out
.
println
(
"Server is listening on port "
+
port
);
while
(
true
)
{
Socket
socket
=
serverSocket
.
accept
();
System
.
out
.
println
(
"New client connected"
);
new
SimpleServerThread
(
socket
,
lib
).
start
();
}
}
catch
(
IOException
ex
)
{
System
.
out
.
println
(
"Server exception: "
+
ex
.
getMessage
());
ex
.
printStackTrace
();
}
}
}
\ No newline at end of file
examples/javademo/jni/SimpleServerThread.java
deleted
100644 → 0
View file @
3051b102
package
javademo
.
jni
;
import
java.io.*
;
import
java.net.*
;
import
java.util.regex.*
;
public
class
SimpleServerThread
extends
Thread
{
private
Socket
socket
;
private
AdemcoHbLibrary
lib
;
private
long
lastTimeStatusChange
=
0
;
public
SimpleServerThread
(
Socket
socket
,
AdemcoHbLibrary
lib
)
{
this
.
socket
=
socket
;
this
.
lib
=
lib
;
}
/**
* 16进制表示的字符串转换为字节数组
*
* @param s 16进制表示的字符串
* @return byte[] 字节数组
*/
public
static
byte
[]
hexStringToByteArray
(
String
s
)
{
int
len
=
s
.
length
();
byte
[]
b
=
new
byte
[
len
/
2
];
for
(
int
i
=
0
;
i
<
len
;
i
+=
2
)
{
// 两位一组,表示一个字节,把这样表示的16进制字符串,还原成一个字节
b
[
i
/
2
]
=
(
byte
)
((
Character
.
digit
(
s
.
charAt
(
i
),
16
)
<<
4
)
+
Character
.
digit
(
s
.
charAt
(
i
+
1
),
16
));
}
return
b
;
}
public
static
String
printable_bytes
(
byte
[]
b
){
String
HEX_STRING
=
"0123456789ABCDEF"
;
String
s
=
""
;
for
(
int
i
=
0
;
i
<
b
.
length
;
i
++){
byte
c
=
b
[
i
];
if
(
32
<=
c
&&
c
<=
127
){
s
+=
(
char
)
c
;
}
else
{
s
+=
"\\x"
+
HEX_STRING
.
charAt
(
b
[
i
]
>>>
4
);
s
+=
HEX_STRING
.
charAt
(
b
[
i
]
&
0x0F
);
}
}
return
s
;
}
public
void
run
()
{
try
{
InputStream
input
=
socket
.
getInputStream
();
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
input
));
OutputStream
output
=
socket
.
getOutputStream
();
PrintWriter
writer
=
new
PrintWriter
(
output
,
true
);
String
line
;
// 创建 Pattern 对象
String
pattern1
=
"\"(.+)\"(\\d{4}).+\\#(.+)\\["
;
Pattern
r1
=
Pattern
.
compile
(
pattern1
);
String
pattern2
=
"\\[\\#([\\d\\|a-fA-F]{6})\\|(\\d{4})\\s(\\d{2})\\s(\\d{3})\\]"
;
Pattern
r2
=
Pattern
.
compile
(
pattern2
);
while
(
true
){
line
=
reader
.
readLine
();
if
(
line
==
null
)
continue
;
System
.
out
.
println
(
line
);
// 现在创建 matcher 对象
Matcher
m
=
r1
.
matcher
(
line
);
if
(
m
.
find
())
{
String
id
=
m
.
group
(
1
);
int
seq
=
Integer
.
parseInt
(
m
.
group
(
2
));
String
acct
=
m
.
group
(
3
);
System
.
out
.
println
(
"Found id: "
+
id
);
System
.
out
.
println
(
"Found seq: "
+
seq
);
System
.
out
.
println
(
"Found acct: "
+
acct
);
switch
(
id
){
case
"ACK"
:
break
;
case
"NULL"
:
// reply ack
{
String
ack
=
lib
.
packAck
(
seq
,
acct
);
System
.
out
.
println
(
"replying ack:"
+
ack
);
writer
.
write
(
ack
);
writer
.
flush
();
break
;
}
case
"HENG-BO"
:
case
"ADM-CID"
:
{
// reply ack
String
ack
=
lib
.
packAck
(
seq
,
acct
);
System
.
out
.
println
(
"replying ack:"
+
ack
);
writer
.
write
(
ack
);
writer
.
flush
();
// handle event
m
=
r2
.
matcher
(
line
);
if
(
m
.
find
())
{
int
ademco_id16
=
Integer
.
parseInt
(
m
.
group
(
1
),
16
);
int
ademco_event
=
Integer
.
parseInt
(
m
.
group
(
2
));
int
gg
=
Integer
.
parseInt
(
m
.
group
(
3
));
int
zone
=
Integer
.
parseInt
(
m
.
group
(
4
));
System
.
out
.
println
(
"Found ademco_event: "
+
ademco_event
);
System
.
out
.
println
(
"Found gg: "
+
gg
);
System
.
out
.
println
(
"Found zone: "
+
zone
);
// 主机状态改变间隔超过5秒,则触发一次远程控制命令发送给主机
if
(
ademco_event
==
3400
||
ademco_event
==
1400
){
long
now
=
System
.
currentTimeMillis
();
if
(
now
-
lastTimeStatusChange
>
5000
){
lastTimeStatusChange
=
now
;
if
(
ademco_event
==
3400
){
// 布防则发撤防命令
String
cmd
=
lib
.
pack2
(
seq
+
1
,
acct
,
ademco_id16
,
1400
,
0
,
0
,
"123456"
);
byte
[]
data
=
hexStringToByteArray
(
cmd
);
System
.
out
.
println
(
"sending 1400 command:"
+
printable_bytes
(
data
));
output
.
write
(
data
);
output
.
flush
();
}
else
{
// 撤防就发布防命令
String
cmd
=
lib
.
pack
(
seq
+
1
,
acct
,
ademco_id16
,
3400
,
0
,
0
);
System
.
out
.
println
(
"sending 3400 command:"
+
cmd
);
writer
.
write
(
ack
);
writer
.
flush
();
}
}
}
}
else
{
System
.
out
.
println
(
"r2 NO MATCH"
);
}
break
;
}
}
}
else
{
System
.
out
.
println
(
"r1 NO MATCH"
);
}
}
}
catch
(
IOException
ex
)
{
System
.
out
.
println
(
"Server exception: "
+
ex
.
getMessage
());
ex
.
printStackTrace
();
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment