blob: 19a3916b840ce5599294766b7fd92b921a9d9fcf [file] [log] [blame]
Sergei Lissianoif1c44da2020-08-09 16:11:24 -07001/**
2 *
Sergei Lissianoiaa2933b2020-08-09 16:11:26 -07003 * Copyright (c) 2020 Project CHIP Authors
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/**
19 *
Sergei Lissianoif1c44da2020-08-09 16:11:24 -070020 * Copyright (c) 2020 Silicon Labs
21 *
22 * Licensed under the Apache License, Version 2.0 (the "License");
23 * you may not use this file except in compliance with the License.
24 * You may obtain a copy of the License at
25 *
26 * http://www.apache.org/licenses/LICENSE-2.0
27 *
28 * Unless required by applicable law or agreed to in writing, software
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
33 */
34/***************************************************************************//**
35 * @file
36 * @brief CLI for the Groups Server plugin.
37 *******************************************************************************
38 ******************************************************************************/
39
40#include "app/framework/include/af.h"
41#include "app/util/serial/command-interpreter2.h"
42
43void emAfGroupsServerCliPrint(void);
44void emAfGroupsServerCliClear(void);
45
46#if !defined(EMBER_AF_GENERATE_CLI)
47EmberCommandEntry emberAfPluginGroupsServerCommands[] = {
48 emberCommandEntryAction("print", emAfGroupsServerCliPrint, "", "Print the state of the groups table."),
49 emberCommandEntryAction("clear", emAfGroupsServerCliClear, "", "Clear the groups table on every endpoint."),
50 emberCommandEntryTerminator(),
51};
52#endif // EMBER_AF_GENERATE_CLI
53
54// plugin groups-server print
55void emAfGroupsServerCliPrint(void)
56{
57 EmberStatus status;
58 uint8_t i;
59
60 for (i = 0; i < EMBER_BINDING_TABLE_SIZE; i++) {
61 EmberBindingTableEntry entry;
62 status = emberGetBinding(i, &entry);
63 if ((status == EMBER_SUCCESS) && (entry.type == EMBER_MULTICAST_BINDING)) {
64 emberAfCorePrintln("ep[%x] id[%2x]", entry.local,
65 HIGH_LOW_TO_INT(entry.identifier[1], entry.identifier[0]));
66 }
67 }
68}
69
70// plugin groups-server clear
71void emAfGroupsServerCliClear(void)
72{
73 emberAfCorePrintln("Clearing all groups.");
74 emberAfGroupsClusterClearGroupTableCallback(EMBER_BROADCAST_ENDPOINT);
75}