SHARE
TWEET

Untitled

a guest Jul 8th, 2015 266 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "mem.h"
  2. #include "osapi.h"
  3. #include "os_type.h"
  4. #include "user_interface.h"
  5.  
  6. os_event_t *queue;
  7. void get_status(os_event_t *e);
  8.  
  9. ICACHE_FLASH_ATTR void my_init_done_cb() {
  10.   struct station_config conf;
  11.   strcpy(conf.ssid, "DeiWolke");
  12.   strcpy(conf.password, "DeiWolke");
  13.   //strcpy(conf.ssid, "TehCloud");
  14.   //conf.password[0] = '\0';
  15.   conf.bssid_set = 0;
  16.   ETS_UART_INTR_DISABLE();
  17.   wifi_station_set_config(&conf);
  18.   wifi_station_connect();
  19.   ETS_UART_INTR_ENABLE();
  20.   wifi_station_dhcpc_start();
  21.  
  22.   queue = (os_event_t*) os_malloc(sizeof(os_event_t) * 5);
  23.   system_os_task(get_status, 0, queue, 5);
  24.   system_os_post(0, 0, 0);
  25. }
  26.  
  27. int x = 0;
  28.  
  29. ICACHE_FLASH_ATTR void get_status(os_event_t *e) {
  30.   x++;
  31.   if (x % 100 == 0) {
  32.     int status = wifi_station_get_connect_status();
  33.     int32 free = system_get_free_heap_size();
  34.     os_printf("wifi status: %d %u\n", status, free);
  35.   }
  36.   os_delay_us(10000);
  37.   system_os_post(0, 0, 0);
  38. }
  39.  
  40. ICACHE_FLASH_ATTR void user_init() {
  41.   wifi_set_opmode(STATION_MODE);
  42.   wifi_station_set_auto_connect(FALSE);
  43.   uart_div_modify(0, UART_CLK_FREQ / 115200);
  44.  
  45.   system_init_done_cb(my_init_done_cb);
  46. }
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