I added functionality to get the RSSI, BER, and Cell Neighbor for reporting connection issues to M2X
Dependencies: WncControllerK64F
Socket/UDPSocket.h@16:8a4105d407d3, 2016-11-14 (annotated)
- Committer:
- JMF
- Date:
- Mon Nov 14 21:15:42 2016 +0000
- Revision:
- 16:8a4105d407d3
- Parent:
- 1:e511ea8d39d5
updated to ensure it builds with TLS by correcting config defaults.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JMF | 1:e511ea8d39d5 | 1 | /* ===================================================================== |
JMF | 1:e511ea8d39d5 | 2 | Copyright © 2016, Avnet (R) |
JMF | 1:e511ea8d39d5 | 3 | |
JMF | 1:e511ea8d39d5 | 4 | Contributors: |
JMF | 1:e511ea8d39d5 | 5 | * James M Flynn, www.em.avnet.com |
JMF | 1:e511ea8d39d5 | 6 | |
JMF | 1:e511ea8d39d5 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); |
JMF | 1:e511ea8d39d5 | 8 | you may not use this file except in compliance with the License. |
JMF | 1:e511ea8d39d5 | 9 | You may obtain a copy of the License at |
JMF | 1:e511ea8d39d5 | 10 | |
JMF | 1:e511ea8d39d5 | 11 | http://www.apache.org/licenses/LICENSE-2.0 |
JMF | 1:e511ea8d39d5 | 12 | |
JMF | 1:e511ea8d39d5 | 13 | Unless required by applicable law or agreed to in writing, |
JMF | 1:e511ea8d39d5 | 14 | software distributed under the License is distributed on an |
JMF | 1:e511ea8d39d5 | 15 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, |
JMF | 1:e511ea8d39d5 | 16 | either express or implied. See the License for the specific |
JMF | 1:e511ea8d39d5 | 17 | language governing permissions and limitations under the License. |
JMF | 1:e511ea8d39d5 | 18 | |
JMF | 1:e511ea8d39d5 | 19 | @file WNCInterface.cpp |
JMF | 1:e511ea8d39d5 | 20 | @version 1.0 |
JMF | 1:e511ea8d39d5 | 21 | @date Sept 2016 |
JMF | 1:e511ea8d39d5 | 22 | |
JMF | 1:e511ea8d39d5 | 23 | ======================================================================== */ |
JMF | 1:e511ea8d39d5 | 24 | |
JMF | 1:e511ea8d39d5 | 25 | |
JMF | 1:e511ea8d39d5 | 26 | #ifndef UDPSOCKET_H |
JMF | 1:e511ea8d39d5 | 27 | #define UDPSOCKET_H |
JMF | 1:e511ea8d39d5 | 28 | |
JMF | 1:e511ea8d39d5 | 29 | #include "Socket.h" |
JMF | 1:e511ea8d39d5 | 30 | #include "Endpoint.h" |
JMF | 1:e511ea8d39d5 | 31 | |
JMF | 1:e511ea8d39d5 | 32 | /** |
JMF | 1:e511ea8d39d5 | 33 | UDP Socket |
JMF | 1:e511ea8d39d5 | 34 | */ |
JMF | 1:e511ea8d39d5 | 35 | class UDPSocket : public Socket, public WNCInterface { |
JMF | 1:e511ea8d39d5 | 36 | |
JMF | 1:e511ea8d39d5 | 37 | public: |
JMF | 1:e511ea8d39d5 | 38 | UDPSocket(); |
JMF | 1:e511ea8d39d5 | 39 | ~UDPSocket(); |
JMF | 1:e511ea8d39d5 | 40 | |
JMF | 1:e511ea8d39d5 | 41 | int init(void); |
JMF | 1:e511ea8d39d5 | 42 | |
JMF | 1:e511ea8d39d5 | 43 | /** sendTo - send data to the remote host. |
JMF | 1:e511ea8d39d5 | 44 | \param remote, a pointer to the endpoint (class) |
JMF | 1:e511ea8d39d5 | 45 | \param packet, pointer to the buffer to send to the host. |
JMF | 1:e511ea8d39d5 | 46 | \param length The length of the buffer to send. |
JMF | 1:e511ea8d39d5 | 47 | \return the number of written bytes on success (>=0) or -1 on failure |
JMF | 1:e511ea8d39d5 | 48 | */ |
JMF | 1:e511ea8d39d5 | 49 | int sendTo(Endpoint &remote, char *packet, int length); |
JMF | 1:e511ea8d39d5 | 50 | |
JMF | 1:e511ea8d39d5 | 51 | /** receiveFrom - receive data from the remote host. |
JMF | 1:e511ea8d39d5 | 52 | \param remote, a pointer to the endpoint (class) |
JMF | 1:e511ea8d39d5 | 53 | \param packet, The buffer in which to store the data received from the host. |
JMF | 1:e511ea8d39d5 | 54 | \param length The maximum length of the buffer. |
JMF | 1:e511ea8d39d5 | 55 | \return the number of received bytes on success (>=0) or -1 on failure |
JMF | 1:e511ea8d39d5 | 56 | */ |
JMF | 1:e511ea8d39d5 | 57 | int receiveFrom(Endpoint &remote, char *buffer, int length); |
JMF | 1:e511ea8d39d5 | 58 | |
JMF | 1:e511ea8d39d5 | 59 | /** Set blocking or non-blocking mode of the socket and a timeout |
JMF | 1:e511ea8d39d5 | 60 | \param blocking true for blocking mode, false for non-blocking mode. |
JMF | 1:e511ea8d39d5 | 61 | \return none. |
JMF | 1:e511ea8d39d5 | 62 | */ |
JMF | 1:e511ea8d39d5 | 63 | void set_blocking (bool blocking, unsigned int timeout=1500); |
JMF | 1:e511ea8d39d5 | 64 | |
JMF | 1:e511ea8d39d5 | 65 | /** Close the socket |
JMF | 1:e511ea8d39d5 | 66 | \param none |
JMF | 1:e511ea8d39d5 | 67 | \return 0 if closed successfully, -1 on failure |
JMF | 1:e511ea8d39d5 | 68 | */ |
JMF | 1:e511ea8d39d5 | 69 | int close(void); |
JMF | 1:e511ea8d39d5 | 70 | |
JMF | 1:e511ea8d39d5 | 71 | private: |
JMF | 1:e511ea8d39d5 | 72 | bool _is_blocking; |
JMF | 1:e511ea8d39d5 | 73 | unsigned int _btimeout; |
JMF | 1:e511ea8d39d5 | 74 | }; |
JMF | 1:e511ea8d39d5 | 75 | |
JMF | 1:e511ea8d39d5 | 76 | #endif |
JMF | 1:e511ea8d39d5 | 77 |