Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GEMALTO_CINTERION_CellularStack.h Source File

GEMALTO_CINTERION_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 GEMALTO_CINTERION_CELLULAR_STACK_H_
00019 #define GEMALTO_CINTERION_CELLULAR_STACK_H_
00020 
00021 #include "AT_CellularStack.h"
00022 
00023 namespace mbed {
00024 
00025 class GEMALTO_CINTERION_CellularStack : public AT_CellularStack {
00026 public:
00027     GEMALTO_CINTERION_CellularStack(ATHandler &atHandler, const char *apn, const char *username,
00028                                     const char *password, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device);
00029     virtual ~GEMALTO_CINTERION_CellularStack();
00030 
00031 protected:
00032 
00033     virtual nsapi_error_t socket_stack_init();
00034 
00035     virtual int get_max_socket_count();
00036 
00037     virtual bool is_protocol_supported(nsapi_protocol_t protocol);
00038 
00039     virtual nsapi_error_t socket_close_impl(int sock_id);
00040 
00041     virtual nsapi_error_t create_socket_impl(CellularSocket *socket);
00042 
00043     virtual nsapi_size_or_error_t socket_sendto_impl(CellularSocket *socket, const SocketAddress &address,
00044                                                      const void *data, nsapi_size_t size);
00045 
00046     virtual nsapi_size_or_error_t socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address,
00047                                                        void *buffer, nsapi_size_t size);
00048 
00049     virtual nsapi_error_t socket_connect(nsapi_socket_t handle, const SocketAddress &address);
00050 
00051 private:
00052     // socket URC handlers as per Cinterion AT manuals
00053     void urc_sis();
00054     void urc_sisw();
00055     void sisw_urc_handler(int sock_id, int urc_code);
00056     void urc_sisr();
00057     void sisr_urc_handler(int sock_id, int urc_code);
00058 
00059     // sockets need a connection profile, one profile is enough to support single stack sockets
00060     nsapi_error_t create_connection_profile(int connection_profile_id);
00061     void close_connection_profile(int connection_profile_id);
00062 
00063     // socket open need to be deferred until sendto due to BGS2 does not support UDP server endpoint
00064     nsapi_error_t socket_open_defer(CellularSocket *socket, const SocketAddress *address = NULL);
00065 
00066     // connection profile configuration needs Access Point Name, User Name and Password
00067     const char *_apn;
00068     const char *_user;
00069     const char *_password;
00070 };
00071 
00072 } // namespace mbed
00073 
00074 #endif /* GEMALTO_CINTERION_CELLULAR_STACK_H_ */