btEventDone (Function)

Top  Previous  Next

Architecture:

NX32L

Firmware version:

1.10.00

 


 

This function will make the current event as done, allowing btWaitEvent to find the next event.

 

 

Input:

None.

 

Returns: INT

1

-

_BT_OK


Success

0

-

_BT_ERR_NOT_SUPPORTED


The API is not supported.

-1

-

_BT_ERR_NOT_OPEN


The adapter is not powered(see btPower).

-9

-

_BT_ERR_NODATA


No valid event found to mark as done.

 

 

Declaration:

FUNCTION btEventDone : INT;

 

Example:

...
THREAD_BLOCK btThread
VAR
   rc      : INT;
   address : STRING;
   ch      : SINT;
   pass    : DINT;
END_VAR;
   WHILE TRUE DO
      // 
      rc := btWaitEvent(timeout:=10000dev := address);
      IF rc <> _BT_ERR_TIMEOUT THEN
         DebugFmt(message:="event \1: "+addressv1:=rc);
         CASE rc OF 
         _BT_EVENT_INCOMING:
            rc := btHandleSerialPortIncomingConnection(ch := chport := port);
            DebugFmt(message:="btHandleSerialPortIncomingConnection(\2) : \1, \3", v1:=rcv2:=chv3:=port);
         _BT_EVENT_DEV_FOUND:
            DebugFmt(message:="Found "+address);
         _BT_EVENT_DEV_LOST:
            DebugFmt(message:="Lost "+address);
         _BT_EVENT_PAIR_REQ:
            DebugFmt(message:="Requested confirm for "+address);
            rc := btHandlePairRequest(passkey:=pass);
            DebugFmt(message:="Pass: \4, \1", v1:=rcv4:=pass);
            rc := guiShowMessage(message:="Is the pairing code "+dintToStr(v:=pass)+" correct?", type := 2timeout := 20);
            DebugFmt(message:="guiShowMessage: \1", v1:=rc);
            // Accept if "Yes" was pressed
            rc := btSendPairResponse(accept:=(rc = 3));
            DebugFmt(message:="btSendPairResponse: \1", v1:=rc);
         ELSE
            DebugFmt(message:="unknown event: \1", v1:=rc);
         END_CASE;
         btEventDone();
      END_IF;
 
   END_WHILE;
END_THREAD_BLOCK;
...