Preliminary main mbed library for nexpaq development

Committer:
nexpaq
Date:
Fri Nov 04 20:27:58 2016 +0000
Revision:
0:6c56fb4bc5f0
Moving to library for sharing updates

Who changed what in which revision?

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