2 * Copyright (c) 2019, The OpenThread Authors.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. Neither the name of the copyright holder nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
31 * This file includes definitions for OpenThread daemon client.
34 #ifndef OTBR_WEB_WEB_SERVICE_OT_CLIENT_HPP_
35 #define OTBR_WEB_WEB_SERVICE_OT_CLIENT_HPP_
37 #include "openthread-br/config.h"
44 #define OT_SCANNED_NET_BUFFER_SIZE 250
45 #define OT_SET_MAX_DATA_SIZE 250
46 #define OT_NETWORK_NAME_MAX_SIZE 17
47 #define OT_HARDWARE_ADDRESS_SIZE 8
48 #define OT_PREFIX_SIZE 8
49 #define OT_ROUTER_ROLE 2
51 struct WpanNetworkInfo
53 char mNetworkName[OT_NETWORK_NAME_MAX_SIZE];
59 uint8_t mHardwareAddress[OT_HARDWARE_ADDRESS_SIZE];
60 uint8_t mPrefix[OT_PREFIX_SIZE];
64 * This class implements functionality of OpenThread client.
67 class OpenThreadClient
71 * This constructor creates an OpenThread client.
74 OpenThreadClient(void);
76 * This destructor destories an OpenThread client.
79 ~OpenThreadClient(void);
82 * This method connects to OpenThread daemon.
84 * @retval true Successfully connected to the daemon.
85 * @retval false Failed to connected to the daemon.
91 * This method executes OpenThread CLI.
93 * @param[in] aFormat C style format string.
94 * @param[in] ... C style format arguments.
96 * @returns A pointer to the output if succeeded, otherwise nullptr.
99 char *Execute(const char *aFormat, ...);
102 * This method scans Thread network.
104 * @param[out] aNetworks A pointer to the buffer to store network information.
105 * @param[in] aLength Number of entries in @p aNetworks.
107 * @returns Number of entries found. 0 if none found.
110 int Scan(WpanNetworkInfo *aNetworks, int aLength);
113 * This method performs factory reset.
116 bool FactoryReset(void);
119 void Disconnect(void);
123 kBufferSize = 1024, ///< Maximum command line input and output buffer.
124 kDefaultTimeout = 800, ///< Default timeout(ms) waiting for a command finish.
127 char mBuffer[kBufferSize];
128 int mTimeout; /// Timeout in milliseconds
135 #endif // OTBR_WEB_WEB_SERVICE_OT_CLIENT_HPP_