Socket interface for C027Interface. Implements the NetworkSocketAPI

Dependencies:   C027_Support

Dependents:   HelloC027Interface U_Blox_DeviceConnector U_Blox_DeviceConnector U-Blox_Client

Fork of LWIPInterface by NetworkSocketAPI

Committer:
geky
Date:
Fri Apr 15 16:06:47 2016 +0000
Revision:
12:181a9415736b
Child:
14:3d1845f5cd81
Created C027Interface

Who changed what in which revision?

UserRevisionLine numberNew contents of line
geky 12:181a9415736b 1 /* C027 implementation of NetworkInterfaceAPI
geky 12:181a9415736b 2 * Copyright (c) 2015 ARM Limited
geky 12:181a9415736b 3 *
geky 12:181a9415736b 4 * Licensed under the Apache License, Version 2.0 (the "License");
geky 12:181a9415736b 5 * you may not use this file except in compliance with the License.
geky 12:181a9415736b 6 * You may obtain a copy of the License at
geky 12:181a9415736b 7 *
geky 12:181a9415736b 8 * http://www.apache.org/licenses/LICENSE-2.0
geky 12:181a9415736b 9 *
geky 12:181a9415736b 10 * Unless required by applicable law or agreed to in writing, software
geky 12:181a9415736b 11 * distributed under the License is distributed on an "AS IS" BASIS,
geky 12:181a9415736b 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
geky 12:181a9415736b 13 * See the License for the specific language governing permissions and
geky 12:181a9415736b 14 * limitations under the License.
geky 12:181a9415736b 15 */
geky 12:181a9415736b 16
geky 12:181a9415736b 17 #ifndef C027_INTERFACE_H
geky 12:181a9415736b 18 #define C027_INTERFACE_H
geky 12:181a9415736b 19
geky 12:181a9415736b 20 #include "CellularInterface.h"
geky 12:181a9415736b 21 #include "MDM.h"
geky 12:181a9415736b 22
geky 12:181a9415736b 23
geky 12:181a9415736b 24 /** C027Interface class
geky 12:181a9415736b 25 * Implementation of the NetworkInterface for C027
geky 12:181a9415736b 26 */
geky 12:181a9415736b 27 class C027Interface : public CellularInterface
geky 12:181a9415736b 28 {
geky 12:181a9415736b 29 public:
geky 12:181a9415736b 30 // Lifetime of C027Interface
geky 12:181a9415736b 31 C027Interface(const char *simpin=0, bool debug=false);
geky 12:181a9415736b 32
geky 12:181a9415736b 33 // Implementation of CellularInterface
geky 12:181a9415736b 34 virtual int32_t connect(const char *apn=0, const char *username=0, const char *password=0);
geky 12:181a9415736b 35 virtual int32_t disconnect();
geky 12:181a9415736b 36
geky 12:181a9415736b 37 // Implementation of NetworkInterface
geky 12:181a9415736b 38 virtual const char *getIPAddress();
geky 12:181a9415736b 39 virtual const char *getMACAddress();
geky 12:181a9415736b 40
geky 12:181a9415736b 41 virtual SocketInterface *createSocket(ns_protocol_t proto);
geky 12:181a9415736b 42 virtual void destroySocket(SocketInterface *socket);
geky 12:181a9415736b 43
geky 12:181a9415736b 44 private:
geky 12:181a9415736b 45 // Modem object
geky 12:181a9415736b 46 bool _debug;
geky 12:181a9415736b 47 MDMSerial *_mdm;
geky 12:181a9415736b 48 char _ip_address[NS_IP_SIZE];
geky 12:181a9415736b 49 char _mac_address[NS_MAC_SIZE];
geky 12:181a9415736b 50 char _pin[sizeof "1234"];
geky 12:181a9415736b 51
geky 12:181a9415736b 52 // Implementation of the TCP SocketInterface for C027
geky 12:181a9415736b 53 class C027Socket : public SocketInterface
geky 12:181a9415736b 54 {
geky 12:181a9415736b 55 public:
geky 12:181a9415736b 56
geky 12:181a9415736b 57 C027Socket(MDMSerial *mdm, int socket, MDMParser::IpProtocol proto)
geky 12:181a9415736b 58 : _mdm(mdm), _socket(socket), _proto(proto) {}
geky 12:181a9415736b 59 MDMSerial *_mdm;
geky 12:181a9415736b 60 int _socket;
geky 12:181a9415736b 61 MDMParser::IpProtocol _proto;
geky 12:181a9415736b 62 MDMParser::IP _ip;
geky 12:181a9415736b 63 int _port;
geky 12:181a9415736b 64
geky 12:181a9415736b 65 // Implementation of SocketInterface
geky 12:181a9415736b 66 virtual int32_t open(const char *ip, uint16_t port);
geky 12:181a9415736b 67 virtual int32_t close();
geky 12:181a9415736b 68
geky 12:181a9415736b 69 virtual int32_t send(const void *data, uint32_t size);
geky 12:181a9415736b 70 virtual int32_t recv(void *data, uint32_t size);
geky 12:181a9415736b 71 };
geky 12:181a9415736b 72 };
geky 12:181a9415736b 73
geky 12:181a9415736b 74
geky 12:181a9415736b 75 #endif