mbed client lightswitch demo
Dependencies: mbed Socket lwip-eth lwip-sys lwip
Fork of mbed-client-classic-example-lwip by
mbed-client/mbed-client/m2mconnectionobserver.h@11:cada08fc8a70, 2016-06-09 (annotated)
- Committer:
- mbedAustin
- Date:
- Thu Jun 09 17:08:36 2016 +0000
- Revision:
- 11:cada08fc8a70
Commit for public Consumption
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mbedAustin | 11:cada08fc8a70 | 1 | /* |
| mbedAustin | 11:cada08fc8a70 | 2 | * Copyright (c) 2015 ARM Limited. All rights reserved. |
| mbedAustin | 11:cada08fc8a70 | 3 | * SPDX-License-Identifier: Apache-2.0 |
| mbedAustin | 11:cada08fc8a70 | 4 | * Licensed under the Apache License, Version 2.0 (the License); you may |
| mbedAustin | 11:cada08fc8a70 | 5 | * not use this file except in compliance with the License. |
| mbedAustin | 11:cada08fc8a70 | 6 | * You may obtain a copy of the License at |
| mbedAustin | 11:cada08fc8a70 | 7 | * |
| mbedAustin | 11:cada08fc8a70 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| mbedAustin | 11:cada08fc8a70 | 9 | * |
| mbedAustin | 11:cada08fc8a70 | 10 | * Unless required by applicable law or agreed to in writing, software |
| mbedAustin | 11:cada08fc8a70 | 11 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
| mbedAustin | 11:cada08fc8a70 | 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| mbedAustin | 11:cada08fc8a70 | 13 | * See the License for the specific language governing permissions and |
| mbedAustin | 11:cada08fc8a70 | 14 | * limitations under the License. |
| mbedAustin | 11:cada08fc8a70 | 15 | */ |
| mbedAustin | 11:cada08fc8a70 | 16 | #ifndef M2M_CONNECTION_OBSERVER_H__ |
| mbedAustin | 11:cada08fc8a70 | 17 | #define M2M_CONNECTION_OBSERVER_H__ |
| mbedAustin | 11:cada08fc8a70 | 18 | |
| mbedAustin | 11:cada08fc8a70 | 19 | #include "mbed-client/m2minterface.h" |
| mbedAustin | 11:cada08fc8a70 | 20 | |
| mbedAustin | 11:cada08fc8a70 | 21 | /** |
| mbedAustin | 11:cada08fc8a70 | 22 | * @brief M2MConnectionObserver |
| mbedAustin | 11:cada08fc8a70 | 23 | * Observer class for informing socket activity to the state machine. |
| mbedAustin | 11:cada08fc8a70 | 24 | */ |
| mbedAustin | 11:cada08fc8a70 | 25 | |
| mbedAustin | 11:cada08fc8a70 | 26 | class M2MConnectionObserver |
| mbedAustin | 11:cada08fc8a70 | 27 | { |
| mbedAustin | 11:cada08fc8a70 | 28 | |
| mbedAustin | 11:cada08fc8a70 | 29 | public : |
| mbedAustin | 11:cada08fc8a70 | 30 | |
| mbedAustin | 11:cada08fc8a70 | 31 | /** |
| mbedAustin | 11:cada08fc8a70 | 32 | * @enum ServerType, Defines the type of the |
| mbedAustin | 11:cada08fc8a70 | 33 | * server that the client wants to use. |
| mbedAustin | 11:cada08fc8a70 | 34 | */ |
| mbedAustin | 11:cada08fc8a70 | 35 | typedef enum { |
| mbedAustin | 11:cada08fc8a70 | 36 | Bootstrap, |
| mbedAustin | 11:cada08fc8a70 | 37 | LWM2MServer |
| mbedAustin | 11:cada08fc8a70 | 38 | }ServerType; |
| mbedAustin | 11:cada08fc8a70 | 39 | |
| mbedAustin | 11:cada08fc8a70 | 40 | /** |
| mbedAustin | 11:cada08fc8a70 | 41 | * @brief The M2MSocketAddress struct. |
| mbedAustin | 11:cada08fc8a70 | 42 | * Unified container for holding socket address data |
| mbedAustin | 11:cada08fc8a70 | 43 | * across different platforms. |
| mbedAustin | 11:cada08fc8a70 | 44 | */ |
| mbedAustin | 11:cada08fc8a70 | 45 | struct SocketAddress{ |
| mbedAustin | 11:cada08fc8a70 | 46 | M2MInterface::NetworkStack _stack; |
| mbedAustin | 11:cada08fc8a70 | 47 | void *_address; |
| mbedAustin | 11:cada08fc8a70 | 48 | uint8_t _length; |
| mbedAustin | 11:cada08fc8a70 | 49 | uint16_t _port; |
| mbedAustin | 11:cada08fc8a70 | 50 | }; |
| mbedAustin | 11:cada08fc8a70 | 51 | |
| mbedAustin | 11:cada08fc8a70 | 52 | /** |
| mbedAustin | 11:cada08fc8a70 | 53 | * @brief Indicates that data is available from socket. |
| mbedAustin | 11:cada08fc8a70 | 54 | * @param data, The data read from the socket. |
| mbedAustin | 11:cada08fc8a70 | 55 | * @param data_size, The length of the data read from the socket. |
| mbedAustin | 11:cada08fc8a70 | 56 | * @param address, Address of the server where the data is coming from. |
| mbedAustin | 11:cada08fc8a70 | 57 | */ |
| mbedAustin | 11:cada08fc8a70 | 58 | virtual void data_available(uint8_t* data, |
| mbedAustin | 11:cada08fc8a70 | 59 | uint16_t data_size, |
| mbedAustin | 11:cada08fc8a70 | 60 | const M2MConnectionObserver::SocketAddress &address) = 0; |
| mbedAustin | 11:cada08fc8a70 | 61 | |
| mbedAustin | 11:cada08fc8a70 | 62 | /** |
| mbedAustin | 11:cada08fc8a70 | 63 | * @brief Indicates an error occured in socket. |
| mbedAustin | 11:cada08fc8a70 | 64 | * @param error_code, Error code from socket, |
| mbedAustin | 11:cada08fc8a70 | 65 | * it cannot be used any further. |
| mbedAustin | 11:cada08fc8a70 | 66 | */ |
| mbedAustin | 11:cada08fc8a70 | 67 | virtual void socket_error(uint8_t error_code) = 0; |
| mbedAustin | 11:cada08fc8a70 | 68 | |
| mbedAustin | 11:cada08fc8a70 | 69 | /** |
| mbedAustin | 11:cada08fc8a70 | 70 | * @brief Indicates that the server address resolving is ready. |
| mbedAustin | 11:cada08fc8a70 | 71 | * @param address, Resolved socket address. |
| mbedAustin | 11:cada08fc8a70 | 72 | * @param server_type, Type of server. |
| mbedAustin | 11:cada08fc8a70 | 73 | * @param server_port, Port of the resolved server address. |
| mbedAustin | 11:cada08fc8a70 | 74 | */ |
| mbedAustin | 11:cada08fc8a70 | 75 | virtual void address_ready(const M2MConnectionObserver::SocketAddress &address, |
| mbedAustin | 11:cada08fc8a70 | 76 | M2MConnectionObserver::ServerType server_type, |
| mbedAustin | 11:cada08fc8a70 | 77 | const uint16_t server_port) = 0; |
| mbedAustin | 11:cada08fc8a70 | 78 | |
| mbedAustin | 11:cada08fc8a70 | 79 | /** |
| mbedAustin | 11:cada08fc8a70 | 80 | * @brief Indicates that data has been sent successfully. |
| mbedAustin | 11:cada08fc8a70 | 81 | */ |
| mbedAustin | 11:cada08fc8a70 | 82 | virtual void data_sent() = 0; |
| mbedAustin | 11:cada08fc8a70 | 83 | }; |
| mbedAustin | 11:cada08fc8a70 | 84 | |
| mbedAustin | 11:cada08fc8a70 | 85 | #endif // M2M_CONNECTION_OBSERVER_H__ |
Austin Blackstone
