I have two devices running the serial port software. I would like to see which one I'm selecting on an Iphone, so I would like to add the last four chars of the BT MAC address to the advertisement name. Is there a recommended way in doing so, is there sample code where this is implemented?
Regards,
R
Keywords:
Device:
Hi roland,
你不该有to place the MAC address on the advertising string in order to be aware on which device you are connecting to, normaly a Central device should indicate the bd address of the device that receives the advertising string from, anyway i suppose that the iPhone presents a number that is irrelevant with the actual bd address of the device and thats why you would want that. Anyway, no there is no reference design that implements that, but depending on the source that the db address is populated (NVDS or OTP) or via reading directly the dev_dbaddr variable (that variable that stores the actual bd address) you can update the advertising string. You can have a look at the barebone example in order to check how to update the advertising string, and in the .default_operation_adv invoke the app_easy_gap_undirected_advertise_get_active() in order to create the message, read the db address from dev_dbaddr variable and attach it the the advertising string using the extra length value and the 0xFF advertising string tag for manufacturer data. In case you dont want to do this dynamically but you are changing the bd address in each image you download to the devices you have, you can attach at the end of the USER_ADVERTISE_DATA the bd address of the device again using the length of the portion of bytes that you have added and the 0xFF tag for the manufacturer data. For example lets say that your last bytes of the bd address end in 0x01 0x02 0x03, so your advertising data will be like below.
#define USER_ADVERTISE_DATA "\x11\x07\xb7\x5c\x49\xd2\x04\xa3\x40\x71\xa0\xb5\x35\x85\x3e\xb0\x83\x07\x04\xFF\x01\x02\x03"
Thanks MT_dialog