Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers QUECTEL_M26_CellularStack.h Source File

QUECTEL_M26_CellularStack.h

00001 /*
00002  * Copyright (c) 2018, 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 
00018 #ifndef QUECTEL_M26_CELLULARSTACK_H_
00019 #define QUECTEL_M26_CELLULARSTACK_H_
00020 
00021 #include "AT_CellularStack.h"
00022 
00023 namespace mbed {
00024 
00025 #define M26_SOCKET_MAX 6
00026 #define M26_CREATE_SOCKET_TIMEOUT 75000 //75 seconds
00027 #define M26_SENT_BYTE_MAX 1460
00028 #define M26_RECV_BYTE_MAX 1024
00029 
00030 class QUECTEL_M26_CellularStack : public AT_CellularStack {
00031 public:
00032     QUECTEL_M26_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device);
00033     virtual ~QUECTEL_M26_CellularStack();
00034 
00035 protected: // NetworkStack
00036 
00037     virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog);
00038 
00039     virtual nsapi_error_t socket_accept(nsapi_socket_t server,
00040                                         nsapi_socket_t *handle, SocketAddress *address = 0);
00041 
00042     virtual nsapi_error_t socket_bind(nsapi_socket_t handle, const SocketAddress &address);
00043 
00044     virtual nsapi_error_t socket_connect(nsapi_socket_t handle, const SocketAddress &address);
00045 
00046 protected: // AT_CellularStack
00047 
00048     virtual nsapi_error_t socket_stack_init();
00049 
00050     virtual int get_max_socket_count();
00051 
00052     virtual bool is_protocol_supported(nsapi_protocol_t protocol);
00053 
00054     virtual nsapi_error_t socket_close_impl(int sock_id);
00055 
00056     virtual nsapi_error_t create_socket_impl(CellularSocket *socket);
00057 
00058     virtual nsapi_size_or_error_t socket_sendto_impl(CellularSocket *socket, const SocketAddress &address,
00059                                                      const void *data, nsapi_size_t size);
00060 
00061     virtual nsapi_size_or_error_t socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address,
00062                                                        void *buffer, nsapi_size_t size);
00063 
00064 private:
00065     // URC handlers
00066     void urc_qiurc();
00067     void socket_closed(int sock_id);
00068     void socket_closed_0();
00069     void socket_closed_1();
00070     void socket_closed_2();
00071     void socket_closed_3();
00072     void socket_closed_4();
00073     void socket_closed_5();
00074 
00075     void handle_open_socket_response(int &modem_connect_id, int &err);
00076 };
00077 } // namespace mbed
00078 #endif /* QUECTEL_M26_CELLULARSTACK_H_ */