Download User Guide - smartBASIC BL600 Extensions

Transcript
smart BASIC
User Manual
To submit a passkey, use the function BLESECMNGRPASSKEY.
BleSecMngrPasskey
FUNCTION
This function submits a passkey to the underlying stack during a pairing procedure when
prompted by the EVBLEMSG with msgId set to 11. See Events & Messages.
BLESECMNGRPASSKEY(connHandle, nPassKey)
INTEGER, a result code.
Typical value: 0x0000 (indicates a successful operation)
Returns
Arguments
connHandle
nPassKey
Interactive
Command
byVal connHandle AS INTEGER.
This is the connection handle as received via the EVBLEMSG event with msgId
set to 0.
byVal nPassKey AS INTEGER.
This is the passkey to submit to the stack. Submit a value outside the range 0
to 999999 to reject the pairing.
No
//Example :: BleSecMngrPasskey.sb (See in BL600CodeSnippets.zip)
DIM rc, connHandle
DIM addr$ : addr$=""
FUNCTION HandlerBleMsg(BYVAL nMsgId AS INTEGER, BYVAL nCtx AS INTEGER) AS INTEGER
SELECT nMsgId
CASE 0
connHandle = nCtx
PRINT "\n--- Ble Connection, ",nCtx
CASE 1
PRINT "\n--- Disconnected ";nCtx;"\n"
EXITFUNC 0
CASE 11
PRINT "\n +++ Auth Key Request, type=";nCtx
rc=BleSecMngrPassKey(connHandle,123456)
IF rc==0 THEN //key is 123456
PRINT "\nPasskey 123456 was used"
ELSE
PRINT "\nResult Code 0x";integer.h'rc
ENDIF
CASE ELSE
ENDSELECT
ENDFUNC 1
ONEVENT
EVBLEMSG
CALL HandlerBleMsg
rc=BleSecMngrIoCap(4) //Set i/o capability - Keyboard Only (authenticated pairing)
IF BleAdvertStart(0,addr$,25,0,0)==0 THEN
PRINT "\nAdverts Started\n"
PRINT "\nMake a connection to the BL600"
ELSE
PRINT "\n\nAdvertisement not successful"
ENDIF
Americas: +1-800-492-2320 Option 2
Europe: +44-1628-858-940
Hong Kong: +852 2923 0610
[email protected]
www.lairdtech.com/bluetooth
69
Laird Technologies