Mbed OS Reference
Loading...
Searching...
No Matches
RM1000_AT_CellularStack.h
1/*
2 * Copyright (c) 2018, 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#ifndef RM1000_AT_CELLULARSTACK_H_
18#define RM1000_AT_CELLULARSTACK_H_
19
20#include <chrono>
21
22#include "AT_CellularStack.h"
23#include "CellularUtil.h"
24#include "mbed_wait_api.h"
25#include "drivers/Timer.h"
26
27using namespace std::chrono;
28
29namespace mbed {
30
32public:
33 RM1000_AT_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device);
35
36 virtual nsapi_error_t gethostbyname(const char *host,
37 SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC, const char *interface_name = NULL);
38
39protected:
40 virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog);
41
43 nsapi_socket_t *handle, SocketAddress *address = 0);
44
45protected: // AT_CellularStack
46
47 /** The profile to use (on board the modem).
48 */
49#define PROFILE "0"
50
51 /** Socket "unused" value.
52 */
53 static const int SOCKET_UNUSED = -1;
54
55 /** Socket timeout value in milliseconds.
56 * Note: the sockets layer above will retry the
57 * call to the functions here when they return NSAPI_ERROR_WOULD_BLOCK
58 * and the user has set a larger timeout or full blocking.
59 */
60 static constexpr seconds SOCKET_TIMEOUT = 1s;
61
62 /** The maximum number of bytes in a packet that can be write/read from
63 * the AT interface in one go.
64 */
65 static const int RM1000_MAX_PACKET_SIZE = 1024;
66
68
70
72 const void *data, nsapi_size_t size);
73
75 void *buffer, nsapi_size_t size);
76
77 virtual nsapi_error_t socket_close_impl(int sock_id);
78
79private:
80 // URC handlers
81 void RUSORCV_URC();
82 void RUSOCL_URC();
83
84 /** Clear out the storage for a socket.
85 *
86 * @param id Cellular Socket.
87 * @return None
88 */
89 void clear_socket(CellularSocket *socket);
90};
91} // namespace mbed
92#endif /* RM1000_AT_CELLULARSTACK_H_ */
SocketAddress class.
Definition: SocketAddress.h:37
Class AT_CellularDevice.
Class AT_CellularStack.
Class for sending AT commands and parsing AT responses.
Definition: ATHandler.h:68
virtual nsapi_error_t create_socket_impl(CellularSocket *socket)
Implements modem specific AT command set for creating socket.
virtual nsapi_error_t socket_connect(nsapi_socket_t handle, const SocketAddress &address)
Connects TCP socket to a remote host.
virtual nsapi_error_t gethostbyname(const char *host, SocketAddress *address, nsapi_version_t version=NSAPI_UNSPEC, const char *interface_name=NULL)
Translates a hostname to an IP address with specific version.
virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog)
Listen for connections on a TCP socket.
virtual nsapi_error_t socket_accept(nsapi_socket_t server, nsapi_socket_t *handle, SocketAddress *address=0)
Accepts a connection on a TCP socket.
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.
static const int RM1000_MAX_PACKET_SIZE
The maximum number of bytes in a packet that can be write/read from the AT interface in one go.
virtual nsapi_error_t socket_close_impl(int sock_id)
Implements modem specific AT command set for socket closing.
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.
static const int SOCKET_UNUSED
Socket "unused" value.
static constexpr seconds SOCKET_TIMEOUT
Socket timeout value in milliseconds.
signed int nsapi_size_or_error_t
Type used to represent either a size or error passed through sockets.
Definition: nsapi_types.h:153
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:142
void * nsapi_socket_t
Opaque handle for network sockets.
Definition: nsapi_types.h:254
unsigned int nsapi_size_t
Type used to represent the size of data passed through sockets.
Definition: nsapi_types.h:146
@ NSAPI_UNSPEC
Definition: nsapi_types.h:230