autoconnect.pp 832 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. program autoconnect;
  2. {$mode objfpc}
  3. uses
  4. ctypes, nds9, dswifi9;
  5. var
  6. ip, gateway, mask, dns1, dns2: in_addr;
  7. keys: integer;
  8. begin
  9. consoleDemoInit(); //setup the sub screen for printing
  10. iprintf(#10#10#9'Simple Wifi Connection Demo'#10#10);
  11. iprintf('Connecting via WFC data ...'#10);
  12. if not Wifi_InitDefault(WFC_CONNECT) then
  13. iprintf('Failed to connect!')
  14. else
  15. begin
  16. iprintf('Connected'#10#10);
  17. ip := in_addr(Wifi_GetIPInfo(@gateway, @mask, @dns1, @dns2));
  18. iprintf('ip : %s'#10, inet_ntoa(ip));
  19. iprintf('gateway: %s'#10, inet_ntoa(gateway));
  20. iprintf('mask : %s'#10, inet_ntoa(mask));
  21. iprintf('dns1 : %s'#10, inet_ntoa(dns1));
  22. iprintf('dns2 : %s'#10, inet_ntoa(dns2));
  23. end;
  24. while true do
  25. begin
  26. swiWaitForVBlank();
  27. if( keys and KEY_START ) <> 0 then
  28. break;
  29. end;
  30. end.