summaryrefslogtreecommitdiff
path: root/packages/libndsfpc/examples/dswifi/autoconnect/autoconnect.pp
blob: 1fd002389d234eda2d98d29a76d9d32735774d7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
program autoconnect;

{$mode objfpc}

uses
  ctypes, nds9, dswifi9;

var
	ip, gateway, mask, dns1, dns2: in_addr;
    keys: integer;
begin

	consoleDemoInit();  //setup the sub screen for printing

	iprintf(#10#10#9'Simple Wifi Connection Demo'#10#10);
	iprintf('Connecting via WFC data ...'#10);

	if not Wifi_InitDefault(WFC_CONNECT) then
		iprintf('Failed to connect!')
	else 
	begin
		iprintf('Connected'#10#10);

		ip := in_addr(Wifi_GetIPInfo(@gateway, @mask, @dns1, @dns2));
		
		iprintf('ip     : %s'#10, inet_ntoa(ip));
		iprintf('gateway: %s'#10, inet_ntoa(gateway));
		iprintf('mask   : %s'#10, inet_ntoa(mask));
		iprintf('dns1   : %s'#10, inet_ntoa(dns1));
		iprintf('dns2   : %s'#10, inet_ntoa(dns2));
	end;

	while true do
  begin
		swiWaitForVBlank();
		if( keys and KEY_START ) <> 0 then 
      break;
  end;
end.