Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
k-sdk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈伟灿
k-sdk
Commits
44036e7a
Commit
44036e7a
authored
Sep 01, 2020
by
chen.weican
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://172.17.3.10:17001/chenweican/k-sdk
parents
c7a249a9
a0816f3c
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
2864 additions
and
2734 deletions
+2864
-2734
common/api/tcp_channel.c
common/api/tcp_channel.c
+707
-685
common/hal/iot.mk
common/hal/iot.mk
+1
-1
midware/midware/dm/kk_property_db.c
midware/midware/dm/kk_property_db.c
+89
-0
midware/midware/dm/kk_property_db.h
midware/midware/dm/kk_property_db.h
+14
-8
midware/midware/midware.c
midware/midware/midware.c
+698
-687
platform/zigbee/app/builder/Z3GatewayHost/Makefile
platform/zigbee/app/builder/Z3GatewayHost/Makefile
+391
-391
platform/zigbee/app/builder/Z3GatewayHost/libapi_com.so
platform/zigbee/app/builder/Z3GatewayHost/libapi_com.so
+0
-0
platform/zigbee/app/builder/Z3GatewayHost/libkk_hal.so
platform/zigbee/app/builder/Z3GatewayHost/libkk_hal.so
+0
-0
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
...p/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
+964
-962
No files found.
common/api/tcp_channel.c
View file @
44036e7a
...
@@ -196,6 +196,26 @@ int kk_is_tcp_channel(char devCode[DEVICE_CODE_LEN]){
...
@@ -196,6 +196,26 @@ int kk_is_tcp_channel(char devCode[DEVICE_CODE_LEN]){
return
-
1
;
return
-
1
;
}
}
int
kk_set_tcp_channel_by_idx
(
int
idx
,
char
devCode
[
DEVICE_CODE_LEN
],
char
ip
[
MAX_IP_LEN
]){
int
i
=
0
;
if
(
idx
>=
MAX_LISTEN_NUM
){
printf
(
"kk_set_tcp_channel_by_idx idx[] need less than %d
\n
"
,
idx
,
MAX_LISTEN_NUM
);
return
-
1
;
}
if
(
devCode
==
NULL
||
strlen
(
devCode
)
==
0
||
ip
==
NULL
||
strlen
(
ip
)
==
0
){
return
-
1
;
}
//printf("[%s] devCode=%s \n", __FUNCTION__,devCode);
memcpy
(
g_tcp_ctrl
[
idx
].
deviceCode
,
devCode
,
strlen
(
devCode
));
memcpy
(
g_tcp_ctrl
[
idx
].
ip
,
ip
,
strlen
(
ip
));
return
0
;
}
int
kk_set_tcp_channel
(
char
devCode
[
DEVICE_CODE_LEN
],
char
ip
[
MAX_IP_LEN
]){
int
kk_set_tcp_channel
(
char
devCode
[
DEVICE_CODE_LEN
],
char
ip
[
MAX_IP_LEN
]){
int
i
=
0
;
int
i
=
0
;
int
isEmptyIdx
=
-
1
;
int
isEmptyIdx
=
-
1
;
...
@@ -210,7 +230,7 @@ int kk_set_tcp_channel(char devCode[DEVICE_CODE_LEN], char ip[MAX_IP_LEN]){
...
@@ -210,7 +230,7 @@ int kk_set_tcp_channel(char devCode[DEVICE_CODE_LEN], char ip[MAX_IP_LEN]){
if
(
strcmp
(
devCode
,
g_tcp_ctrl
[
i
].
deviceCode
)
==
0
){
if
(
strcmp
(
devCode
,
g_tcp_ctrl
[
i
].
deviceCode
)
==
0
){
strncpy
(
g_tcp_ctrl
[
i
].
ip
,
ip
,
strlen
(
ip
));
strncpy
(
g_tcp_ctrl
[
i
].
ip
,
ip
,
strlen
(
ip
));
printf
(
"find and replace it [%d][%s][%s]
\n
"
,
i
,
g_tcp_ctrl
[
i
].
ip
,
devCode
);
printf
(
"find and replace it [%d][%s][%s]
\n
"
,
i
,
g_tcp_ctrl
[
i
].
ip
,
devCode
);
kk_gw_list_save
();
//kk_gw_list_save();
break
;
break
;
}
}
...
@@ -228,7 +248,7 @@ int kk_set_tcp_channel(char devCode[DEVICE_CODE_LEN], char ip[MAX_IP_LEN]){
...
@@ -228,7 +248,7 @@ int kk_set_tcp_channel(char devCode[DEVICE_CODE_LEN], char ip[MAX_IP_LEN]){
strncpy
(
g_tcp_ctrl
[
isEmptyIdx
].
ip
,
ip
,
strlen
(
ip
));
strncpy
(
g_tcp_ctrl
[
isEmptyIdx
].
ip
,
ip
,
strlen
(
ip
));
strncpy
(
g_tcp_ctrl
[
isEmptyIdx
].
deviceCode
,
devCode
,
strlen
(
devCode
));
strncpy
(
g_tcp_ctrl
[
isEmptyIdx
].
deviceCode
,
devCode
,
strlen
(
devCode
));
printf
(
"idx deviceCode ip[%d][%s][%s]"
,
isEmptyIdx
,
g_tcp_ctrl
[
isEmptyIdx
].
deviceCode
,
g_tcp_ctrl
[
isEmptyIdx
].
ip
);
printf
(
"idx deviceCode ip[%d][%s][%s]"
,
isEmptyIdx
,
g_tcp_ctrl
[
isEmptyIdx
].
deviceCode
,
g_tcp_ctrl
[
isEmptyIdx
].
ip
);
kk_gw_list_save
();
//kk_gw_list_save();
return
0
;
return
0
;
}
}
...
@@ -433,9 +453,11 @@ int kk_TCP_channel_init(ipc_cb cb)
...
@@ -433,9 +453,11 @@ int kk_TCP_channel_init(ipc_cb cb)
return
-
1
;
return
-
1
;
}
}
g_init
=
1
;
g_init
=
1
;
memset
(
g_tcp_ctrl
,
0
,
sizeof
(
kk_tcp_ctrl_t
)
*
MAX_LISTEN_NUM
);
//memset(g_tcp_ctrl, 0, sizeof(kk_tcp_ctrl_t)*MAX_LISTEN_NUM);
kk_gw_list_load
();
//kk_gw_list_load();
for
(
i
=
0
;
i
<
MAX_LISTEN_NUM
;
i
++
){
g_tcp_ctrl
[
i
].
sock
=
-
1
;
}
if
(
g_pTh
==
NULL
&&
0
!=
pthread_create
(
&
g_pTh
,
NULL
,
loop_tcp_thread
,
NULL
))
{
if
(
g_pTh
==
NULL
&&
0
!=
pthread_create
(
&
g_pTh
,
NULL
,
loop_tcp_thread
,
NULL
))
{
printf
(
"create pthread failed
\r\n
"
);
printf
(
"create pthread failed
\r\n
"
);
...
...
common/hal/iot.mk
View file @
44036e7a
LIBA_TARGET
:=
libkk_hal.a
LIBSO_TARGET
:=
libkk_hal.so
\ No newline at end of file
\ No newline at end of file
midware/midware/dm/kk_property_db.c
View file @
44036e7a
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include "sqlite3.h"
#include "sqlite3.h"
#include "kk_log.h"
#include "kk_log.h"
#include "kk_dm_mng.h"
#include "kk_dm_mng.h"
#include "kk_property_db.h"
#define KK_PROPERTIES_DB_FILE "kk_properties.db"
#define KK_PROPERTIES_DB_FILE "kk_properties.db"
...
@@ -185,6 +186,93 @@ int kk_property_db_update_value(const char *deviceCode,const char *identifier,co
...
@@ -185,6 +186,93 @@ int kk_property_db_update_value(const char *deviceCode,const char *identifier,co
return
SUCCESS_RETURN
;
return
SUCCESS_RETURN
;
}
}
int
kk_property_db_get_value
(
const
char
*
deviceCode
,
const
char
*
identifier
,
void
*
value
)
{
char
*
sqlCmd
=
NULL
;
int
rc
=
0
;
char
*
zErrMsg
=
0
;
sqlite3_stmt
*
stmt
;
char
*
valueStr
=
NULL
;
int
valueType
=
0
;
kk_property_db_ctx_t
*
ctx
=
_kk_property_db_get_ctx
();
_kk_property_db_lock
();
sqlCmd
=
sqlite3_mprintf
(
"select * from PropertiesInfo WHERE deviceCode= '%s' and identifier = '%s'"
,
deviceCode
,
identifier
);
DEBUG_PRINT
(
"kk_property_db_get_value sqlCmd:%s
\n
"
,
sqlCmd
);
sqlite3_prepare_v2
(
ctx
->
pDb
,
sqlCmd
,
strlen
(
sqlCmd
),
&
stmt
,
NULL
);
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
){
valueStr
=
sqlite3_column_text
(
stmt
,
DB_VALUE
);
valueType
=
sqlite3_column_int
(
stmt
,
DB_VALUETYPE
);
if
(
valueType
==
KK_TSL_DATA_TYPE_INT
||
valueType
==
KK_TSL_DATA_TYPE_ENUM
||
valueType
==
KK_TSL_DATA_TYPE_BOOL
){
int
value_int
=
atoi
(
valueStr
);
*
(
int
*
)
value
=
value_int
;
}
else
if
(
valueType
==
KK_TSL_DATA_TYPE_FLOAT
){
float
value_float
=
atoi
(
valueStr
);
*
(
float
*
)
value
=
value_float
;
}
else
if
(
valueType
==
KK_TSL_DATA_TYPE_DOUBLE
){
double
value_double
=
atoi
(
valueStr
);
*
(
double
*
)
value
=
value_double
;
}
else
{
memcpy
(
value
,
valueStr
,
strlen
(
valueStr
));
}
}
sqlite3_free
(
sqlCmd
);
_kk_property_db_unlock
();
sqlite3_finalize
(
stmt
);
return
SUCCESS_RETURN
;
}
int
kk_property_db_get_rawdata
(
const
char
*
identifier
,
const
int
dev_type
,
kk_prop_raw_struct_t
*
raw
,
int
count
)
{
char
*
sqlCmd
=
NULL
;
int
rc
=
0
;
char
*
zErrMsg
=
0
;
sqlite3_stmt
*
stmt
;
char
*
valueStr
=
NULL
;
char
*
devcode
=
NULL
;
int
valueType
=
0
;
int
idx
=
0
;
kk_prop_raw_struct_t
*
curData
=
NULL
;
kk_property_db_ctx_t
*
ctx
=
_kk_property_db_get_ctx
();
_kk_property_db_lock
();
sqlCmd
=
sqlite3_mprintf
(
"select * from PropertiesInfo WHERE devType= '%d' and identifier = '%s'"
,
dev_type
,
identifier
);
DEBUG_PRINT
(
"kk_property_db_get_gw_value sqlCmd:%s
\n
"
,
sqlCmd
);
sqlite3_prepare_v2
(
ctx
->
pDb
,
sqlCmd
,
strlen
(
sqlCmd
),
&
stmt
,
NULL
);
curData
=
raw
;
while
(
sqlite3_step
(
stmt
)
==
SQLITE_ROW
&&
idx
<
count
){
devcode
=
sqlite3_column_text
(
stmt
,
DB_DEVICECODE
);
valueStr
=
sqlite3_column_text
(
stmt
,
DB_VALUE
);
valueType
=
sqlite3_column_int
(
stmt
,
DB_VALUETYPE
);
memcpy
(
curData
->
deviceCode
,
devcode
,
strlen
(
devcode
));
memcpy
(
curData
->
raw
,
valueStr
,
strlen
(
valueStr
));
curData
->
type
=
valueType
;
curData
++
;
idx
++
;
}
sqlite3_free
(
sqlCmd
);
_kk_property_db_unlock
();
sqlite3_finalize
(
stmt
);
return
SUCCESS_RETURN
;
}
int
kk_property_db_update
(
const
char
*
deviceCode
)
int
kk_property_db_update
(
const
char
*
deviceCode
)
{
{
int
res
=
0
;
int
res
=
0
;
...
@@ -285,6 +373,7 @@ int kk_property_sync_values(const char *deviceCode)
...
@@ -285,6 +373,7 @@ int kk_property_sync_values(const char *deviceCode)
}
}
sqlite3_free
(
sqlCmd
);
_kk_property_db_unlock
();
_kk_property_db_unlock
();
sqlite3_finalize
(
stmt
);
sqlite3_finalize
(
stmt
);
...
...
midware/midware/dm/kk_property_db.h
View file @
44036e7a
...
@@ -2,6 +2,12 @@
...
@@ -2,6 +2,12 @@
#define _KK_PROPERTY_DB_H_
#define _KK_PROPERTY_DB_H_
#include "kk_tsl_common.h"
#include "kk_tsl_common.h"
typedef
struct
{
int
type
;
char
deviceCode
[
DEVICE_CODE_MAXLEN
];
char
raw
[
60
];
}
kk_prop_raw_struct_t
;
int
kk_property_db_init
(
void
);
int
kk_property_db_init
(
void
);
#endif
#endif
...
...
midware/midware/midware.c
View file @
44036e7a
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include "kk_dm_mng.h"
#include "kk_dm_mng.h"
#include "kk_log.h"
#include "kk_log.h"
#include "kk_dm_queue.h"
#include "kk_dm_queue.h"
#include "kk_property_db.h"
char
*
g_filerToPlatTable
[]
=
char
*
g_filerToPlatTable
[]
=
...
@@ -323,6 +324,7 @@ void *ota_dispatch_yield(void *args)
...
@@ -323,6 +324,7 @@ void *ota_dispatch_yield(void *args)
#define UDP_LAN_PORT 25556
#define UDP_LAN_PORT 25556
#define UDP_LAN_PORT_HOST 25555
#define UDP_LAN_PORT_HOST 25555
#define test_
#define test_
void
*
udp_dispatch_yield
(
void
*
args
){
void
*
udp_dispatch_yield
(
void
*
args
){
...
@@ -381,7 +383,16 @@ void *udp_dispatch_yield(void *args){
...
@@ -381,7 +383,16 @@ void *udp_dispatch_yield(void *args){
char
mac
[
32
]
=
{
0
};
char
mac
[
32
]
=
{
0
};
char
device_code
[
DEVICE_CODE_LEN
]
=
{
0
};
char
device_code
[
DEVICE_CODE_LEN
]
=
{
0
};
int
devId
=
0
;
int
devId
=
0
;
kk_prop_raw_struct_t
ipList
[
10
]
=
{
0
};
int
idx
=
0
;
kk_property_db_get_rawdata
(
"IPAddress"
,
4
,
ipList
,
sizeof
(
ipList
));
for
(;
idx
<
10
;
idx
++
){
DEBUG_PRINT
(
"ipList[%d][%s][%s]
\n
"
,
idx
,
ipList
[
idx
].
deviceCode
,
ipList
[
idx
].
raw
);
if
(
strlen
(
ipList
[
idx
].
deviceCode
)
>
0
&&
strlen
(
ipList
[
idx
].
raw
)
>
0
){
kk_set_tcp_channel_by_idx
(
idx
,
ipList
[
idx
].
deviceCode
,
ipList
[
idx
].
raw
);
}
}
kk_TCP_channel_init
(
gw2mid_cb
);
kk_TCP_channel_init
(
gw2mid_cb
);
while
(
1
)
while
(
1
)
...
...
platform/zigbee/app/builder/Z3GatewayHost/Makefile
View file @
44036e7a
...
@@ -356,7 +356,7 @@ $(TARGET_FILE): $(APPLICATION_OBJECTS) $(LIBRARIES)
...
@@ -356,7 +356,7 @@ $(TARGET_FILE): $(APPLICATION_OBJECTS) $(LIBRARIES)
@
echo
-e
'\n$@ build success'
@
echo
-e
'\n$@ build success'
else
else
$(TARGET_FILE)
:
$(APPLICATION_OBJECTS) $(LIBRARIES)
$(TARGET_FILE)
:
$(APPLICATION_OBJECTS) $(LIBRARIES)
$(LD)
$^
$(LINKER_FLAGS)
-lm
-L
.
-lapi_com
-lnanomsg
-l
anl
-pthread
-lev
-ltinfo
-o
$(TARGET_FILE)
$(LD)
$^
$(LINKER_FLAGS)
-lm
-L
.
-lapi_com
-lnanomsg
-l
kk_hal
-lanl
-pthread
-lev
-ltinfo
-o
$(TARGET_FILE)
@
echo
-e
'\n$@ build success'
@
echo
-e
'\n$@ build success'
endif
endif
...
...
platform/zigbee/app/builder/Z3GatewayHost/libapi_com.so
View file @
44036e7a
No preview for this file type
platform/zigbee/app/builder/Z3GatewayHost/libkk_hal.so
0 → 100644
View file @
44036e7a
File added
platform/zigbee/app/builder/Z3GatewayHost/rpc_api/src/rpc_interface_parse.c
View file @
44036e7a
...
@@ -534,7 +534,9 @@ void ipcHandle(void)
...
@@ -534,7 +534,9 @@ void ipcHandle(void)
cnt
++
;
cnt
++
;
if
(
cnt
==
2
){
if
(
cnt
==
2
){
sleep
(
1
);
sleep
(
1
);
char
*
postmsg
=
_msg_event_property_post
(
ip
,
port
);
char
gwIp
[
17
]
=
{
0
};
HAL_Get_IP
(
gwIp
,
NULL
);
char
*
postmsg
=
_msg_event_property_post
(
gwIp
,
port
);
if
(
outbuf
==
NULL
){
if
(
outbuf
==
NULL
){
printf
(
"[%s] property_post msg failed
\n
"
,
__FUNCTION__
);
printf
(
"[%s] property_post msg failed
\n
"
,
__FUNCTION__
);
...
...
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