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