Download BL600 smartBASIC Module
Transcript
smart BASIC
User Manual
Expected Output:
Handle for HRS Uuid is FE01180D (-33482739)
BLEHANDLEUUID16 is an extension function.
BleHandleUuid128
FUNCTION
This function takes a 16 byte string and converts it into a 32 bit integer handle. The handle consists of a 16
bit (2 byte) offset into a new 128 bit base UUID.
The base UUID is basically created by taking the 16 byte input string and setting bytes 12 and 13 to zero after
extracting those bytes and storing them in the handle object. The handle also contains an index into an array
of these 16 byte base UUIDs which are managed opaquely in the underlying stack.
The returned handle shall be treated by the developer as an opaque entity and no further logic shall be based
on the bit content. However, note that a string of zeroes represents an invalid UUID handle.
Please ensure that you use a 16 byte UUID that has been generated using a random number generator with
sufficient entropy to minimise duplication, as stated in an earlier section and that the first byte of the array is
the most significant byte of the UUID.
BLEHANDLEUUID128 (stUuid$)
Returns:
INTEGER, A handle representing the shorthand UUID. If zero, which is an invalid UUID
handle, there is either no spare RAM memory to save the 16 byte base or more than
253 custom base UUIDs have been registered.
Arguments:
stUuid$
byRef stUuid$ AS STRING
Any 16 byte string that was generated using a UUID generation utility that has enough
entropy to ensure that it is random. The first byte of the string is the MSB of the UUID –
that is, big endian format.
Interactive Command:
NO
//Example :: BleHandleUuid128.sb (See in BL600CodeSnippets.zip)
DIM uuid$ : hUuidCustom
//create a custom uuid for my ble widget
uuid$ = "ced9d91366924a1287d56f2764762b2a"
uuid$ = StrDehexize$(uuid$)
hUuidCustom = BleHandleUuid128(uuid$)
IF hUuidCustom == 0 THEN
PRINT "\nFailed to create a handle"
ELSE
PRINT "Handle for custom Uuid is ";integer.h’ hUuidCustom; "(";hUuidCustom;")"
ENDIF
// hUuidCustom now references an object which points to
// a base uuid = ced9d91366924a1287d56f2747622b2a (note 0's in byte position 2/3)
// and an offset = 0xd913
Americas: +1-800-492-2320 Option 2
Europe: +44-1628-858-940
Hong Kong: +852 2923 0610
[email protected]
www.lairdtech.com/bluetooth
239
Laird Technologies