Skip to content

Instantly share code, notes, and snippets.

@don
Created June 24, 2014 19:23
Show Gist options
  • Select an option

  • Save don/43f2a79769977e6912e6 to your computer and use it in GitHub Desktop.

Select an option

Save don/43f2a79769977e6912e6 to your computer and use it in GitHub Desktop.
/*
Advertise a URL in the (
*/
#include <RFduinoBLE.h>
// the advertisement packet is composed of a series of variable length blocks, that can appear in any order.
// each block starts with a length byte, followed by a type byte, followed by the data.
// the payload cannot exceed 31 bytes.
// Note: since the RFduino UUID is missing from the advertisement packet, the RFduino iPhone apps will not
// be able to see this advertisement.
uint8_t advdata[] =
{
18, // length
0xF0, // URL (using fake number until real one is assigned)
0x68, // 'h'
0x74, // 't'
0x74, // 't'
0x70, // 'p'
0x3a, // ':'
0x2f, // '/'
0x2f, // '/'
0x6a, // 'j'
0x65, // 'e'
0x6e, // 'n'
0x73, // 's'
0x6f, // 'o'
0x6e, // 'n'
0x2e, // '.'
0x6f, // 'o'
0x72, // 'r'
0x67 // 'g'
};
// pin 3 on the RGB shield is the green led
int led = 3;
void setup() {
// led used to indicate that the RFduino is advertising
pinMode(led, OUTPUT);
RFduinoBLE_advdata = advdata;
RFduinoBLE_advdata_len = sizeof(advdata);
// start the BLE stack
RFduinoBLE.begin();
}
void loop() {
// switch to lower power mode
RFduino_ULPDelay(INFINITE);
}
void RFduinoBLE_onAdvertisement(bool start)
{
// turn the green led on if we start advertisement, and turn it
// off if we stop advertisement
if (start)
digitalWrite(led, HIGH);
else
digitalWrite(led, LOW);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment