Mistake on this page?
Report an issue in GitHub or email us
WisunInterface.h
1 /*
2  * Copyright (c) 2018-2019 ARM Limited. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  * Licensed under the Apache License, Version 2.0 (the License); you may
5  * not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef WISUNINTERFACE_H
18 #define WISUNINTERFACE_H
19 
20 #include "MeshInterfaceNanostack.h"
21 
22 /** Wi-SUN mesh network interface class
23  *
24  * Configure Nanostack to use Wi-SUN protocol.
25  */
27 public:
28 
29  /** Create an uninitialized WisunInterface
30  *
31  * Must initialize to initialize the mesh on a phy.
32  */
34 
35  /** Create an initialized WisunInterface
36  *
37  */
39 
40  /**
41  * \brief Set Wi-SUN network name.
42  *
43  * Function stores new network name to mbed-mesh-api and uses it when connect() is called next time.
44  * If device is already connected to the Wi-SUN network then device will restart network discovery after
45  * changing the network name.
46  *
47  * Function overwrites network name defined by Mbed OS configuration.
48  *
49  * \param network_name Network name as NUL terminated string. Can't exceed 32 characters and can't be NULL.
50  * \return MESH_ERROR_NONE on success.
51  * \return MESH_ERROR_UNKNOWN in case of failure.
52  * */
53  mesh_error_t set_network_name(char *network_name);
54 
55  /**
56  * \brief Set Wi-SUN network regulatory domain, operating class and operating mode.
57  *
58  * Function stores new parameters to mbed-mesh-api and uses them when connect() is called next time.
59  * If device is already connected to the Wi-SUN network then device will restart network discovery after
60  * changing the regulatory_domain, operating_class or operating_mode.
61  *
62  * Function overwrites parameters defined by Mbed OS configuration.
63  *
64  * \param regulatory_domain Values defined in Wi-SUN PHY-specification. Use 0xff to use leave parameter unchanged.
65  * \param operating_class Values defined in Wi-SUN PHY-specification. Use 0xff to use leave parameter unchanged.
66  * \param operating_mode Values defined in Wi-SUN PHY-specification. Use 0xff to use leave parameter unchanged.
67  * \return MESH_ERROR_NONE on success.
68  * \return MESH_ERROR_UNKNOWN in case of failure.
69  * */
70  mesh_error_t set_network_regulatory_domain(uint8_t regulatory_domain = 0xff, uint8_t operating_class = 0xff, uint8_t operating_mode = 0xff);
71 
72  /**
73  * \brief Set own certificate and private key reference to the Wi-SUN network.
74  *
75  * Function can be called several times if intermediate certificates are used. Then each call to the function
76  * adds a certificate reference to own certificate chain. Certificates are in bottom up order i.e. the top certificate is given last.
77  *
78  * Function must be called before connecting the device i.e before call to connect() method.
79  * Function will not copy certificate or key, therefore addresses must remain valid.
80  *
81  * \param cert Certificate address.
82  * \param cert_len Certificate length in bytes.
83  * \param cert_key Certificate key address.
84  * \param cert_key_len Certificate key length in bytes.
85  * \return MESH_ERROR_NONE on success.
86  * \return MESH_ERROR_STATE if method is called after calling connect().
87  * \return MESH_ERROR_MEMORY in case of memory allocation failure.
88  * */
89  mesh_error_t set_own_certificate(uint8_t *cert, uint16_t cert_len, uint8_t *cert_key = NULL, uint16_t cert_key_len = 0);
90 
91  /**
92  * \brief Remove own certificates from the Wi-SUN network.
93  *
94  * Function must be called before connecting the device i.e before call to connect() method.
95  *
96  * \return MESH_ERROR_NONE on success.
97  * \return MESH_ERROR_STATE if method is called after calling connect().
98  * */
99  mesh_error_t remove_own_certificates(void);
100 
101  /**
102  * \brief Set trusted certificate reference to the Wi-SUN network.
103  *
104  * Function can be called several times. Certificates are in bottom up order i.e. the top certificate is given last.
105  *
106  * Function must be called before connecting the device i.e before call to connect() method.
107  * Function will not copy certificate, therefore addresses must remain valid.
108  *
109  * \param cert Certificate address.
110  * \param cert_len Certificate length in bytes.
111  * \return MESH_ERROR_NONE on success.
112  * \return MESH_ERROR_STATE if method is called after calling connect().
113  * \return MESH_ERROR_MEMORY in case of memory allocation failure.
114  * */
115  mesh_error_t set_trusted_certificate(uint8_t *cert, uint16_t cert_len);
116 
117  /**
118  * \brief Remove trusted certificates from the Wi-SUN network.
119  *
120  * Function must be called before connecting the device i.e before call to connect() method.
121  *
122  * \return MESH_ERROR_NONE on success.
123  * \return MESH_ERROR_STATE if method is called after calling connect().
124  * */
125  mesh_error_t remove_trusted_certificates(void);
126 
127  /**
128  * \brief Get router IP address
129  *
130  * \param address
131  * \param len
132  * */
133  bool getRouterIpAddress(char *address, int8_t len);
134 protected:
135  Nanostack::WisunInterface *get_interface() const;
136  virtual nsapi_error_t do_initialize();
137 };
138 
139 #endif
Radio PHY driver class for Nanostack.
Wi-SUN mesh network interface class.
mesh_error_t remove_own_certificates(void)
Remove own certificates from the Wi-SUN network.
mesh_error_t set_network_name(char *network_name)
Set Wi-SUN network name.
bool getRouterIpAddress(char *address, int8_t len)
Get router IP address.
mesh_error_t set_network_regulatory_domain(uint8_t regulatory_domain=0xff, uint8_t operating_class=0xff, uint8_t operating_mode=0xff)
Set Wi-SUN network regulatory domain, operating class and operating mode.
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:95
mesh_error_t remove_trusted_certificates(void)
Remove trusted certificates from the Wi-SUN network.
WisunInterface()
Create an uninitialized WisunInterface.
WisunInterface(NanostackRfPhy *phy)
Create an initialized WisunInterface.
mesh_error_t set_trusted_certificate(uint8_t *cert, uint16_t cert_len)
Set trusted certificate reference to the Wi-SUN network.
mesh_error_t set_own_certificate(uint8_t *cert, uint16_t cert_len, uint8_t *cert_key=NULL, uint16_t cert_key_len=0)
Set own certificate and private key reference to the Wi-SUN network.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.