mbed client on ethernet with LWIP
Dependencies: mbed Socket lwip-eth lwip-sys lwip
Fork of mbed-client-classic-example-lwip by
mbed-client-classic/source/m2mconnectionhandler.cpp@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 | #include "mbed-client-classic/m2mconnectionhandlerpimpl.h" |
mbedAustin | 11:cada08fc8a70 | 17 | #include "mbed-client/m2mconnectionobserver.h" |
mbedAustin | 11:cada08fc8a70 | 18 | #include "mbed-client/m2mconnectionhandler.h" |
mbedAustin | 11:cada08fc8a70 | 19 | #include "mbed-client/m2mconstants.h" |
mbedAustin | 11:cada08fc8a70 | 20 | |
mbedAustin | 11:cada08fc8a70 | 21 | M2MConnectionHandler::M2MConnectionHandler(M2MConnectionObserver &observer, |
mbedAustin | 11:cada08fc8a70 | 22 | M2MConnectionSecurity* sec, |
mbedAustin | 11:cada08fc8a70 | 23 | M2MInterface::BindingMode mode, |
mbedAustin | 11:cada08fc8a70 | 24 | M2MInterface::NetworkStack stack) |
mbedAustin | 11:cada08fc8a70 | 25 | :_observer(observer) |
mbedAustin | 11:cada08fc8a70 | 26 | { |
mbedAustin | 11:cada08fc8a70 | 27 | _private_impl = new M2MConnectionHandlerPimpl(this, observer, sec, mode, stack); |
mbedAustin | 11:cada08fc8a70 | 28 | } |
mbedAustin | 11:cada08fc8a70 | 29 | |
mbedAustin | 11:cada08fc8a70 | 30 | M2MConnectionHandler::~M2MConnectionHandler() |
mbedAustin | 11:cada08fc8a70 | 31 | { |
mbedAustin | 11:cada08fc8a70 | 32 | delete _private_impl; |
mbedAustin | 11:cada08fc8a70 | 33 | } |
mbedAustin | 11:cada08fc8a70 | 34 | |
mbedAustin | 11:cada08fc8a70 | 35 | bool M2MConnectionHandler::bind_connection(const uint16_t listen_port) |
mbedAustin | 11:cada08fc8a70 | 36 | { |
mbedAustin | 11:cada08fc8a70 | 37 | |
mbedAustin | 11:cada08fc8a70 | 38 | return _private_impl->bind_connection(listen_port); |
mbedAustin | 11:cada08fc8a70 | 39 | } |
mbedAustin | 11:cada08fc8a70 | 40 | |
mbedAustin | 11:cada08fc8a70 | 41 | bool M2MConnectionHandler::resolve_server_address(const String& server_address, |
mbedAustin | 11:cada08fc8a70 | 42 | const uint16_t server_port, |
mbedAustin | 11:cada08fc8a70 | 43 | M2MConnectionObserver::ServerType server_type, |
mbedAustin | 11:cada08fc8a70 | 44 | const M2MSecurity* security) |
mbedAustin | 11:cada08fc8a70 | 45 | { |
mbedAustin | 11:cada08fc8a70 | 46 | return _private_impl->resolve_server_address(server_address, server_port, |
mbedAustin | 11:cada08fc8a70 | 47 | server_type, security); |
mbedAustin | 11:cada08fc8a70 | 48 | } |
mbedAustin | 11:cada08fc8a70 | 49 | |
mbedAustin | 11:cada08fc8a70 | 50 | bool M2MConnectionHandler::start_listening_for_data() |
mbedAustin | 11:cada08fc8a70 | 51 | { |
mbedAustin | 11:cada08fc8a70 | 52 | return _private_impl->start_listening_for_data(); |
mbedAustin | 11:cada08fc8a70 | 53 | } |
mbedAustin | 11:cada08fc8a70 | 54 | |
mbedAustin | 11:cada08fc8a70 | 55 | void M2MConnectionHandler::stop_listening() |
mbedAustin | 11:cada08fc8a70 | 56 | { |
mbedAustin | 11:cada08fc8a70 | 57 | _private_impl->stop_listening(); |
mbedAustin | 11:cada08fc8a70 | 58 | } |
mbedAustin | 11:cada08fc8a70 | 59 | |
mbedAustin | 11:cada08fc8a70 | 60 | int M2MConnectionHandler::send_to_socket(const unsigned char *buf, size_t len) |
mbedAustin | 11:cada08fc8a70 | 61 | { |
mbedAustin | 11:cada08fc8a70 | 62 | return _private_impl->send_to_socket(buf, len); |
mbedAustin | 11:cada08fc8a70 | 63 | } |
mbedAustin | 11:cada08fc8a70 | 64 | |
mbedAustin | 11:cada08fc8a70 | 65 | int M2MConnectionHandler::receive_from_socket(unsigned char *buf, size_t len) |
mbedAustin | 11:cada08fc8a70 | 66 | { |
mbedAustin | 11:cada08fc8a70 | 67 | return _private_impl->receive_from_socket(buf, len); |
mbedAustin | 11:cada08fc8a70 | 68 | } |
mbedAustin | 11:cada08fc8a70 | 69 | |
mbedAustin | 11:cada08fc8a70 | 70 | bool M2MConnectionHandler::send_data(uint8_t *data, |
mbedAustin | 11:cada08fc8a70 | 71 | uint16_t data_len, |
mbedAustin | 11:cada08fc8a70 | 72 | sn_nsdl_addr_s *address) |
mbedAustin | 11:cada08fc8a70 | 73 | { |
mbedAustin | 11:cada08fc8a70 | 74 | return _private_impl->send_data(data, data_len, address); |
mbedAustin | 11:cada08fc8a70 | 75 | } |
mbedAustin | 11:cada08fc8a70 | 76 | |
mbedAustin | 11:cada08fc8a70 | 77 | void M2MConnectionHandler::handle_connection_error(int error) |
mbedAustin | 11:cada08fc8a70 | 78 | { |
mbedAustin | 11:cada08fc8a70 | 79 | _private_impl->handle_connection_error(error); |
mbedAustin | 11:cada08fc8a70 | 80 | } |