Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed Servo X_NUCLEO_IKS01A2 X_NUCLEO_IDW01M1v2 NetworkSocketAPI NDefLib MQTT
X_NUCLEO_IDW01M1/SPWFInterface.h
- Committer:
- mridup
- Date:
- 2016-04-08
- Revision:
- 0:cbf8bc43bc9e
- Child:
- 2:ba0531d896f0
File content as of revision 0:cbf8bc43bc9e:
/* SpwfSAInterface implementation of NetworkInterfaceAPI
* Copyright (c) 2015 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SPWFSA_INTERFACE_H
#define SPWFSA_INTERFACE_H
#include <vector>
#include <map>
#include "WiFiInterface.h"
#include "x-nucleo-idw01m1.h"
#define SPWFSA_SOCKET_COUNT 8
/** SpwfSAInterface class
* Implementation of the NetworkInterface for the SPWF Device
*/
class SpwfSAInterface : public WiFiInterface
{
public:
SpwfSAInterface(PinName tx, PinName rx, PinName rst, PinName wkup, PinName rts, bool debug = false);
virtual ~SpwfSAInterface();
// Implementation of WiFiInterface
virtual int32_t connect(
const char *ssid,
const char *pass,
ns_security_t security = NS_SECURITY_NONE);
virtual int32_t disconnect();
// Implementation of NetworkInterface
virtual const char *getIPAddress();
virtual const char *getMACAddress();
virtual SocketInterface *createSocket(ns_protocol_t proto);
virtual void destroySocket(SocketInterface *socket);
int32_t init(void);
void debug(const char * string);
void setid(bool set, int id);
private:
SpwfSADevice _spwf;
bool _ids[SPWFSA_SOCKET_COUNT];
multimap <char *, vector <uint16_t> > c_table;
// Implementation of the SocketInterface for the SpwfSA
class SpwfSASocket : public SocketInterface
{
public:
// SpwfSA specific details
SpwfSADevice *__spwf;
SpwfSAInterface *_itf;
ns_protocol_t _proto;
int _id;
SpwfSASocket(SpwfSAInterface *itf, SpwfSADevice *spwf, ns_protocol_t proto)
: __spwf(spwf), _itf(itf), _proto(proto) {}
virtual ~SpwfSASocket() {
_itf = 0;
__spwf = 0;
}
// Implementation of SocketInterface
virtual int32_t open(const char *ip, uint16_t port);
virtual int32_t close();
virtual int32_t send(const void *data, uint32_t size);
virtual int32_t recv(void *data, uint32_t size);
};
};
/*Function to export singleton instance*/
SpwfSAInterface *createSPWFInstance(void);
#endif