N Device Status - FujiNetWIFI/fujinet-firmware GitHub Wiki

Description

The STATUS command returns one of six possible chunks of status information, on a given IOCB, across the four status bytes provided by the OS (DVSTAT):

If AUX1=0:

  • DVSTAT[0] - Bytes Available for read
  • DVSTAT[1] - If a server socket was specified in OPEN by AUX2=1, then 0 = No Client Waiting for connection accept., 1 = Client waiting for connection accept.
  • DVSTAT[2] - 1=connected, 0=disconnected

If AUX1 is 1 to 5, then four bytes are returned in DVSTAT, which correspond to:

  • AUX1=1 - External IP address
  • AUX1=2 - Internal IP Address
  • AUX1=3 - Gateway IP Address
  • AUX1=4 - Netmask (e.g. 255.255.255.0)
  • AUX1=5 - DNS IP Address

These are useful, for example, to display in your program.

Parameters

Parameter Description
AUX1 0=Socket Status, 1=External IP, 2=Internal IP, 3=Gateway IP, 4=Netmask, 5=DNS IP
AUX2 Not used
FILENAME Nx: where x is the device # (1-8), or empty for 1.

Returns

The error code is returned in the STATUS return. Typically 1, for success. Other values are returned in DVSTAT, which must be read, e.g. by a PEEK(746) to PEEK(749) command in BASIC.

Examples

BASIC

Given a socket opened by:

OPEN #1,12,0,"N:TCP:192.168.1.8:2000"

You can check the status for available bytes, by issuing

STATUS #1,A

and retrieving the number of bytes available:

BAVAIL=PEEK(746)

You should also check to see if the connection is available:

BCONNECTED=PEEK(748)

or checking if a user is waiting

WAITING=PEEK(747)
IF WAITING THEN GOTO 1000:REM GO ACCEPT CONNECTION

For Any other status information, the XIO command must be used, such as retrieving the external IP address

XIO 13,#1,1,0,"N:":REM AUX1=1 = RETRIEVE EXTERNAL IP
PRINT "MY IP IS: ";PEEK(746);".";PEEK(747);".";PEEK(748);".";PEEK(749)