Dmitry Bursov / Mbed OS mbed-os-ethattach-fault
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 
00002 #include "EthernetInterface.h"
00003 #include "mbed.h"
00004 #include "nsapi_types.h"
00005 
00006 // Network interface
00007 EthernetInterface eth;
00008 
00009 void status_callback(nsapi_event_t status, intptr_t param)
00010 {
00011     printf("Connection status changed!\r\n");
00012     switch(param) {
00013         case NSAPI_STATUS_LOCAL_UP:
00014             printf("Local IP address set!\r\n");
00015             break;
00016         case NSAPI_STATUS_GLOBAL_UP:
00017             printf("Global IP address set!\r\n");
00018             break;
00019         case NSAPI_STATUS_DISCONNECTED:
00020             printf("No connection to network!\r\n");
00021             break;
00022         case NSAPI_STATUS_CONNECTING:
00023             printf("Connecting to network!\r\n");
00024             break;
00025         default:
00026             printf("Not supported");
00027             break;
00028     }
00029 }
00030 void onemorethread(void)
00031 {
00032     while (1)
00033     {
00034      //   Thread::wait(10);   
00035     }    
00036 }
00037 
00038 int main()
00039 {
00040     printf("Connecting...\n");
00041     eth.attach(&status_callback);
00042     eth.set_network("192.168.1.200","255.255.255.0","192.168.1.1");
00043     eth.connect();
00044     Thread onemore;
00045     onemore.start(onemorethread);
00046     while(1)
00047     {
00048         Thread::wait(10);
00049     }
00050  }