Mistake on this page?
Report an issue in GitHub or email us
TELIT_ME310_CellularStack.h
1 /*
2  * Copyright (c) 2020, Arm Limited and affiliates.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef TELIT_ME310_CELLULARSTACK_H_
19 #define TELIT_ME310_CELLULARSTACK_H_
20 
21 #include "AT_CellularStack.h"
22 #include "mbed_trace.h"
23 #include "drivers/Timer.h"
24 
25 
26 namespace mbed {
27 
28 #define ME310_SOCKET_MAX 6
29 #define ME310_CONTEXT_MAX 6
30 #define ME310_CREATE_SOCKET_TIMEOUT 150000 //150 seconds
31 #define ME310_CLOSE_SOCKET_TIMEOUT 20000 // TCP socket max timeout is >10sec
32 #define ME310_MAX_RECV_SIZE 1000
33 #define ME310_MAX_SEND_SIZE 1023
34 #define ME310_SOCKET_BIND_FAIL 556
35 #define ME310_IPEASY_ACTIVATED_CONTEXT 1
36 #define ME310_IPEASY_DEACTIVATED_CONTEXT 0
37 #define CTRL_Z "\x1a"
38 #define ESC "\x1b"
39 
41 public:
42  TELIT_ME310_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device);
43  virtual ~TELIT_ME310_CellularStack();
44 
45 protected: // NetworkStack
46 
47  virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog);
48 
50  nsapi_socket_t *handle, SocketAddress *address = 0);
51 
52  virtual nsapi_error_t socket_connect(nsapi_socket_t handle, const SocketAddress &address);
53 
54 #if defined(MBED_CONF_NSAPI_OFFLOAD_TLSSOCKET) && (MBED_CONF_NSAPI_OFFLOAD_TLSSOCKET)
55  virtual nsapi_error_t setsockopt(nsapi_socket_t handle, int level,
56  int optname, const void *optval, unsigned optlen);
57 #endif
58 
59 protected: // AT_CellularStack
60 
61  virtual int get_max_socket_count();
62 
63  virtual bool is_protocol_supported(nsapi_protocol_t protocol);
64 
65  virtual nsapi_error_t socket_close_impl(int sock_id);
66 
68 
70  const void *data, nsapi_size_t size);
71 
73  void *buffer, nsapi_size_t size);
74 
75 private:
76  // URC handler for socket data being received
77  void urc_sring();
78 
79  bool is_ipeasy_context_activated(int context_id);
80  nsapi_error_t activate_ipeasy_context(int context_id);
81  nsapi_error_t deactivate_ipeasy_context(int context_id);
82 
83  uint8_t _tls_sec_level;
84 };
85 } // namespace mbed
86 #endif /* TELIT_ME310_CELLULARSTACK_H_ */
Class AT_CellularStack.
void * nsapi_socket_t
Opaque handle for network sockets.
Definition: nsapi_types.h:252
virtual nsapi_error_t socket_close_impl(int sock_id)
Implements modem specific AT command set for socket closing.
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:140
virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog)
Listen for connections on a TCP socket.
signed int nsapi_size_or_error_t
Type used to represent either a size or error passed through sockets.
Definition: nsapi_types.h:151
virtual nsapi_error_t setsockopt(nsapi_socket_t handle, int level, int optname, const void *optval, unsigned optlen)
Set stack-specific socket options.
SocketAddress class.
Definition: SocketAddress.h:37
virtual nsapi_size_or_error_t socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address, void *buffer, nsapi_size_t size)
Implements modem specific AT command set for receiving data.
Class AT_CellularDevice.
virtual nsapi_error_t create_socket_impl(CellularSocket *socket)
Implements modem specific AT command set for creating socket.
unsigned int nsapi_size_t
Type used to represent the size of data passed through sockets.
Definition: nsapi_types.h:144
virtual nsapi_error_t socket_connect(nsapi_socket_t handle, const SocketAddress &address)
Connects TCP socket to a remote host.
virtual nsapi_size_or_error_t socket_sendto_impl(CellularSocket *socket, const SocketAddress &address, const void *data, nsapi_size_t size)
Implements modem specific AT command set for sending data.
Definition: ATHandler.h:46
Class for sending AT commands and parsing AT responses.
Definition: ATHandler.h:70
virtual nsapi_error_t socket_accept(nsapi_socket_t server, nsapi_socket_t *handle, SocketAddress *address=0)
Accepts a connection on a TCP socket.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.