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

Revision:
17:3f1e33e638a4
Parent:
16:eaf31bd133f0
Child:
20:be7a08046b6d
--- a/C027Interface.h	Thu Feb 02 16:17:35 2017 +0000
+++ b/C027Interface.h	Thu Feb 02 21:16:38 2017 +0000
@@ -32,6 +32,23 @@
      * @param debug     Enable debugging
      */
     C027Interface(const char *simpin=0, bool debug=false);
+    
+    /** Set the cellular network APN and credentials
+     *
+     *  @param apn      Optional name of the network to connect to
+     *  @param user     Optional username for the APN
+     *  @param pass     Optional password fot the APN
+     *  @return         0 on success, negative error code on failure
+     */
+    virtual nsapi_error_t set_credentials(const char *apn, const char *username = 0, const char *password = 0);
+    
+    /** Start the interface
+     *
+     *  Attempts to connect to a cellular network based on supplied credentials
+     *
+     *  @return         0 on success, negative error code on failure
+     */
+    virtual nsapi_error_t connect();
 
     /** Start the interface
      *
@@ -40,7 +57,7 @@
      *  @param password Optional password for your APN 
      *  @return         0 on success, negative error code on failure
      */
-    virtual int connect(const char *apn = 0, const char *username = 0, const char *password = 0);
+    virtual nsapi_error_t connect(const char *apn, const char *username = 0, const char *password = 0);
 
     /** Stop the interface
      *  @return             0 on success, negative on failure
@@ -102,8 +119,8 @@
      *  @note This call is not-blocking, if this call would block, must
      *        immediately return NSAPI_ERROR_WOULD_WAIT
      */
-    virtual int socket_accept(void **handle, void *server);
-
+    virtual nsapi_error_t socket_accept(nsapi_socket_t server,
+            nsapi_socket_t *handle, SocketAddress *address=0);
     /** Send data to the remote host
      *  @param handle       Socket handle
      *  @param data         The buffer to send to the host
@@ -172,6 +189,9 @@
     SocketAddress _ip_address;
     char _mac_address[NSAPI_MAC_SIZE];
     char _pin[sizeof "1234"];
+    char _apn[50];
+    char _username[25];
+    char _password[25];
     Thread _thread;
     void (*_callback)(void *); void *_data;
     void _run();