Mistake on this page?
Report an issue in GitHub or email us
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 
27 using namespace std::chrono;
28 
29 namespace mbed {
30 
32 public:
33  RM1000_AT_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device);
34  virtual ~RM1000_AT_CellularStack();
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 
39 protected:
40  virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog);
41 
42  virtual nsapi_error_t socket_accept(nsapi_socket_t server,
43  nsapi_socket_t *handle, SocketAddress *address = 0);
44 
45 protected: // 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 
67  virtual nsapi_error_t create_socket_impl(CellularSocket *socket);
68 
69  virtual nsapi_error_t socket_connect(nsapi_socket_t handle, const SocketAddress &address);
70 
71  virtual nsapi_size_or_error_t socket_sendto_impl(CellularSocket *socket, const SocketAddress &address,
72  const void *data, nsapi_size_t size);
73 
74  virtual nsapi_size_or_error_t socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address,
75  void *buffer, nsapi_size_t size);
76 
77  virtual nsapi_error_t socket_close_impl(int sock_id);
78 
79 private:
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_ */
Class AT_CellularStack.
void * nsapi_socket_t
Opaque handle for network sockets.
Definition: nsapi_types.h:252
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:140
signed int nsapi_size_or_error_t
Type used to represent either a size or error passed through sockets.
Definition: nsapi_types.h:151
SocketAddress class.
Definition: SocketAddress.h:37
Class AT_CellularDevice.
unsigned int nsapi_size_t
Type used to represent the size of data passed through sockets.
Definition: nsapi_types.h:144
Definition: ATHandler.h:46
Class for sending AT commands and parsing AT responses.
Definition: ATHandler.h:68
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.