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: C027_Support
Dependents: HelloC027Interface U_Blox_DeviceConnector U_Blox_DeviceConnector U-Blox_Client
Fork of LWIPInterface by
Revision 15:21d4f56eb172, committed 2016-04-26
- Comitter:
- geky
- Date:
- Tue Apr 26 20:34:29 2016 +0000
- Parent:
- 14:3d1845f5cd81
- Child:
- 16:eaf31bd133f0
- Commit message:
- Adopt bitwise representation of IP address internally
Changed in this revision
| C027Interface.cpp | Show annotated file Show diff for this revision Revisions of this file |
| C027Interface.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/C027Interface.cpp Thu Apr 21 06:53:31 2016 -0500
+++ b/C027Interface.cpp Tue Apr 26 20:34:29 2016 +0000
@@ -18,11 +18,6 @@
#include "mbed.h"
-static void ipToString(MDMParser::IP ip, char *buffer) {
- sprintf(buffer, IPSTR, IPNUM(ip));
-}
-
-
// C027Interface implementation
C027Interface::C027Interface(const char *simpin, bool debug)
: _debug(debug)
@@ -59,7 +54,7 @@
if (mdmOk) {
// join the internet connection
MDMParser::IP ip = _mdm->join(apn, username, password);
- ipToString(ip, _ip_address);
+ _ip_address.set_ip_bytes(&ip, NSAPI_IPv4);
mdmOk = (ip != NOIP);
}
@@ -77,7 +72,7 @@
const char *C027Interface::get_ip_address()
{
- return _ip_address;
+ return _ip_address.get_ip_address();
}
const char *C027Interface::get_mac_address()
@@ -178,10 +173,10 @@
{
struct c027_socket *socket = (struct c027_socket *)handle;
- MDMParser::IP ip = _mdm->gethostbyname(addr.get_ip_address());
- uint16_t port = addr.get_port();
-
- int sent = _mdm->socketSendTo(socket->socket, ip, port, (const char *)data, size);
+ int sent = _mdm->socketSendTo(socket->socket,
+ *(MDMParser::IP *)addr.get_ip_bytes(), addr.get_port(),
+ (const char *)data, size);
+
if (sent == SOCKET_ERROR) {
return NSAPI_ERROR_DEVICE_ERROR;
}
@@ -205,9 +200,7 @@
}
if (addr) {
- char buffer[NSAPI_IP_SIZE];
- ipToString(ip, buffer);
- addr->set_ip_address(buffer);
+ addr->set_ip_bytes(&ip, NSAPI_IPv4);
addr->set_port(port);
}
--- a/C027Interface.h Thu Apr 21 06:53:31 2016 -0500
+++ b/C027Interface.h Tue Apr 26 20:34:29 2016 +0000
@@ -160,7 +160,7 @@
// Modem object
bool _debug;
MDMSerial *_mdm;
- char _ip_address[NSAPI_IP_SIZE];
+ SocketAddress _ip_address;
char _mac_address[NSAPI_MAC_SIZE];
char _pin[sizeof "1234"];
};
