Toyomasa Watarai
/
Mbed-example-WS-W27
simple-mbed-cloud-client/mbed-cloud-client/mbed-client/mbed-client-classic/source/m2mconnectionhandler.cpp@0:119624335925, 2018-06-30 (annotated)
- Committer:
- MACRUM
- Date:
- Sat Jun 30 01:40:30 2018 +0000
- Revision:
- 0:119624335925
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MACRUM | 0:119624335925 | 1 | /* |
MACRUM | 0:119624335925 | 2 | * Copyright (c) 2015 ARM Limited. All rights reserved. |
MACRUM | 0:119624335925 | 3 | * SPDX-License-Identifier: Apache-2.0 |
MACRUM | 0:119624335925 | 4 | * Licensed under the Apache License, Version 2.0 (the License); you may |
MACRUM | 0:119624335925 | 5 | * not use this file except in compliance with the License. |
MACRUM | 0:119624335925 | 6 | * You may obtain a copy of the License at |
MACRUM | 0:119624335925 | 7 | * |
MACRUM | 0:119624335925 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
MACRUM | 0:119624335925 | 9 | * |
MACRUM | 0:119624335925 | 10 | * Unless required by applicable law or agreed to in writing, software |
MACRUM | 0:119624335925 | 11 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT |
MACRUM | 0:119624335925 | 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
MACRUM | 0:119624335925 | 13 | * See the License for the specific language governing permissions and |
MACRUM | 0:119624335925 | 14 | * limitations under the License. |
MACRUM | 0:119624335925 | 15 | */ |
MACRUM | 0:119624335925 | 16 | #include "mbed-client-classic/m2mconnectionhandlerpimpl.h" |
MACRUM | 0:119624335925 | 17 | #include "mbed-client/m2mconnectionobserver.h" |
MACRUM | 0:119624335925 | 18 | #include "mbed-client/m2mconnectionhandler.h" |
MACRUM | 0:119624335925 | 19 | #include "mbed-client/m2mconstants.h" |
MACRUM | 0:119624335925 | 20 | |
MACRUM | 0:119624335925 | 21 | M2MConnectionHandler::M2MConnectionHandler(M2MConnectionObserver &observer, |
MACRUM | 0:119624335925 | 22 | M2MConnectionSecurity* sec, |
MACRUM | 0:119624335925 | 23 | M2MInterface::BindingMode mode, |
MACRUM | 0:119624335925 | 24 | M2MInterface::NetworkStack stack) |
MACRUM | 0:119624335925 | 25 | :_observer(observer) |
MACRUM | 0:119624335925 | 26 | { |
MACRUM | 0:119624335925 | 27 | _private_impl = new M2MConnectionHandlerPimpl(this, observer, sec, mode, stack); |
MACRUM | 0:119624335925 | 28 | } |
MACRUM | 0:119624335925 | 29 | |
MACRUM | 0:119624335925 | 30 | M2MConnectionHandler::~M2MConnectionHandler() |
MACRUM | 0:119624335925 | 31 | { |
MACRUM | 0:119624335925 | 32 | delete _private_impl; |
MACRUM | 0:119624335925 | 33 | } |
MACRUM | 0:119624335925 | 34 | |
MACRUM | 0:119624335925 | 35 | bool M2MConnectionHandler::bind_connection(const uint16_t listen_port) |
MACRUM | 0:119624335925 | 36 | { |
MACRUM | 0:119624335925 | 37 | |
MACRUM | 0:119624335925 | 38 | return _private_impl->bind_connection(listen_port); |
MACRUM | 0:119624335925 | 39 | } |
MACRUM | 0:119624335925 | 40 | |
MACRUM | 0:119624335925 | 41 | bool M2MConnectionHandler::resolve_server_address(const String& server_address, |
MACRUM | 0:119624335925 | 42 | const uint16_t server_port, |
MACRUM | 0:119624335925 | 43 | M2MConnectionObserver::ServerType server_type, |
MACRUM | 0:119624335925 | 44 | const M2MSecurity* security) |
MACRUM | 0:119624335925 | 45 | { |
MACRUM | 0:119624335925 | 46 | return _private_impl->resolve_server_address(server_address, server_port, |
MACRUM | 0:119624335925 | 47 | server_type, security); |
MACRUM | 0:119624335925 | 48 | } |
MACRUM | 0:119624335925 | 49 | |
MACRUM | 0:119624335925 | 50 | bool M2MConnectionHandler::start_listening_for_data() |
MACRUM | 0:119624335925 | 51 | { |
MACRUM | 0:119624335925 | 52 | return _private_impl->start_listening_for_data(); |
MACRUM | 0:119624335925 | 53 | } |
MACRUM | 0:119624335925 | 54 | |
MACRUM | 0:119624335925 | 55 | void M2MConnectionHandler::stop_listening() |
MACRUM | 0:119624335925 | 56 | { |
MACRUM | 0:119624335925 | 57 | _private_impl->stop_listening(); |
MACRUM | 0:119624335925 | 58 | } |
MACRUM | 0:119624335925 | 59 | |
MACRUM | 0:119624335925 | 60 | bool M2MConnectionHandler::send_data(uint8_t *data, |
MACRUM | 0:119624335925 | 61 | uint16_t data_len, |
MACRUM | 0:119624335925 | 62 | sn_nsdl_addr_s *address) |
MACRUM | 0:119624335925 | 63 | { |
MACRUM | 0:119624335925 | 64 | return _private_impl->send_data(data, data_len, address); |
MACRUM | 0:119624335925 | 65 | } |
MACRUM | 0:119624335925 | 66 | |
MACRUM | 0:119624335925 | 67 | void M2MConnectionHandler::handle_connection_error(int error) |
MACRUM | 0:119624335925 | 68 | { |
MACRUM | 0:119624335925 | 69 | _private_impl->handle_connection_error(error); |
MACRUM | 0:119624335925 | 70 | } |
MACRUM | 0:119624335925 | 71 | |
MACRUM | 0:119624335925 | 72 | void M2MConnectionHandler::set_platform_network_handler(void *handler) |
MACRUM | 0:119624335925 | 73 | { |
MACRUM | 0:119624335925 | 74 | _private_impl->set_platform_network_handler(handler); |
MACRUM | 0:119624335925 | 75 | } |
MACRUM | 0:119624335925 | 76 | |
MACRUM | 0:119624335925 | 77 | void M2MConnectionHandler::claim_mutex() |
MACRUM | 0:119624335925 | 78 | { |
MACRUM | 0:119624335925 | 79 | _private_impl->claim_mutex(); |
MACRUM | 0:119624335925 | 80 | } |
MACRUM | 0:119624335925 | 81 | |
MACRUM | 0:119624335925 | 82 | void M2MConnectionHandler::release_mutex() |
MACRUM | 0:119624335925 | 83 | { |
MACRUM | 0:119624335925 | 84 | _private_impl->release_mutex(); |
MACRUM | 0:119624335925 | 85 | } |