daily pastebin goal
24%
SHARE
TWEET

Untitled

a guest Jan 23rd, 2016 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <ESP8266WiFi.h>
  2. #include <ESP8266HTTPClient.h>
  3. #include "Esp.h"
  4.  
  5. const char* ssid     = "ZON-6860";
  6. const char* password = "b90979db9305";
  7.  
  8.  
  9. // Expose Espressif SDK functionality - wrapped in ifdef so that it still
  10. // compiles on other platforms
  11. #ifdef ESP8266
  12. extern "C" {
  13. #include "user_interface.h"
  14.  
  15.  
  16.  
  17. }
  18. #endif
  19.  
  20. void setup() {
  21.     Serial.begin(115200);
  22.  
  23. void user_ping_recv(void *arg, void *pdata){
  24.     struct ping_resp *ping_resp = pdata;
  25.     struct ping_option *ping_opt = arg;
  26.  
  27.     if (ping_resp->ping_err == -1)
  28.         os_printf("ping host fail \r\n");
  29.     else
  30.         os_printf("ping recv: byte = %d, time = %d ms \r\n",ping_resp->bytes,ping_resp->resp_time);
  31.  
  32. }
  33.  
  34. void user_ping_sent(void *arg, void *pdata){
  35.     os_printf("user ping finish \r\n");
  36. }
  37.  
  38.  
  39. void user_test_ping(void){
  40.     struct ping_option *ping_opt = NULL;
  41.     const char* ping_ip = "192.168.1.114";
  42.  
  43.     ping_opt = (struct ping_option *)os_zalloc(sizeof(struct ping_option));
  44.  
  45.     ping_opt->count = 10;    //  try to ping how many times
  46.     ping_opt->coarse_time = 2;  // ping interval
  47.     ping_opt->ip = ipaddr_addr(ping_ip);
  48.  
  49.     ping_regist_recv(ping_opt,user_ping_recv);
  50.     ping_regist_sent(ping_opt,user_ping_sent);
  51.  
  52.     ping_start(ping_opt);
  53.  
  54. }
  55.  
  56.   delay(10);
  57.  
  58.   // We start by connecting to a WiFi network
  59.  
  60.   Serial.println();
  61.   Serial.println();
  62.   Serial.print("Connecting to ");
  63.   Serial.println(ssid);
  64.  
  65.   WiFi.begin(ssid, password);
  66.  
  67.   while (WiFi.status() != WL_CONNECTED) {
  68.     delay(500);
  69.     Serial.print(".");
  70.   }
  71.  
  72.   Serial.println("");
  73.   Serial.println("WiFi connected");  
  74.   Serial.println("IP address: ");
  75.   Serial.println(WiFi.localIP());
  76. }
  77.  
  78. void loop() {
  79.   // Call Espressif SDK functionality - wrapped in ifdef so that it still
  80.   // compiles on other platforms
  81. #ifdef ESP8266
  82.   Serial.print("wifi_station_get_hostname: ");
  83.   Serial.println(wifi_station_get_hostname());
  84.   Serial.println(ESP.getChipId());
  85.  
  86.  
  87.  
  88. #endif
  89.  
  90.   Serial.println(WiFi.localIP());
  91.  
  92.  
  93.  
  94.  
  95.  
  96.   delay(1000);
  97. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top