C027Interface

Dependencies:   C027_Support

Fork of C027Interface by NetworkSocketAPI

Files at this revision

API Documentation at this revision

Comitter:
sarahmarshy
Date:
Thu Feb 02 16:17:35 2017 +0000
Parent:
15:21d4f56eb172
Commit message:
socket_attach and get_stack functions implemented

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
C027_Support.lib Show annotated file Show diff for this revision Revisions of this file
--- a/C027Interface.cpp	Tue Apr 26 20:34:29 2016 +0000
+++ b/C027Interface.cpp	Thu Feb 02 16:17:35 2017 +0000
@@ -207,6 +207,17 @@
     return recv;
 }
 
+void C027Interface::_run()
+{
+    while (true) {
+        _callback(_data);
+        wait(0.25f);
+    }
+}
+
 void C027Interface::socket_attach(void *handle, void (*callback)(void *), void *data)
 {
+    _callback = callback;
+    _data = data;
+    _thread.start(this, &C027Interface::_run);
 }
--- a/C027Interface.h	Tue Apr 26 20:34:29 2016 +0000
+++ b/C027Interface.h	Thu Feb 02 16:17:35 2017 +0000
@@ -155,6 +155,15 @@
      *  @note Callback may be called in an interrupt context.
      */
     virtual void socket_attach(void *handle, void (*callback)(void *), void *data);
+    
+     /** Provide access to the NetworkStack object
+     *
+     *  @return The underlying NetworkStack object
+     */
+     virtual NetworkStack *get_stack()
+     {
+         return this;
+     }
 
 private:
     // Modem object
@@ -163,6 +172,9 @@
     SocketAddress _ip_address;
     char _mac_address[NSAPI_MAC_SIZE];
     char _pin[sizeof "1234"];
+    Thread _thread;
+    void (*_callback)(void *); void *_data;
+    void _run();
 };
 
 #endif
--- a/C027_Support.lib	Tue Apr 26 20:34:29 2016 +0000
+++ b/C027_Support.lib	Thu Feb 02 16:17:35 2017 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/NetworkSocketAPI/code/C027_Support/#596bcb599ac1
+https://developer.mbed.org/teams/NetworkSocketAPI/code/C027_Support/#0d91c7fe072b