What is the easiest way to change the advertised Device Name for the BL600 or BT900 using smartBASIC?
Changing the advertised device name is accomplished using three different functions prior to calling the BleAdvertStart () function. First, the BleGapSvcInit () function is used to change the device name from the default, Laird [BL600 | BT900], to the desired device name. Next, the BleAdvRptInit () funtion must be called to create and initialize the advert report with the new device name. Finally, the BleAdvRptsCommit () function must be called to commit the changes. Below is an example of a simplified smart BASIC app which changes the default device name to "My Device": //****************************************************************************** // Laird Technologies // Rikki Horrigan //****************************************************************************** //****************************************************************************** //Definitions //****************************************************************************** //****************************************************************************** //Global Variable Definitions //****************************************************************************** dim rc ? ? //result code dim nameWritable dim nAppearance dim nMinConnInterval dim nMaxConnInterval dim nSupervisionTout dim nSlaveLatency //****************************************************************************** // Initialisse Global Variable //****************************************************************************** nameWritable = 0 //The device name will not be writable by peer. nAppearance = 1091 //Device will apear as Walking sensor on hip (org.bluetooth.characteristic.gap.appearance.) nMinConnInterval = 500000 // must be smaller than nMaxConnInterval. nMaxConnInterval = 1000000 //must be larger than nMinConnInterval nSupervisionTout = 4000000 //Range is between 100000 to 32000000 microseconds (rounded to the nearest 10000 microseconds) nSlaveLatency = 0 //value must be smaller than (nSupervisionTimeout/nMaxConnInterval)-1 //****************************************************************************** //Functions & Subroutines //****************************************************************************** //ERROR HANDLER SUB assertRC(rc, line) ? IF rc != 0 THEN ? ? PRINT "
Error on line ";line;", code: ";INTEGER.H'rc ? ENDIF ENDSUB // Change Device Name FUNCTION OnStartup() print "Default Device Name: "; BleGetDeviceName$ ();"
" dim deviceName$ //declare variable for DEVICENAME deviceName$= "My Device" //Set new DEVICENAME rc = BleGapSvcInit (deviceName$, nameWritable, nAppearance, nMinConnInterval, nMaxConnInterval, nSupervisionTout, nSlaveLatency ) print "
New Device Name: "; BleGetDeviceName$ (); "
" //Create and Initializing the Advert Report (not advertised until BLEADVRPTSCOMMIT is called) dim adRpt$ //advert report adRpt$ = "" rc = BleAdvRptInit(adRpt$, 2, 0, 16) //Commit the advert report dim scRpt$ //scan report scRpt$ = "" rc = BleAdvRptsCommit(adRpt$,scRpt$) //Start Advertising dim addr$ addr$ = "" rc = BleAdvertStart(0,addr$,100,0,0) ENDFUNC 1 // Remain in WAITEVENT //****************************************************************************** //Handler Definitions //****************************************************************************** //****************************************************************************** //OnEvent Statements //****************************************************************************** //****************************************************************************** //Equivalent to Main() in C //****************************************************************************** rc = OnStartup() Waitevent