Pinned to some recent date

Committer:
Simon Cooksey
Date:
Thu Nov 17 16:43:53 2016 +0000
Revision:
0:fb7af294d5d9
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Simon Cooksey 0:fb7af294d5d9 1 /*
Simon Cooksey 0:fb7af294d5d9 2 * Copyright (c) 2016 ARM Limited. All rights reserved.
Simon Cooksey 0:fb7af294d5d9 3 */
Simon Cooksey 0:fb7af294d5d9 4
Simon Cooksey 0:fb7af294d5d9 5 #ifndef NANOSTACK_INTERFACE_H_
Simon Cooksey 0:fb7af294d5d9 6 #define NANOSTACK_INTERFACE_H_
Simon Cooksey 0:fb7af294d5d9 7
Simon Cooksey 0:fb7af294d5d9 8 #include "NetworkStack.h"
Simon Cooksey 0:fb7af294d5d9 9 #include "MeshInterface.h"
Simon Cooksey 0:fb7af294d5d9 10 #include "NanostackRfPhy.h"
Simon Cooksey 0:fb7af294d5d9 11
Simon Cooksey 0:fb7af294d5d9 12 #include "mbed-mesh-api/Mesh6LoWPAN_ND.h"
Simon Cooksey 0:fb7af294d5d9 13 #include "mbed-mesh-api/MeshThread.h"
Simon Cooksey 0:fb7af294d5d9 14
Simon Cooksey 0:fb7af294d5d9 15 class NanostackInterface : public NetworkStack {
Simon Cooksey 0:fb7af294d5d9 16 public:
Simon Cooksey 0:fb7af294d5d9 17 static NanostackInterface *get_stack();
Simon Cooksey 0:fb7af294d5d9 18
Simon Cooksey 0:fb7af294d5d9 19 protected:
Simon Cooksey 0:fb7af294d5d9 20
Simon Cooksey 0:fb7af294d5d9 21 /** Get the local IP address
Simon Cooksey 0:fb7af294d5d9 22 *
Simon Cooksey 0:fb7af294d5d9 23 * @return Null-terminated representation of the local IP address
Simon Cooksey 0:fb7af294d5d9 24 * or null if not yet connected
Simon Cooksey 0:fb7af294d5d9 25 */
Simon Cooksey 0:fb7af294d5d9 26 virtual const char *get_ip_address();
Simon Cooksey 0:fb7af294d5d9 27
Simon Cooksey 0:fb7af294d5d9 28 /** Opens a socket
Simon Cooksey 0:fb7af294d5d9 29 *
Simon Cooksey 0:fb7af294d5d9 30 * Creates a network socket and stores it in the specified handle.
Simon Cooksey 0:fb7af294d5d9 31 * The handle must be passed to following calls on the socket.
Simon Cooksey 0:fb7af294d5d9 32 *
Simon Cooksey 0:fb7af294d5d9 33 * A stack may have a finite number of sockets, in this case
Simon Cooksey 0:fb7af294d5d9 34 * NSAPI_ERROR_NO_SOCKET is returned if no socket is available.
Simon Cooksey 0:fb7af294d5d9 35 *
Simon Cooksey 0:fb7af294d5d9 36 * @param handle Destination for the handle to a newly created socket
Simon Cooksey 0:fb7af294d5d9 37 * @param proto Protocol of socket to open, NSAPI_TCP or NSAPI_UDP
Simon Cooksey 0:fb7af294d5d9 38 * @return 0 on success, negative error code on failure
Simon Cooksey 0:fb7af294d5d9 39 */
Simon Cooksey 0:fb7af294d5d9 40 virtual int socket_open(void **handle, nsapi_protocol_t proto);
Simon Cooksey 0:fb7af294d5d9 41
Simon Cooksey 0:fb7af294d5d9 42 /** Close the socket
Simon Cooksey 0:fb7af294d5d9 43 *
Simon Cooksey 0:fb7af294d5d9 44 * Closes any open connection and deallocates any memory associated
Simon Cooksey 0:fb7af294d5d9 45 * with the socket.
Simon Cooksey 0:fb7af294d5d9 46 *
Simon Cooksey 0:fb7af294d5d9 47 * @param handle Socket handle
Simon Cooksey 0:fb7af294d5d9 48 * @return 0 on success, negative error code on failure
Simon Cooksey 0:fb7af294d5d9 49 */
Simon Cooksey 0:fb7af294d5d9 50 virtual int socket_close(void *handle);
Simon Cooksey 0:fb7af294d5d9 51
Simon Cooksey 0:fb7af294d5d9 52 /** Bind a specific address to a socket
Simon Cooksey 0:fb7af294d5d9 53 *
Simon Cooksey 0:fb7af294d5d9 54 * Binding a socket specifies the address and port on which to recieve
Simon Cooksey 0:fb7af294d5d9 55 * data. If the IP address is zeroed, only the port is bound.
Simon Cooksey 0:fb7af294d5d9 56 *
Simon Cooksey 0:fb7af294d5d9 57 * @param handle Socket handle
Simon Cooksey 0:fb7af294d5d9 58 * @param address Local address to bind
Simon Cooksey 0:fb7af294d5d9 59 * @return 0 on success, negative error code on failure.
Simon Cooksey 0:fb7af294d5d9 60 */
Simon Cooksey 0:fb7af294d5d9 61 virtual int socket_bind(void *handle, const SocketAddress &address);
Simon Cooksey 0:fb7af294d5d9 62
Simon Cooksey 0:fb7af294d5d9 63 /** Listen for connections on a TCP socket
Simon Cooksey 0:fb7af294d5d9 64 *
Simon Cooksey 0:fb7af294d5d9 65 * Marks the socket as a passive socket that can be used to accept
Simon Cooksey 0:fb7af294d5d9 66 * incoming connections.
Simon Cooksey 0:fb7af294d5d9 67 *
Simon Cooksey 0:fb7af294d5d9 68 * @param handle Socket handle
Simon Cooksey 0:fb7af294d5d9 69 * @param backlog Number of pending connections that can be queued
Simon Cooksey 0:fb7af294d5d9 70 * simultaneously
Simon Cooksey 0:fb7af294d5d9 71 * @return 0 on success, negative error code on failure
Simon Cooksey 0:fb7af294d5d9 72 */
Simon Cooksey 0:fb7af294d5d9 73 virtual int socket_listen(void *handle, int backlog);
Simon Cooksey 0:fb7af294d5d9 74
Simon Cooksey 0:fb7af294d5d9 75 /** Connects TCP socket to a remote host
Simon Cooksey 0:fb7af294d5d9 76 *
Simon Cooksey 0:fb7af294d5d9 77 * Initiates a connection to a remote server specified by the
Simon Cooksey 0:fb7af294d5d9 78 * indicated address.
Simon Cooksey 0:fb7af294d5d9 79 *
Simon Cooksey 0:fb7af294d5d9 80 * @param handle Socket handle
Simon Cooksey 0:fb7af294d5d9 81 * @param address The SocketAddress of the remote host
Simon Cooksey 0:fb7af294d5d9 82 * @return 0 on success, negative error code on failure
Simon Cooksey 0:fb7af294d5d9 83 */
Simon Cooksey 0:fb7af294d5d9 84 virtual int socket_connect(void *handle, const SocketAddress &address);
Simon Cooksey 0:fb7af294d5d9 85
Simon Cooksey 0:fb7af294d5d9 86 /** Accepts a connection on a TCP socket
Simon Cooksey 0:fb7af294d5d9 87 *
Simon Cooksey 0:fb7af294d5d9 88 * The server socket must be bound and set to listen for connections.
Simon Cooksey 0:fb7af294d5d9 89 * On a new connection, creates a network socket and stores it in the
Simon Cooksey 0:fb7af294d5d9 90 * specified handle. The handle must be passed to following calls on
Simon Cooksey 0:fb7af294d5d9 91 * the socket.
Simon Cooksey 0:fb7af294d5d9 92 *
Simon Cooksey 0:fb7af294d5d9 93 * A stack may have a finite number of sockets, in this case
Simon Cooksey 0:fb7af294d5d9 94 * NSAPI_ERROR_NO_SOCKET is returned if no socket is available.
Simon Cooksey 0:fb7af294d5d9 95 *
Simon Cooksey 0:fb7af294d5d9 96 * This call is non-blocking. If accept would block,
Simon Cooksey 0:fb7af294d5d9 97 * NSAPI_ERROR_WOULD_BLOCK is returned immediately.
Simon Cooksey 0:fb7af294d5d9 98 *
Simon Cooksey 0:fb7af294d5d9 99 * @param server Socket handle to server to accept from
Simon Cooksey 0:fb7af294d5d9 100 * @param handle Destination for a handle to the newly created socket
Simon Cooksey 0:fb7af294d5d9 101 * @param address Destination for the remote address or NULL
Simon Cooksey 0:fb7af294d5d9 102 * @return 0 on success, negative error code on failure
Simon Cooksey 0:fb7af294d5d9 103 */
Simon Cooksey 0:fb7af294d5d9 104 virtual int socket_accept(void *handle, void **server, SocketAddress *address);
Simon Cooksey 0:fb7af294d5d9 105
Simon Cooksey 0:fb7af294d5d9 106 /** Send data over a TCP socket
Simon Cooksey 0:fb7af294d5d9 107 *
Simon Cooksey 0:fb7af294d5d9 108 * The socket must be connected to a remote host. Returns the number of
Simon Cooksey 0:fb7af294d5d9 109 * bytes sent from the buffer.
Simon Cooksey 0:fb7af294d5d9 110 *
Simon Cooksey 0:fb7af294d5d9 111 * This call is non-blocking. If send would block,
Simon Cooksey 0:fb7af294d5d9 112 * NSAPI_ERROR_WOULD_BLOCK is returned immediately.
Simon Cooksey 0:fb7af294d5d9 113 *
Simon Cooksey 0:fb7af294d5d9 114 * @param handle Socket handle
Simon Cooksey 0:fb7af294d5d9 115 * @param data Buffer of data to send to the host
Simon Cooksey 0:fb7af294d5d9 116 * @param size Size of the buffer in bytes
Simon Cooksey 0:fb7af294d5d9 117 * @return Number of sent bytes on success, negative error
Simon Cooksey 0:fb7af294d5d9 118 * code on failure
Simon Cooksey 0:fb7af294d5d9 119 */
Simon Cooksey 0:fb7af294d5d9 120 virtual int socket_send(void *handle, const void *data, unsigned size);
Simon Cooksey 0:fb7af294d5d9 121
Simon Cooksey 0:fb7af294d5d9 122 /** Receive data over a TCP socket
Simon Cooksey 0:fb7af294d5d9 123 *
Simon Cooksey 0:fb7af294d5d9 124 * The socket must be connected to a remote host. Returns the number of
Simon Cooksey 0:fb7af294d5d9 125 * bytes received into the buffer.
Simon Cooksey 0:fb7af294d5d9 126 *
Simon Cooksey 0:fb7af294d5d9 127 * This call is non-blocking. If recv would block,
Simon Cooksey 0:fb7af294d5d9 128 * NSAPI_ERROR_WOULD_BLOCK is returned immediately.
Simon Cooksey 0:fb7af294d5d9 129 *
Simon Cooksey 0:fb7af294d5d9 130 * @param handle Socket handle
Simon Cooksey 0:fb7af294d5d9 131 * @param data Destination buffer for data received from the host
Simon Cooksey 0:fb7af294d5d9 132 * @param size Size of the buffer in bytes
Simon Cooksey 0:fb7af294d5d9 133 * @return Number of received bytes on success, negative error
Simon Cooksey 0:fb7af294d5d9 134 * code on failure
Simon Cooksey 0:fb7af294d5d9 135 */
Simon Cooksey 0:fb7af294d5d9 136 virtual int socket_recv(void *handle, void *data, unsigned size);
Simon Cooksey 0:fb7af294d5d9 137
Simon Cooksey 0:fb7af294d5d9 138 /** Send a packet over a UDP socket
Simon Cooksey 0:fb7af294d5d9 139 *
Simon Cooksey 0:fb7af294d5d9 140 * Sends data to the specified address. Returns the number of bytes
Simon Cooksey 0:fb7af294d5d9 141 * sent from the buffer.
Simon Cooksey 0:fb7af294d5d9 142 *
Simon Cooksey 0:fb7af294d5d9 143 * This call is non-blocking. If sendto would block,
Simon Cooksey 0:fb7af294d5d9 144 * NSAPI_ERROR_WOULD_BLOCK is returned immediately.
Simon Cooksey 0:fb7af294d5d9 145 *
Simon Cooksey 0:fb7af294d5d9 146 * @param handle Socket handle
Simon Cooksey 0:fb7af294d5d9 147 * @param address The SocketAddress of the remote host
Simon Cooksey 0:fb7af294d5d9 148 * @param data Buffer of data to send to the host
Simon Cooksey 0:fb7af294d5d9 149 * @param size Size of the buffer in bytes
Simon Cooksey 0:fb7af294d5d9 150 * @return Number of sent bytes on success, negative error
Simon Cooksey 0:fb7af294d5d9 151 * code on failure
Simon Cooksey 0:fb7af294d5d9 152 */
Simon Cooksey 0:fb7af294d5d9 153 virtual int socket_sendto(void *handle, const SocketAddress &address, const void *data, unsigned size);
Simon Cooksey 0:fb7af294d5d9 154
Simon Cooksey 0:fb7af294d5d9 155 /** Receive a packet over a UDP socket
Simon Cooksey 0:fb7af294d5d9 156 *
Simon Cooksey 0:fb7af294d5d9 157 * Receives data and stores the source address in address if address
Simon Cooksey 0:fb7af294d5d9 158 * is not NULL. Returns the number of bytes received into the buffer.
Simon Cooksey 0:fb7af294d5d9 159 *
Simon Cooksey 0:fb7af294d5d9 160 * This call is non-blocking. If recvfrom would block,
Simon Cooksey 0:fb7af294d5d9 161 * NSAPI_ERROR_WOULD_BLOCK is returned immediately.
Simon Cooksey 0:fb7af294d5d9 162 *
Simon Cooksey 0:fb7af294d5d9 163 * @param handle Socket handle
Simon Cooksey 0:fb7af294d5d9 164 * @param address Destination for the source address or NULL
Simon Cooksey 0:fb7af294d5d9 165 * @param data Destination buffer for data received from the host
Simon Cooksey 0:fb7af294d5d9 166 * @param size Size of the buffer in bytes
Simon Cooksey 0:fb7af294d5d9 167 * @return Number of received bytes on success, negative error
Simon Cooksey 0:fb7af294d5d9 168 * code on failure
Simon Cooksey 0:fb7af294d5d9 169 */
Simon Cooksey 0:fb7af294d5d9 170 virtual int socket_recvfrom(void *handle, SocketAddress *address, void *buffer, unsigned size);
Simon Cooksey 0:fb7af294d5d9 171
Simon Cooksey 0:fb7af294d5d9 172 /** Register a callback on state change of the socket
Simon Cooksey 0:fb7af294d5d9 173 *
Simon Cooksey 0:fb7af294d5d9 174 * The specified callback will be called on state changes such as when
Simon Cooksey 0:fb7af294d5d9 175 * the socket can recv/send/accept successfully and on when an error
Simon Cooksey 0:fb7af294d5d9 176 * occurs. The callback may also be called spuriously without reason.
Simon Cooksey 0:fb7af294d5d9 177 *
Simon Cooksey 0:fb7af294d5d9 178 * The callback may be called in an interrupt context and should not
Simon Cooksey 0:fb7af294d5d9 179 * perform expensive operations such as recv/send calls.
Simon Cooksey 0:fb7af294d5d9 180 *
Simon Cooksey 0:fb7af294d5d9 181 * @param handle Socket handle
Simon Cooksey 0:fb7af294d5d9 182 * @param callback Function to call on state change
Simon Cooksey 0:fb7af294d5d9 183 * @param data Argument to pass to callback
Simon Cooksey 0:fb7af294d5d9 184 */
Simon Cooksey 0:fb7af294d5d9 185 virtual void socket_attach(void *handle, void (*callback)(void *), void *data);
Simon Cooksey 0:fb7af294d5d9 186
Simon Cooksey 0:fb7af294d5d9 187 /* Set stack-specific socket options
Simon Cooksey 0:fb7af294d5d9 188 *
Simon Cooksey 0:fb7af294d5d9 189 * The setsockopt allow an application to pass stack-specific hints
Simon Cooksey 0:fb7af294d5d9 190 * to the underlying stack. For unsupported options,
Simon Cooksey 0:fb7af294d5d9 191 * NSAPI_ERROR_UNSUPPORTED is returned and the socket is unmodified.
Simon Cooksey 0:fb7af294d5d9 192 *
Simon Cooksey 0:fb7af294d5d9 193 * @param handle Socket handle
Simon Cooksey 0:fb7af294d5d9 194 * @param level Stack-specific protocol level
Simon Cooksey 0:fb7af294d5d9 195 * @param optname Stack-specific option identifier
Simon Cooksey 0:fb7af294d5d9 196 * @param optval Option value
Simon Cooksey 0:fb7af294d5d9 197 * @param optlen Length of the option value
Simon Cooksey 0:fb7af294d5d9 198 * @return 0 on success, negative error code on failure
Simon Cooksey 0:fb7af294d5d9 199 */
Simon Cooksey 0:fb7af294d5d9 200 virtual int setsockopt(void *handle, int level, int optname, const void *optval, unsigned optlen);
Simon Cooksey 0:fb7af294d5d9 201
Simon Cooksey 0:fb7af294d5d9 202 /* Get stack-specific socket options
Simon Cooksey 0:fb7af294d5d9 203 *
Simon Cooksey 0:fb7af294d5d9 204 * The getstackopt allow an application to retrieve stack-specific hints
Simon Cooksey 0:fb7af294d5d9 205 * from the underlying stack. For unsupported options,
Simon Cooksey 0:fb7af294d5d9 206 * NSAPI_ERROR_UNSUPPORTED is returned and optval is unmodified.
Simon Cooksey 0:fb7af294d5d9 207 *
Simon Cooksey 0:fb7af294d5d9 208 * @param handle Socket handle
Simon Cooksey 0:fb7af294d5d9 209 * @param level Stack-specific protocol level
Simon Cooksey 0:fb7af294d5d9 210 * @param optname Stack-specific option identifier
Simon Cooksey 0:fb7af294d5d9 211 * @param optval Destination for option value
Simon Cooksey 0:fb7af294d5d9 212 * @param optlen Length of the option value
Simon Cooksey 0:fb7af294d5d9 213 * @return 0 on success, negative error code on failure
Simon Cooksey 0:fb7af294d5d9 214 */
Simon Cooksey 0:fb7af294d5d9 215 virtual int getsockopt(void *handle, int level, int optname, void *optval, unsigned *optlen);
Simon Cooksey 0:fb7af294d5d9 216
Simon Cooksey 0:fb7af294d5d9 217 private:
Simon Cooksey 0:fb7af294d5d9 218 static NanostackInterface * _ns_interface;
Simon Cooksey 0:fb7af294d5d9 219 };
Simon Cooksey 0:fb7af294d5d9 220
Simon Cooksey 0:fb7af294d5d9 221 class MeshInterfaceNanostack : public MeshInterface {
Simon Cooksey 0:fb7af294d5d9 222 public:
Simon Cooksey 0:fb7af294d5d9 223
Simon Cooksey 0:fb7af294d5d9 224 /** Attach phy and initialize the mesh
Simon Cooksey 0:fb7af294d5d9 225 *
Simon Cooksey 0:fb7af294d5d9 226 * Initializes a mesh interface on the given phy. Not needed if
Simon Cooksey 0:fb7af294d5d9 227 * the phy is passed to the mesh's constructor.
Simon Cooksey 0:fb7af294d5d9 228 *
Simon Cooksey 0:fb7af294d5d9 229 * @return 0 on success, negative on failure
Simon Cooksey 0:fb7af294d5d9 230 */
Simon Cooksey 0:fb7af294d5d9 231 virtual int initialize(NanostackRfPhy *phy);
Simon Cooksey 0:fb7af294d5d9 232
Simon Cooksey 0:fb7af294d5d9 233 /** Start the interface
Simon Cooksey 0:fb7af294d5d9 234 *
Simon Cooksey 0:fb7af294d5d9 235 * @return 0 on success, negative on failure
Simon Cooksey 0:fb7af294d5d9 236 */
Simon Cooksey 0:fb7af294d5d9 237 virtual int connect() = 0;
Simon Cooksey 0:fb7af294d5d9 238
Simon Cooksey 0:fb7af294d5d9 239 /** Stop the interface
Simon Cooksey 0:fb7af294d5d9 240 *
Simon Cooksey 0:fb7af294d5d9 241 * @return 0 on success, negative on failure
Simon Cooksey 0:fb7af294d5d9 242 */
Simon Cooksey 0:fb7af294d5d9 243 virtual int disconnect();
Simon Cooksey 0:fb7af294d5d9 244
Simon Cooksey 0:fb7af294d5d9 245 /** Get the internally stored IP address
Simon Cooksey 0:fb7af294d5d9 246 /return IP address of the interface or null if not yet connected
Simon Cooksey 0:fb7af294d5d9 247 */
Simon Cooksey 0:fb7af294d5d9 248 virtual const char *get_ip_address();
Simon Cooksey 0:fb7af294d5d9 249
Simon Cooksey 0:fb7af294d5d9 250 /** Get the internally stored MAC address
Simon Cooksey 0:fb7af294d5d9 251 /return MAC address of the interface
Simon Cooksey 0:fb7af294d5d9 252 */
Simon Cooksey 0:fb7af294d5d9 253 virtual const char *get_mac_address();
Simon Cooksey 0:fb7af294d5d9 254
Simon Cooksey 0:fb7af294d5d9 255 protected:
Simon Cooksey 0:fb7af294d5d9 256 MeshInterfaceNanostack();
Simon Cooksey 0:fb7af294d5d9 257 MeshInterfaceNanostack(NanostackRfPhy *phy);
Simon Cooksey 0:fb7af294d5d9 258 int register_rf();
Simon Cooksey 0:fb7af294d5d9 259 int actual_connect();
Simon Cooksey 0:fb7af294d5d9 260 virtual NetworkStack * get_stack(void);
Simon Cooksey 0:fb7af294d5d9 261
Simon Cooksey 0:fb7af294d5d9 262 void mesh_network_handler(mesh_connection_status_t status);
Simon Cooksey 0:fb7af294d5d9 263 NanostackRfPhy *phy;
Simon Cooksey 0:fb7af294d5d9 264 AbstractMesh *mesh_api;
Simon Cooksey 0:fb7af294d5d9 265 int8_t rf_device_id;
Simon Cooksey 0:fb7af294d5d9 266 uint8_t eui64[8];
Simon Cooksey 0:fb7af294d5d9 267 char ip_addr_str[40];
Simon Cooksey 0:fb7af294d5d9 268 char mac_addr_str[24];
Simon Cooksey 0:fb7af294d5d9 269 Semaphore connect_semaphore;
Simon Cooksey 0:fb7af294d5d9 270 };
Simon Cooksey 0:fb7af294d5d9 271
Simon Cooksey 0:fb7af294d5d9 272 class LoWPANNDInterface : public MeshInterfaceNanostack {
Simon Cooksey 0:fb7af294d5d9 273 public:
Simon Cooksey 0:fb7af294d5d9 274
Simon Cooksey 0:fb7af294d5d9 275 /** Create an uninitialized LoWPANNDInterface
Simon Cooksey 0:fb7af294d5d9 276 *
Simon Cooksey 0:fb7af294d5d9 277 * Must initialize to initialize the mesh on a phy.
Simon Cooksey 0:fb7af294d5d9 278 */
Simon Cooksey 0:fb7af294d5d9 279 LoWPANNDInterface() : MeshInterfaceNanostack() {
Simon Cooksey 0:fb7af294d5d9 280
Simon Cooksey 0:fb7af294d5d9 281 }
Simon Cooksey 0:fb7af294d5d9 282
Simon Cooksey 0:fb7af294d5d9 283 /** Create an initialized MeshInterface
Simon Cooksey 0:fb7af294d5d9 284 *
Simon Cooksey 0:fb7af294d5d9 285 */
Simon Cooksey 0:fb7af294d5d9 286 LoWPANNDInterface(NanostackRfPhy *phy) : MeshInterfaceNanostack(phy) {
Simon Cooksey 0:fb7af294d5d9 287
Simon Cooksey 0:fb7af294d5d9 288 }
Simon Cooksey 0:fb7af294d5d9 289
Simon Cooksey 0:fb7af294d5d9 290 int connect();
Simon Cooksey 0:fb7af294d5d9 291 protected:
Simon Cooksey 0:fb7af294d5d9 292 Mesh6LoWPAN_ND *get_mesh_api() const { return static_cast<Mesh6LoWPAN_ND *>(mesh_api); }
Simon Cooksey 0:fb7af294d5d9 293 private:
Simon Cooksey 0:fb7af294d5d9 294
Simon Cooksey 0:fb7af294d5d9 295 };
Simon Cooksey 0:fb7af294d5d9 296
Simon Cooksey 0:fb7af294d5d9 297 class ThreadInterface : public MeshInterfaceNanostack {
Simon Cooksey 0:fb7af294d5d9 298 public:
Simon Cooksey 0:fb7af294d5d9 299
Simon Cooksey 0:fb7af294d5d9 300 /** Create an uninitialized LoWPANNDInterface
Simon Cooksey 0:fb7af294d5d9 301 *
Simon Cooksey 0:fb7af294d5d9 302 * Must initialize to initialize the mesh on a phy.
Simon Cooksey 0:fb7af294d5d9 303 */
Simon Cooksey 0:fb7af294d5d9 304 ThreadInterface() : MeshInterfaceNanostack() {
Simon Cooksey 0:fb7af294d5d9 305
Simon Cooksey 0:fb7af294d5d9 306 }
Simon Cooksey 0:fb7af294d5d9 307
Simon Cooksey 0:fb7af294d5d9 308 /** Create an initialized MeshInterface
Simon Cooksey 0:fb7af294d5d9 309 *
Simon Cooksey 0:fb7af294d5d9 310 */
Simon Cooksey 0:fb7af294d5d9 311 ThreadInterface(NanostackRfPhy *phy) : MeshInterfaceNanostack(phy) {
Simon Cooksey 0:fb7af294d5d9 312
Simon Cooksey 0:fb7af294d5d9 313 }
Simon Cooksey 0:fb7af294d5d9 314
Simon Cooksey 0:fb7af294d5d9 315 int connect();
Simon Cooksey 0:fb7af294d5d9 316 protected:
Simon Cooksey 0:fb7af294d5d9 317 MeshThread *get_mesh_api() const { return static_cast<MeshThread *>(mesh_api); }
Simon Cooksey 0:fb7af294d5d9 318 private:
Simon Cooksey 0:fb7af294d5d9 319
Simon Cooksey 0:fb7af294d5d9 320 };
Simon Cooksey 0:fb7af294d5d9 321
Simon Cooksey 0:fb7af294d5d9 322
Simon Cooksey 0:fb7af294d5d9 323 #endif /* NANOSTACK_INTERFACE_H_ */