Extending the X_NUCLEO_IDW01M1 to allow configuration of the board as an access point

Dependents:   X_NUCLEO_IDW01M1_AP_Test

Fork of X_NUCLEO_IDW01M1 by ST

Committer:
scsims
Date:
Thu Jul 07 13:54:06 2016 +0000
Revision:
22:a1276b7d3b2d
Parent:
18:b265b3b696f1
Added wifi_connected_to_ap extern to indicate when BSSS beacons have been lost/picked up. Also added some debugging to get a better idea as to what's going to and from the SPWF01SA.11 over the UART

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mridup 17:2c47c2aab4a4 1 /* mbed Microcontroller Library
mridup 17:2c47c2aab4a4 2 * Copyright (c) 20015 ARM Limited
mridup 17:2c47c2aab4a4 3 *
mridup 17:2c47c2aab4a4 4 * Licensed under the Apache License, Version 2.0 (the "License");
mridup 17:2c47c2aab4a4 5 * you may not use this file except in compliance with the License.
mridup 17:2c47c2aab4a4 6 * You may obtain a copy of the License at
mridup 17:2c47c2aab4a4 7 *
mridup 17:2c47c2aab4a4 8 * http://www.apache.org/licenses/LICENSE-2.0
mridup 17:2c47c2aab4a4 9 *
mridup 17:2c47c2aab4a4 10 * Unless required by applicable law or agreed to in writing, software
mridup 17:2c47c2aab4a4 11 * distributed under the License is distributed on an "AS IS" BASIS,
mridup 17:2c47c2aab4a4 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mridup 17:2c47c2aab4a4 13 * See the License for the specific language governing permissions and
mridup 17:2c47c2aab4a4 14 * limitations under the License.
mridup 17:2c47c2aab4a4 15 */
mridup 13:cdcc13d78252 16
mridup 13:cdcc13d78252 17 /**
mridup 13:cdcc13d78252 18 ******************************************************************************
mridup 13:cdcc13d78252 19 * @file SpwfInterface.h
mridup 13:cdcc13d78252 20 * @author STMicroelectronics
mridup 13:cdcc13d78252 21 * @brief Header file of the NetworkStack for the SPWF Device
mridup 13:cdcc13d78252 22 ******************************************************************************
mridup 13:cdcc13d78252 23 * @copy
mridup 13:cdcc13d78252 24 *
mridup 13:cdcc13d78252 25 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
mridup 13:cdcc13d78252 26 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
mridup 13:cdcc13d78252 27 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
mridup 13:cdcc13d78252 28 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
mridup 13:cdcc13d78252 29 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
mridup 13:cdcc13d78252 30 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
mridup 13:cdcc13d78252 31 *
mridup 13:cdcc13d78252 32 * <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>
mridup 13:cdcc13d78252 33 ******************************************************************************
mridup 13:cdcc13d78252 34 */
mridup 13:cdcc13d78252 35
mridup 0:dc55f40eb04f 36 #ifndef SPWFSA_INTERFACE_H
mridup 0:dc55f40eb04f 37 #define SPWFSA_INTERFACE_H
mridup 0:dc55f40eb04f 38
mridup 0:dc55f40eb04f 39 #include <vector>
mridup 0:dc55f40eb04f 40 #include <map>
mridup 0:dc55f40eb04f 41 #include "WiFiInterface.h"
mridup 0:dc55f40eb04f 42 #include "SpwfSADevice.h"
mridup 0:dc55f40eb04f 43
mridup 0:dc55f40eb04f 44 #define SPWFSA_SOCKET_COUNT 8
mridup 6:e7a3fca2df10 45 #define SERVER_SOCKET_NO 9
mridup 0:dc55f40eb04f 46
mridup 0:dc55f40eb04f 47 /** SpwfSAInterface class
mridup 5:c83ffd44f40a 48 * Implementation of the NetworkStack for the SPWF Device
mridup 0:dc55f40eb04f 49 */
mridup 5:c83ffd44f40a 50 class SpwfSAInterface : public NetworkStack, public WiFiInterface
mridup 0:dc55f40eb04f 51 {
mridup 0:dc55f40eb04f 52 public:
mridup 0:dc55f40eb04f 53
mridup 0:dc55f40eb04f 54 SpwfSAInterface(PinName tx, PinName rx, PinName rst, PinName wkup, PinName rts, bool debug = false);
mridup 0:dc55f40eb04f 55 virtual ~SpwfSAInterface();
scsims 18:b265b3b696f1 56
scsims 18:b265b3b696f1 57 int start_access_point(
scsims 18:b265b3b696f1 58 const char *ap,
scsims 18:b265b3b696f1 59 const char *pass_phrase,
scsims 18:b265b3b696f1 60 nsapi_security_t security = NSAPI_SECURITY_NONE,
scsims 18:b265b3b696f1 61 int channel_num = 6,
scsims 18:b265b3b696f1 62 unsigned int data_rates = 0x3fffcf);
mridup 0:dc55f40eb04f 63
mridup 0:dc55f40eb04f 64 // Implementation of WiFiInterface
mridup 5:c83ffd44f40a 65 virtual int connect(
mridup 0:dc55f40eb04f 66 const char *ssid,
mridup 0:dc55f40eb04f 67 const char *pass,
mridup 5:c83ffd44f40a 68 nsapi_security_t security = NSAPI_SECURITY_NONE);
mridup 0:dc55f40eb04f 69
mridup 5:c83ffd44f40a 70 virtual int disconnect();
mridup 5:c83ffd44f40a 71 virtual const char *get_mac_address();
mridup 0:dc55f40eb04f 72 void debug(const char * string);
mridup 5:c83ffd44f40a 73
mridup 5:c83ffd44f40a 74 //Implementation of NetworkStack
mridup 5:c83ffd44f40a 75 virtual const char *get_ip_address();
mridup 5:c83ffd44f40a 76
mridup 5:c83ffd44f40a 77 protected:
mridup 5:c83ffd44f40a 78 //Implementation of NetworkStack
mridup 5:c83ffd44f40a 79 virtual int socket_open(void **handle, nsapi_protocol_t proto);
mridup 5:c83ffd44f40a 80 virtual int socket_close(void *handle);
mridup 5:c83ffd44f40a 81 virtual int socket_bind(void *handle, const SocketAddress &address); //not supported
mridup 6:e7a3fca2df10 82 virtual int socket_listen(void *handle, int backlog);
mridup 6:e7a3fca2df10 83 virtual int socket_connect(void *handle, const SocketAddress &address);
mridup 6:e7a3fca2df10 84 virtual int socket_accept(void **handle, void *server);
mridup 5:c83ffd44f40a 85 virtual int socket_send(void *handle, const void *data, unsigned size);
mridup 5:c83ffd44f40a 86 virtual int socket_recv(void *handle, void *data, unsigned size);
mridup 5:c83ffd44f40a 87 virtual int socket_sendto(void *handle, const SocketAddress &address, const void *data, unsigned size);
mridup 5:c83ffd44f40a 88 virtual int socket_recvfrom(void *handle, SocketAddress *address, void *buffer, unsigned size);
mridup 5:c83ffd44f40a 89 virtual void socket_attach(void *handle, void (*callback)(void *), void *data);
mridup 5:c83ffd44f40a 90
mridup 5:c83ffd44f40a 91 private:
mridup 7:0fdd186a7d90 92 int init(void);
scsims 18:b265b3b696f1 93 WiFi_Priv_Mode convert_security(int security);
mridup 0:dc55f40eb04f 94
mridup 0:dc55f40eb04f 95 SpwfSADevice _spwf;
mridup 0:dc55f40eb04f 96 bool _ids[SPWFSA_SOCKET_COUNT];
mridup 6:e7a3fca2df10 97 bool isListening;
mridup 3:fd9d20c4d3f0 98 bool isInitialized;
mridup 5:c83ffd44f40a 99 multimap <char *, vector <uint16_t> > c_table;
mridup 0:dc55f40eb04f 100
mridup 0:dc55f40eb04f 101 };
mridup 0:dc55f40eb04f 102
mridup 0:dc55f40eb04f 103
mridup 0:dc55f40eb04f 104 #endif