Download BL620 smartBASIC extensions v12.4.10.0

Transcript
smart BASIC – BL620
Extension Functionality User Manual
//==============================================================================
// CCCD descriptor written handler
//==============================================================================
FUNCTION HndlrCharCccd(BYVAL charHandle, BYVAL nVal)
DIM value$
IF charHandle==hMyChar THEN
PRINT "\nCCCD Val: ";nVal
IF nVal THEN
PRINT " : Indications have been enabled by client"
value$="hello"
rc=BleCharValueIndicate(hMyChar,value$)
IF rc!=0 THEN
PRINT "\nFailed to indicate new value :";INTEGER.H'rc
ELSE
PRINT "\nSuccessful indication of new value"
EXITFUNC 1
ENDIF
ELSE
PRINT " : Indications have been disabled by client"
ENDIF
ELSE
PRINT "\nThis is for some other characteristic"
ENDIF
ENDFUNC 1
//==============================================================================
// Indication Acknowledgement Handler
//==============================================================================
FUNCTION HndlrChrHvc(BYVAL charHandle)
IF charHandle == hMyChar THEN
PRINT "\n\nGot confirmation of recent indication"
ELSE
PRINT "\n\nGot confirmation of some other indication: ";charHandle
ENDIF
ENDFUNC 0
ONEVENT
ONEVENT
ONEVENT
EVBLEMSG
EVCHARCCCD
EVCHARHVC
CALL HndlrBleMsg
CALL HndlrCharCccd
CALL HndlrChrHvc
IF OnStartup()==0 THEN
rc = BleCharValueRead(hMyChar,at$)
PRINT "\nCharacteristic Value: ";at$
PRINT "\nYou can connect and write to the CCCD characteristic."
PRINT "\nThe BL620 will then indicate a new characteristic value\n"
ELSE
PRINT "\nFailure OnStartup"
ENDIF
WAITEVENT
rc=BleDisconnect(conHndl)
rc=BleAdvertStop()
PRINT "\nExiting..."
Embedded Wireless Solutions Support Center:
http://ews-support.lairdtech.com
www.lairdtech.com/wireless
121
Laird Technologies
Americas: +1-800-492-2320
Europe: +44-1628-858-940
Hong Kong: +852-2268-6567 x026