Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers UBLOX_N2XX_CellularStack.h Source File

UBLOX_N2XX_CellularStack.h

00001 /*
00002  * Copyright (c) 2019, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 #ifndef UBLOX_N2XX_CELLULARSTACK_H_
00018 #define UBLOX_N2XX_CELLULARSTACK_H_
00019 
00020 #include "AT_CellularStack.h"
00021 #include "CellularUtil.h"
00022 #include "mbed_wait_api.h"
00023 #include "drivers/Timer.h"
00024 
00025 namespace mbed {
00026 
00027 class UBLOX_N2XX_CellularStack : public AT_CellularStack {
00028 
00029 public:
00030 
00031     UBLOX_N2XX_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device);
00032     virtual ~UBLOX_N2XX_CellularStack();
00033 
00034 protected:
00035 
00036     virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog);
00037 
00038     virtual nsapi_error_t socket_accept(nsapi_socket_t server,
00039                                         nsapi_socket_t *handle, SocketAddress *address = 0);
00040 
00041 protected:
00042 
00043     /** Socket timeout value in milliseconds.
00044      * Note: the sockets layer above will retry the
00045      * call to the functions here when they return NSAPI_ERROR_WOULD_BLOCK
00046      * and the user has set a larger timeout or full blocking.
00047      */
00048     static const int SOCKET_TIMEOUT = 1000;
00049 
00050     /** Maximum allowed sockets.
00051      */
00052     static const int N2XX_MAX_SOCKET = 7;
00053 
00054     /** The maximum number of bytes in a packet that can be write/read from
00055      * the AT interface in one go.
00056      */
00057     static const int N2XX_MAX_PACKET_SIZE = 512;
00058 
00059     virtual int get_max_socket_count();
00060 
00061     virtual bool is_protocol_supported(nsapi_protocol_t protocol);
00062 
00063     virtual nsapi_error_t create_socket_impl(CellularSocket *socket);
00064 
00065     virtual nsapi_size_or_error_t socket_sendto_impl(CellularSocket *socket, const SocketAddress &address,
00066                                                      const void *data, nsapi_size_t size);
00067 
00068     virtual nsapi_size_or_error_t socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address,
00069                                                        void *buffer, nsapi_size_t size);
00070 
00071     virtual nsapi_error_t socket_close_impl(int sock_id);
00072 
00073 private:
00074 
00075     // URC handlers
00076     void NSONMI_URC();
00077 };
00078 
00079 } // namespace mbed
00080 
00081 #endif // UBLOX_N2XX_CELLULARSTACK_H_