cc
SpwfInterface.h@16:c8697141ce44, 2017-01-13 (annotated)
- Committer:
- mapellil
- Date:
- Fri Jan 13 14:37:49 2017 +0000
- Revision:
- 16:c8697141ce44
- Parent:
- 15:0a075334e0e9
added get_time API
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mridup | 0:907910bfb0b5 | 1 | /* mbed Microcontroller Library |
mridup | 0:907910bfb0b5 | 2 | * Copyright (c) 20015 ARM Limited |
mridup | 0:907910bfb0b5 | 3 | * |
mridup | 0:907910bfb0b5 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mridup | 0:907910bfb0b5 | 5 | * you may not use this file except in compliance with the License. |
mridup | 0:907910bfb0b5 | 6 | * You may obtain a copy of the License at |
mridup | 0:907910bfb0b5 | 7 | * |
mridup | 0:907910bfb0b5 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mridup | 0:907910bfb0b5 | 9 | * |
mridup | 0:907910bfb0b5 | 10 | * Unless required by applicable law or agreed to in writing, software |
mridup | 0:907910bfb0b5 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mridup | 0:907910bfb0b5 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mridup | 0:907910bfb0b5 | 13 | * See the License for the specific language governing permissions and |
mridup | 0:907910bfb0b5 | 14 | * limitations under the License. |
mridup | 0:907910bfb0b5 | 15 | */ |
mridup | 0:907910bfb0b5 | 16 | |
mridup | 0:907910bfb0b5 | 17 | /** |
mridup | 0:907910bfb0b5 | 18 | ****************************************************************************** |
mridup | 0:907910bfb0b5 | 19 | * @file SpwfInterface.h |
mridup | 0:907910bfb0b5 | 20 | * @author STMicroelectronics |
mridup | 0:907910bfb0b5 | 21 | * @brief Header file of the NetworkStack for the SPWF Device |
mridup | 0:907910bfb0b5 | 22 | ****************************************************************************** |
mridup | 0:907910bfb0b5 | 23 | * @copy |
mridup | 0:907910bfb0b5 | 24 | * |
mridup | 0:907910bfb0b5 | 25 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
mridup | 0:907910bfb0b5 | 26 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE |
mridup | 0:907910bfb0b5 | 27 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY |
mridup | 0:907910bfb0b5 | 28 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING |
mridup | 0:907910bfb0b5 | 29 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE |
mridup | 0:907910bfb0b5 | 30 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
mridup | 0:907910bfb0b5 | 31 | * |
mridup | 0:907910bfb0b5 | 32 | * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2> |
mridup | 0:907910bfb0b5 | 33 | ****************************************************************************** |
mridup | 0:907910bfb0b5 | 34 | */ |
mridup | 0:907910bfb0b5 | 35 | |
mridup | 0:907910bfb0b5 | 36 | #ifndef SPWFSA_INTERFACE_H |
mridup | 0:907910bfb0b5 | 37 | #define SPWFSA_INTERFACE_H |
mridup | 0:907910bfb0b5 | 38 | |
mridup | 0:907910bfb0b5 | 39 | #include "WiFiInterface.h" |
mridup | 0:907910bfb0b5 | 40 | #include "SPWFSA01.h" |
mridup | 0:907910bfb0b5 | 41 | |
mridup | 0:907910bfb0b5 | 42 | #define SPWFSA_SOCKET_COUNT 8 |
mridup | 0:907910bfb0b5 | 43 | #define SERVER_SOCKET_NO 9 |
mridup | 0:907910bfb0b5 | 44 | |
mapellil | 14:4ec13009341c | 45 | |
mridup | 0:907910bfb0b5 | 46 | /** SpwfSAInterface class |
mridup | 0:907910bfb0b5 | 47 | * Implementation of the NetworkStack for the SPWF Device |
mridup | 0:907910bfb0b5 | 48 | */ |
mridup | 0:907910bfb0b5 | 49 | class SpwfSAInterface : public NetworkStack, public WiFiInterface |
mridup | 0:907910bfb0b5 | 50 | { |
mridup | 0:907910bfb0b5 | 51 | public: |
mapellil | 13:0368732b5b9d | 52 | SpwfSAInterface(PinName tx, PinName rx, bool debug); |
mapellil | 13:0368732b5b9d | 53 | SpwfSAInterface(PinName tx, PinName rx, PinName reset = PC_12, PinName wakeup = PC_8, bool debug = false); |
mridup | 0:907910bfb0b5 | 54 | virtual ~SpwfSAInterface(); |
mridup | 0:907910bfb0b5 | 55 | |
mridup | 0:907910bfb0b5 | 56 | // Implementation of WiFiInterface |
mridup | 0:907910bfb0b5 | 57 | virtual int connect(const char *ssid, |
mridup | 0:907910bfb0b5 | 58 | const char *pass, |
mridup | 0:907910bfb0b5 | 59 | nsapi_security_t security = NSAPI_SECURITY_NONE); |
mridup | 0:907910bfb0b5 | 60 | virtual int disconnect(); |
mapellil | 14:4ec13009341c | 61 | virtual const char *get_mac_address(); |
mapellil | 14:4ec13009341c | 62 | |
mapellil | 14:4ec13009341c | 63 | // implementation of secure sockets |
mapellil | 15:0a075334e0e9 | 64 | virtual void set_secure_mode(void); // to be called before socket creation if TLS/SSL is required |
mapellil | 15:0a075334e0e9 | 65 | virtual void set_unsecure_mode(void); // to be called after socket creation to set unsecure mode (deft) |
mapellil | 16:c8697141ce44 | 66 | virtual bool isSecure_mode(void); |
mapellil | 16:c8697141ce44 | 67 | virtual int set_time(time_t ctTime); // TLS/SSL requires correct system time to check certificates |
mapellil | 16:c8697141ce44 | 68 | virtual int get_time(time_t *ctTime); |
mapellil | 16:c8697141ce44 | 69 | virtual int set_TLS_certificate(char * cert, unsigned int size, CertType_t type); // root cert in PEM format |
mapellil | 16:c8697141ce44 | 70 | virtual int set_TLS_SRV_domain(char * domain, CertType_t type); // secure server domain |
mapellil | 16:c8697141ce44 | 71 | virtual int clean_TLS_certificate(CertType_t type); |
mridup | 0:907910bfb0b5 | 72 | void debug(const char * string); |
mridup | 0:907910bfb0b5 | 73 | |
mridup | 0:907910bfb0b5 | 74 | //Implementation of NetworkStack |
mridup | 0:907910bfb0b5 | 75 | virtual const char *get_ip_address(); |
mridup | 0:907910bfb0b5 | 76 | |
mridup | 0:907910bfb0b5 | 77 | protected: |
mridup | 0:907910bfb0b5 | 78 | //Implementation of NetworkStack |
mridup | 0:907910bfb0b5 | 79 | virtual int socket_open(void **handle, nsapi_protocol_t proto); |
mridup | 0:907910bfb0b5 | 80 | virtual int socket_close(void *handle); |
mridup | 0:907910bfb0b5 | 81 | virtual int socket_bind(void *handle, const SocketAddress &address); //not supported |
mridup | 0:907910bfb0b5 | 82 | virtual int socket_listen(void *handle, int backlog); |
mridup | 0:907910bfb0b5 | 83 | virtual int socket_connect(void *handle, const SocketAddress &address); |
mridup | 0:907910bfb0b5 | 84 | virtual int socket_accept(void **handle, void *server); |
mridup | 0:907910bfb0b5 | 85 | virtual int socket_send(void *handle, const void *data, unsigned size); |
mridup | 0:907910bfb0b5 | 86 | virtual int socket_recv(void *handle, void *data, unsigned size); |
mridup | 0:907910bfb0b5 | 87 | virtual int socket_sendto(void *handle, const SocketAddress &address, const void *data, unsigned size); |
mridup | 0:907910bfb0b5 | 88 | virtual int socket_recvfrom(void *handle, SocketAddress *address, void *buffer, unsigned size); |
mridup | 0:907910bfb0b5 | 89 | virtual void socket_attach(void *handle, void (*callback)(void *), void *data); |
mapellil | 13:0368732b5b9d | 90 | virtual int setsockopt(void *handle, int level, int optname, const void *optval, unsigned optlen); |
mapellil | 13:0368732b5b9d | 91 | virtual int getsockopt(void *handle, int level, int optname, void *optval, unsigned *optlen); |
mridup | 0:907910bfb0b5 | 92 | |
mridup | 0:907910bfb0b5 | 93 | private: |
mridup | 0:907910bfb0b5 | 94 | int init(void); |
mridup | 0:907910bfb0b5 | 95 | |
mridup | 0:907910bfb0b5 | 96 | SPWFSA01 _spwf; |
mridup | 0:907910bfb0b5 | 97 | bool _ids[SPWFSA_SOCKET_COUNT]; |
mridup | 0:907910bfb0b5 | 98 | bool isListening; |
mapellil | 13:0368732b5b9d | 99 | bool isInitialized; |
mapellil | 14:4ec13009341c | 100 | bool isSecure; |
mridup | 0:907910bfb0b5 | 101 | }; |
mridup | 0:907910bfb0b5 | 102 | |
mridup | 0:907910bfb0b5 | 103 | |
mridup | 0:907910bfb0b5 | 104 | #endif |