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