cc
SpwfInterface.h@13:0368732b5b9d, 2016-11-22 (annotated)
- Committer:
- mapellil
- Date:
- Tue Nov 22 14:38:43 2016 +0000
- Revision:
- 13:0368732b5b9d
- Parent:
- 0:907910bfb0b5
- Child:
- 14:4ec13009341c
Added constructor with reset and wakup gpio exposed.
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 | |
mridup | 0:907910bfb0b5 | 45 | /** SpwfSAInterface class |
mridup | 0:907910bfb0b5 | 46 | * Implementation of the NetworkStack for the SPWF Device |
mridup | 0:907910bfb0b5 | 47 | */ |
mridup | 0:907910bfb0b5 | 48 | class SpwfSAInterface : public NetworkStack, public WiFiInterface |
mridup | 0:907910bfb0b5 | 49 | { |
mridup | 0:907910bfb0b5 | 50 | public: |
mapellil | 13:0368732b5b9d | 51 | SpwfSAInterface(PinName tx, PinName rx, bool debug); |
mapellil | 13:0368732b5b9d | 52 | SpwfSAInterface(PinName tx, PinName rx, PinName reset = PC_12, PinName wakeup = PC_8, bool debug = false); |
mridup | 0:907910bfb0b5 | 53 | virtual ~SpwfSAInterface(); |
mridup | 0:907910bfb0b5 | 54 | |
mridup | 0:907910bfb0b5 | 55 | // Implementation of WiFiInterface |
mridup | 0:907910bfb0b5 | 56 | virtual int connect(const char *ssid, |
mridup | 0:907910bfb0b5 | 57 | const char *pass, |
mridup | 0:907910bfb0b5 | 58 | nsapi_security_t security = NSAPI_SECURITY_NONE); |
mridup | 0:907910bfb0b5 | 59 | |
mridup | 0:907910bfb0b5 | 60 | virtual int disconnect(); |
mridup | 0:907910bfb0b5 | 61 | virtual const char *get_mac_address(); |
mridup | 0:907910bfb0b5 | 62 | void debug(const char * string); |
mridup | 0:907910bfb0b5 | 63 | |
mridup | 0:907910bfb0b5 | 64 | //Implementation of NetworkStack |
mridup | 0:907910bfb0b5 | 65 | virtual const char *get_ip_address(); |
mridup | 0:907910bfb0b5 | 66 | |
mridup | 0:907910bfb0b5 | 67 | protected: |
mridup | 0:907910bfb0b5 | 68 | //Implementation of NetworkStack |
mridup | 0:907910bfb0b5 | 69 | virtual int socket_open(void **handle, nsapi_protocol_t proto); |
mridup | 0:907910bfb0b5 | 70 | virtual int socket_close(void *handle); |
mridup | 0:907910bfb0b5 | 71 | virtual int socket_bind(void *handle, const SocketAddress &address); //not supported |
mridup | 0:907910bfb0b5 | 72 | virtual int socket_listen(void *handle, int backlog); |
mridup | 0:907910bfb0b5 | 73 | virtual int socket_connect(void *handle, const SocketAddress &address); |
mridup | 0:907910bfb0b5 | 74 | virtual int socket_accept(void **handle, void *server); |
mridup | 0:907910bfb0b5 | 75 | virtual int socket_send(void *handle, const void *data, unsigned size); |
mridup | 0:907910bfb0b5 | 76 | virtual int socket_recv(void *handle, void *data, unsigned size); |
mridup | 0:907910bfb0b5 | 77 | virtual int socket_sendto(void *handle, const SocketAddress &address, const void *data, unsigned size); |
mridup | 0:907910bfb0b5 | 78 | virtual int socket_recvfrom(void *handle, SocketAddress *address, void *buffer, unsigned size); |
mridup | 0:907910bfb0b5 | 79 | virtual void socket_attach(void *handle, void (*callback)(void *), void *data); |
mapellil | 13:0368732b5b9d | 80 | virtual int setsockopt(void *handle, int level, int optname, const void *optval, unsigned optlen); |
mapellil | 13:0368732b5b9d | 81 | virtual int getsockopt(void *handle, int level, int optname, void *optval, unsigned *optlen); |
mridup | 0:907910bfb0b5 | 82 | |
mridup | 0:907910bfb0b5 | 83 | private: |
mridup | 0:907910bfb0b5 | 84 | int init(void); |
mridup | 0:907910bfb0b5 | 85 | |
mridup | 0:907910bfb0b5 | 86 | SPWFSA01 _spwf; |
mridup | 0:907910bfb0b5 | 87 | bool _ids[SPWFSA_SOCKET_COUNT]; |
mridup | 0:907910bfb0b5 | 88 | bool isListening; |
mapellil | 13:0368732b5b9d | 89 | bool isInitialized; |
mridup | 0:907910bfb0b5 | 90 | }; |
mridup | 0:907910bfb0b5 | 91 | |
mridup | 0:907910bfb0b5 | 92 | |
mridup | 0:907910bfb0b5 | 93 | #endif |