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
8db89644
Commit
8db89644
authored
Aug 10, 2020
by
尹佳钦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add kk_test.c
parent
cd1c0c55
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
397 additions
and
223 deletions
+397
-223
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
+190
-0
platform/zigbee/protocol/zigbee/app/framework/plugin-host/gateway-relay-mqtt/gateway-relay-mqtt.c
...ework/plugin-host/gateway-relay-mqtt/gateway-relay-mqtt.c
+12
-27
platform/zigbee/protocol/zigbee/app/framework/plugin/network-steering/network-steering-cli.c
.../framework/plugin/network-steering/network-steering-cli.c
+4
-4
platform/zigbee/protocol/zigbee/app/framework/plugin/network-steering/network-steering-soc.c
.../framework/plugin/network-steering/network-steering-soc.c
+4
-4
platform/zigbee/protocol/zigbee/app/framework/plugin/network-steering/network-steering.c
.../app/framework/plugin/network-steering/network-steering.c
+187
-188
No files found.
platform/zigbee/app/builder/Z3GatewayHost/kk_test.c
0 → 100644
View file @
8db89644
#include "kk_test.h"
static
void
kk_rpc_send_message
(
cJSON
*
data
,
char
*
method
,
EmberEUI64
mac
)
{
static
uint16_t
msgid
;
cJSON
*
item
=
rpc_cJSON_CreateObject
();
char
msgIdString
[
10
];
sprintf
(
msgIdString
,
"%d"
,
++
msgid
);
rpc_cJSON_AddStringToObject
(
item
,
"msgId"
,
msgIdString
);
rpc_cJSON_AddStringToObject
(
item
,
"version"
,
KK_IPC_VERSION
);
if
(
mac
!=
NULL
){
rpc_cJSON_AddMACToObject
(
item
,
mac
);
}
rpc_cJSON_AddStringToObject
(
item
,
"method"
,
method
);
rpc_cJSON_AddItemToObject
(
item
,
"params"
,
data
);
char
*
p
=
rpc_cJSON_Print
(
item
);
emberAfAppPrintln
(
"send json:
\n
%s
\n
"
,
p
);
free
(
p
);
jrpc_send_msg
(
item
);
}
void
kk_rpc_report_devices
(
cJSON
*
data
,
EmberEUI64
mac
)
{
kk_rpc_send_message
(
data
,
KK_REPORT_DEVICE_JOINED_METHOD
,
mac
);
}
void
kk_rpc_report_status
(
cJSON
*
data
,
EmberEUI64
mac
)
{
kk_rpc_send_message
(
data
,
KK_REPORT_ATTRIBUTE_METHOD
,
mac
);
}
typedef
struct
{
EmberEUI64
mac
;
uint8_t
AppVersion
;
uint8_t
deviceType
;
uint8_t
deviceCode
;
uint8_t
productType
;
uint8_t
productCode
;
}
kk_report_device_s
;
void
kk_rpc_reportDevices
(
kk_report_device_s
device
)
{
cJSON
*
devicesJson
;
devicesJson
=
rpc_cJSON_CreateObject
();
rpc_cJSON_AddAppVersionToObject
(
devicesJson
,
device
.
AppVersion
);
rpc_cJSON_AddStringToObject
(
devicesJson
,
"deviceType"
,
"1"
);
rpc_cJSON_AddStringToObject
(
devicesJson
,
"deviceCode"
,
"2"
);
rpc_cJSON_AddStringToObject
(
devicesJson
,
"productType"
,
"3"
);
rpc_cJSON_AddStringToObject
(
devicesJson
,
"productCode"
,
"4"
);
kk_rpc_report_devices
(
devicesJson
,
device
.
mac
);
}
bool
kk_rpc_report_LightStatus
(
EmberEUI64
mac
,
bool
LightStatus
)
{
cJSON
*
root
;
root
=
rpc_cJSON_CreateObject
();
if
(
LightStatus
==
true
){
rpc_cJSON_AddStringToObject
(
root
,
"LightStatus"
,
"1"
);
}
else
{
rpc_cJSON_AddStringToObject
(
root
,
"LightStatus"
,
"0"
);
}
kk_rpc_report_status
(
root
,
mac
);
}
cJSON
*
rpc_Control
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
rpc_nwk_info_s
info
;
EmberStatus
status
;
if
(
params
==
NULL
){
emberAfCorePrintln
(
"
\r\n
params == NULL
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
{
cJSON
*
mac_item
=
rpc_cJSON_GetObjectItem
(
params
,
"mac"
);
cJSON
*
LightStatus_item
=
rpc_cJSON_GetObjectItem
(
params
,
"LightStatus"
);
uint8_t
LightStatus
=
rpc_get_u8
(
LightStatus_item
->
valuestring
);
uint8_t
mac
[
EUI64_SIZE
];
bool
flag
=
rpc_get_mac
(
mac_item
->
valuestring
,
mac
);
emberAfCorePrintBuffer
(
mac
,
EUI64_SIZE
,
true
);
for
(
int
i
=
0
;
i
<
EUI64_SIZE
;
i
++
){
emberAfCorePrintln
(
"i=%d,val=%02x"
,
i
,
mac
[
i
]);
}
EmberNodeId
node
=
emberAfDeviceTableGetNodeIdFromEui64
(
mac
);
if
(
node
==
0xffff
){
emberAfCorePrintln
(
"
\r\n
not find device!
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
emberAfCorePrintln
(
"
\r\n
node=0x%02X,LightStatus=%d
\r\n
"
,
node
,
LightStatus
);
if
(
flag
){
EmberStatus
status
;
if
(
LightStatus
==
1
){
status
=
zclOnOff_On
(
node
,
1
);
emberAfCorePrintln
(
"
\r\n
zclOnOff_On
\r\n
"
);
}
else
if
(
LightStatus
==
0
){
status
=
zclOnOff_Off
(
node
,
1
);
emberAfCorePrintln
(
"
\r\n
zclOnOff_Off
\r\n
"
);
}
else
{
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
}
else
{
emberAfCorePrintln
(
"
\r\n
22222
\r\n
"
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
return
rpc_cJSON_CreateNumber
(
status
);
}
error_return:
return
rpc_cJSON_CreateNull
();
}
cJSON
*
rpc_nwkPermitJoin
(
jrpc_context
*
ctx
,
cJSON
*
params
,
cJSON
*
id
)
{
cJSON
*
OpenOrClose
;
EmberStatus
status
;
uint8_t
isEnable
;
if
(
params
==
NULL
){
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
else
if
(
params
->
type
==
cJSON_Object
){
OpenOrClose
=
rpc_cJSON_GetObjectItem
(
params
,
"NetChannelState"
);
}
else
{
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
isEnable
=
rpc_get_u8
(
OpenOrClose
->
valuestring
);
if
(
isEnable
==
0
){
status
=
nwkPermitJoinCMD
(
FALSE
);
emberAfCorePrintln
(
"Disable Permit join
\r\n
"
);
}
else
if
(
isEnable
==
1
){
status
=
nwkPermitJoinCMD
(
TRUE
);
emberAfCorePrintln
(
"Enable Permit join 180s
\r\n
"
);
}
else
{
emberAfCorePrintln
(
"item type error[%d]
\r\n
"
,
OpenOrClose
->
type
);
set_json_error_type
(
ctx
,
JRPC_INVALID_PARAMS
,
MSG_INVALID_PARAMS
);
goto
error_return
;
}
return
rpc_cJSON_CreateNumber
(
status
);
error_return:
return
rpc_cJSON_CreateNull
();
}
void
emberAfPluginDeviceTableNewDeviceCallback
(
EmberEUI64
nodeEui64
)
{
uint16_t
deviceTableIndex
=
emberAfDeviceTableGetFirstIndexFromEui64
(
nodeEui64
);
if
(
deviceTableIndex
==
0xffff
){
kk_print_info
(
"not find item!"
);
return
;
}
//EmberAfPluginDeviceTableEntry *deviceTable = emberAfDeviceTablePointer();
//cJSON* nodeJson = rpc_reportDeviceState("joined",deviceTable[deviceTableIndex].eui64);
//rpc_printfJSON("joined",nodeJson);
//rpc_send_message(nodeJson,"device joined");
//rpc_add_device(deviceTable[deviceTableIndex].nodeId);
kk_report_device_s
device
;
//device.mac = nodeEui64;
device
.
AppVersion
=
0x10
;
memcpy
(
device
.
mac
,
nodeEui64
,
EUI64_SIZE
);
kk_rpc_reportDevices
(
device
);
}
platform/zigbee/protocol/zigbee/app/framework/plugin-host/gateway-relay-mqtt/gateway-relay-mqtt.c
View file @
8db89644
...
@@ -505,6 +505,7 @@ static void publishMqttDeviceStateChange(EmberEUI64 eui64,
...
@@ -505,6 +505,7 @@ static void publishMqttDeviceStateChange(EmberEUI64 eui64,
cJSON_AddStringToObject
(
stateChangeJson
,
"eui64"
,
euiString
);
cJSON_AddStringToObject
(
stateChangeJson
,
"eui64"
,
euiString
);
cJSON_AddIntegerToObject
(
stateChangeJson
,
"deviceState"
,
state
);
cJSON_AddIntegerToObject
(
stateChangeJson
,
"deviceState"
,
state
);
publishMqttTopic
(
"devicestatechange"
,
stateChangeJson
);
publishMqttTopic
(
"devicestatechange"
,
stateChangeJson
);
}
}
static
void
publishMqttDeviceJoined
(
EmberEUI64
eui64
)
static
void
publishMqttDeviceJoined
(
EmberEUI64
eui64
)
...
@@ -1260,28 +1261,10 @@ void emberAfPluginOtaServerUpdateStartedCallback(uint16_t manufacturerId,
...
@@ -1260,28 +1261,10 @@ void emberAfPluginOtaServerUpdateStartedCallback(uint16_t manufacturerId,
&
firmwareVersion
);
&
firmwareVersion
);
}
}
void
emberAfPluginDeviceTableNewDeviceCallback
(
EmberEUI64
nodeEui64
)
{
publishMqttDeviceJoined
(
nodeEui64
);
}
void
emberAfPluginDeviceTableDeviceLeftCallback
(
EmberEUI64
nodeEui64
)
{
publishMqttDeviceLeft
(
nodeEui64
);
}
void
emberAfPluginDeviceTableRejoinDeviceCallback
(
EmberEUI64
nodeEui64
)
{
publishMqttDeviceJoined
(
nodeEui64
);
}
void
emberAfPluginDeviceTableStateChangeCallback
(
EmberNodeId
nodeId
,
uint8_t
state
)
{
EmberEUI64
nodeEui64
;
emberAfDeviceTableGetEui64FromNodeId
(
nodeId
,
nodeEui64
);
publishMqttDeviceStateChange
(
nodeEui64
,
state
);
}
void
emberAfPluginDeviceTableClearedCallback
(
void
)
void
emberAfPluginDeviceTableClearedCallback
(
void
)
{
{
...
@@ -1702,6 +1685,8 @@ void emberAfPluginGatewayRelayMqttStateUpdateEventHandler(void)
...
@@ -1702,6 +1685,8 @@ void emberAfPluginGatewayRelayMqttStateUpdateEventHandler(void)
publishMqttSettings
();
publishMqttSettings
();
publishMqttRelays
();
publishMqttRelays
();
publishMqttDevices
();
publishMqttDevices
();
extern
void
rpc_reportDevices
(
void
);
rpc_reportDevices
();
}
}
void
emberAfPluginGatewayRelayMqttProcessCommandEventHandler
(
void
)
void
emberAfPluginGatewayRelayMqttProcessCommandEventHandler
(
void
)
...
...
platform/zigbee/protocol/zigbee/app/framework/plugin/network-steering/network-steering-cli.c
View file @
8db89644
platform/zigbee/protocol/zigbee/app/framework/plugin/network-steering/network-steering-soc.c
View file @
8db89644
platform/zigbee/protocol/zigbee/app/framework/plugin/network-steering/network-steering.c
View file @
8db89644
...
@@ -242,7 +242,7 @@ void gotoNextChannel(void)
...
@@ -242,7 +242,7 @@ void gotoNextChannel(void)
emAfPluginNetworkSteeringCurrentChannel
=
getNextChannel
();
emAfPluginNetworkSteeringCurrentChannel
=
getNextChannel
();
if
(
emAfPluginNetworkSteeringCurrentChannel
==
0
)
{
if
(
emAfPluginNetworkSteeringCurrentChannel
==
0
)
{
debug
Println
(
"No more channels"
);
emberAfCore
Println
(
"No more channels"
);
tryNextMethod
();
tryNextMethod
();
return
;
return
;
}
}
...
@@ -365,7 +365,7 @@ static void networkFoundCallback(EmberZigbeeNetwork *networkFound,
...
@@ -365,7 +365,7 @@ static void networkFoundCallback(EmberZigbeeNetwork *networkFound,
return
;
return
;
}
}
debugPrint
(
"%p nwk found ch: %d, panID 0x%2X, xpan: "
,
emberAfCorePrintln
(
"%p nwk found ch: %d, panID 0x%2X, xpan: "
,
PLUGIN_NAME
,
PLUGIN_NAME
,
networkFound
->
channel
,
networkFound
->
channel
,
networkFound
->
panId
);
networkFound
->
panId
);
...
@@ -376,9 +376,9 @@ static void networkFoundCallback(EmberZigbeeNetwork *networkFound,
...
@@ -376,9 +376,9 @@ static void networkFoundCallback(EmberZigbeeNetwork *networkFound,
if
(
0
!=
MEMCOMPARE
(
networkFound
->
extendedPanId
,
if
(
0
!=
MEMCOMPARE
(
networkFound
->
extendedPanId
,
gExtendedPanIdToFilterOn
,
gExtendedPanIdToFilterOn
,
COUNTOF
(
gExtendedPanIdToFilterOn
)))
{
COUNTOF
(
gExtendedPanIdToFilterOn
)))
{
debug
Print
(
". Skipping since we are looking for xpan: "
);
emberAfCore
Print
(
". Skipping since we are looking for xpan: "
);
debugExec
(
emberAfPrintBigEndianEui64
(
gExtendedPanIdToFilterOn
));
debugExec
(
emberAfPrintBigEndianEui64
(
gExtendedPanIdToFilterOn
));
debugPrintln
(
""
);
emberAfCorePrint
(
""
);
return
;
return
;
}
}
}
}
...
@@ -437,7 +437,7 @@ static uint8_t getNextChannel(void)
...
@@ -437,7 +437,7 @@ static uint8_t getNextChannel(void)
if
(
emAfPluginNetworkSteeringCurrentChannel
==
0
)
{
if
(
emAfPluginNetworkSteeringCurrentChannel
==
0
)
{
emAfPluginNetworkSteeringCurrentChannel
=
(
halCommonGetRandom
()
&
0x0F
)
emAfPluginNetworkSteeringCurrentChannel
=
(
halCommonGetRandom
()
&
0x0F
)
+
EMBER_MIN_802_15_4_CHANNEL_NUMBER
;
+
EMBER_MIN_802_15_4_CHANNEL_NUMBER
;
debug
Println
(
"Randomly choosing a starting channel %d."
,
emAfPluginNetworkSteeringCurrentChannel
);
emberAfCore
Println
(
"Randomly choosing a starting channel %d."
,
emAfPluginNetworkSteeringCurrentChannel
);
}
else
{
}
else
{
emAfPluginNetworkSteeringCurrentChannel
++
;
emAfPluginNetworkSteeringCurrentChannel
++
;
}
}
...
@@ -467,7 +467,6 @@ static EmberStatus stateMachineRun(void)
...
@@ -467,7 +467,6 @@ static EmberStatus stateMachineRun(void)
status
);
status
);
return
tryNextMethod
();
return
tryNextMethod
();
}
}
switch
(
emAfPluginNetworkSteeringState
)
{
switch
(
emAfPluginNetworkSteeringState
)
{
case
EMBER_AF_PLUGIN_NETWORK_STEERING_STATE_SCAN_PRIMARY_CONFIGURED
:
case
EMBER_AF_PLUGIN_NETWORK_STEERING_STATE_SCAN_PRIMARY_CONFIGURED
:
case
EMBER_AF_PLUGIN_NETWORK_STEERING_STATE_SCAN_PRIMARY_INSTALL_CODE
:
case
EMBER_AF_PLUGIN_NETWORK_STEERING_STATE_SCAN_PRIMARY_INSTALL_CODE
:
...
@@ -480,7 +479,7 @@ static EmberStatus stateMachineRun(void)
...
@@ -480,7 +479,7 @@ static EmberStatus stateMachineRun(void)
break
;
break
;
}
}
debug
Println
(
"Channel Mask: 0x%4X"
,
currentChannelMask
);
emberAfCore
Println
(
"Channel Mask: 0x%4X"
,
currentChannelMask
);
gotoNextChannel
();
gotoNextChannel
();
return
status
;
return
status
;
}
}
...
@@ -537,7 +536,7 @@ EmberStatus emberAfPluginNetworkSteeringStart(void)
...
@@ -537,7 +536,7 @@ EmberStatus emberAfPluginNetworkSteeringStart(void)
{
{
EmberStatus
status
=
EMBER_INVALID_CALL
;
EmberStatus
status
=
EMBER_INVALID_CALL
;
if
(
emAfProIsCurrentNetwork
()
if
(
emAfProIsCurrentNetwork
()
&&
(
emAfPluginNetworkSteeringState
&&
(
emAfPluginNetworkSteeringState
==
EMBER_AF_PLUGIN_NETWORK_STEERING_STATE_NONE
))
{
==
EMBER_AF_PLUGIN_NETWORK_STEERING_STATE_NONE
))
{
if
(
emberAfNetworkState
()
==
EMBER_NO_NETWORK
)
{
if
(
emberAfNetworkState
()
==
EMBER_NO_NETWORK
)
{
...
...
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