gwConnected (Function)

Top  Previous  Next

Architecture:

X32 / NX32 / NX32L

Device support:

All

Firmware version:

1.00 / 1.00.00


This returns information about whether the device is connected to the RTCU Communication Hub.

 

 

Input:        

None.

 

Returns: BOOL

True if connection is established, false if not.

 

Declaration:

FUNCTION gwConnected : BOOL;

 

 


Example:

 

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  incoming : gwReceivePacket;
  Buf_in : ARRAY [1..4064] OF SINT;
  Buf_out : ARRAY [1..4064] OF SINT;
  size     : INT;
END_VAR;
 
// Turn on power to the GSM module
gsmPower(power := TRUE);
gprsOpen();
 
// Wait for rch connection
WHILE NOT gwConnected() DO
  Sleep(delay := 2000);
END_WHILE;
 
// Determine the maximum size to send
size := gwPacketSize(nodeid := 2000);
IF size = 0 THEN
  size := 480;
END_IF;
 
// Set address BEFORE the 'incoming' is called the first time!
incoming.buffer   := ADDR(Buf_in);
incoming.maxlength := size;
 
BEGIN
  ...
  // Check for incoming packets
  incoming();
  IF incoming.sender > 0 THEN
     // A packet is received
     ...
  END_IF;
  ...
  gwSendPacket(receiver := 2000, buffer := ADDR(Buf_out), length := size);
  ...
END;
END_PROGRAM;