Fork of KL46Z Wifi version. Moved to KL25Z as umbrella stand now requires 2 SPIs, thus requires 46z.

Dependencies:   WIZnet_Library_ASE mbed nanoservice_client_1_12

Fork of Trenton_Doormat_FRDM-KL25Z_ETH by Eric Gowland

Revision:
17:8ca4a5801430
Parent:
16:3fb612af0dc5
Child:
23:7304a998959b
--- a/nsdl_support.cpp	Fri Apr 04 15:17:07 2014 +0000
+++ b/nsdl_support.cpp	Mon Apr 07 09:29:11 2014 +0000
@@ -3,18 +3,11 @@
 #include "mbed.h"
 #include "nsdl_support.h"
 #include "mbed.h"
-#include "rtos.h"
 #include "WiflyInterface.h"
 
 extern Endpoint nsp;
 extern UDPSocket server;
-//extern TCPSocketConnection server;
-extern char endpoint_name[16];
-extern uint8_t ep_type[];
-extern uint8_t lifetime_ptr[];
 
-/* The number of seconds between NSP registration messages */
-#define RD_UPDATE_PERIOD  300
 
 void *nsdl_alloc(uint16_t size)
 {
@@ -88,22 +81,6 @@
 
 static uint8_t tx_cb(sn_nsdl_capab_e protocol, uint8_t *data_ptr, uint16_t data_len, sn_nsdl_addr_s *address_ptr)
 {
-    /*
-    //TCP
-    int buffer_len = data_len+2;
-    printf("TX callback! Sending %d bytes", buffer_len);
-    char buffer[buffer_len];
-    buffer[0] = data_len >> 8;
-    buffer[1] = data_len & 0xFF;
-    memcpy(buffer+2, data_ptr, data_len);
-    
-    //if(cellular->write((char*)buffer, (int)buffer_len, 1000) != buffer_len)
-    if(server.send((char*)data_ptr, data_len) != data_len)
-        printf("Sending failed");
-
-    return 1;
-    */
-
     //UDP
     printf("TX callback!\n\rSending %d bytes\r\n", data_len);
     if(server.sendTo(nsp, (char*)data_ptr, data_len) != data_len)
@@ -119,22 +96,7 @@
     return 0;
 }
 
-static void registration_update_thread(void const *args)
-{
-    sn_nsdl_ep_parameters_s *endpoint_ptr = NULL;
 
-    while(true)
-    {
-        wait(RD_UPDATE_PERIOD);
-        printf("NSP attempt re-register...\r\n");
-        endpoint_ptr = nsdl_init_register_endpoint(endpoint_ptr, (uint8_t*)endpoint_name, ep_type, lifetime_ptr);
-        if(sn_nsdl_register_endpoint(endpoint_ptr) != 0)
-            printf("NSP re-registering failed\r\n");
-        else
-            printf("NSP re-registering OK\r\n");
-        nsdl_clean_register_endpoint(&endpoint_ptr);
-    }
-}
 
 void nsdl_init()
 {
@@ -153,52 +115,5 @@
     set_NSP_address(nsp_addr, 5683, SN_NSDL_ADDRESS_TYPE_IPV4);
 }
 
-void nsdl_event_loop()
-{
-    //Thread registration_thread(registration_update_thread);
-
-    sn_nsdl_addr_s received_packet_address;
-    uint8_t received_address[4];
-    int8_t nsdl_result = 0;
-    //UDP
-    char buffer[1024];
-    //TCP
-    //char buffer[2048];
-    Endpoint from;
-
-    memset(&received_packet_address, 0, sizeof(sn_nsdl_addr_s));
-    received_packet_address.addr_ptr = received_address;
-
-    while(1)
-    {
-        //UDP
-        int n = server.receiveFrom(from, buffer, sizeof(buffer));
-        //TCP
-        //int n = server.receive(buffer, sizeof(buffer));
-        if (n < 0)
-        {
-            printf("Socket error\n\r");
-        }
-        else
-        { 
-        /*
-            //TCP
-            uint16_t len = 0;
-            if (n > 2) {
-                len = 256 * buffer[0] + buffer[1]; 
-                printf("CoAP length header = %d bytes", len);
-                sn_nsdl_process_coap((uint8_t*)buffer+2, len, &received_packet_address);
-            }
-            */
-        
-            //UDP
-            wait(0.25); //Waiting seems to increase reliability of comms...
-            printf("Received %d bytes\r\n", n);
-            nsdl_result = sn_nsdl_process_coap((uint8_t*)buffer, n, &received_packet_address);
-            printf("Processed COAP Packet: %d\r\n", nsdl_result);
-        
-        }
-    }
-}
 
             
\ No newline at end of file