-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
main.c
42 lines (33 loc) · 850 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "ble_stack.h"
#include "openhaystack.h"
/**
* advertising interval in milliseconds
*/
#define ADVERTISING_INTERVAL 5000
static char public_key[28] = "OFFLINEFINDINGPUBLICKEYHERE!";
/**
* main function
*/
int main(void) {
// Variable to hold the data to advertise
uint8_t *ble_address;
uint8_t *raw_data;
uint8_t data_len;
// Set key to be advertised
data_len = setAdvertisementKey(public_key, &ble_address, &raw_data);
// Init BLE stack
init_ble();
// Set bluetooth address
setMacAddress(ble_address);
// Set advertisement data
setAdvertisementData(raw_data, data_len);
// Start advertising
startAdvertisement(ADVERTISING_INTERVAL);
// Go to low power mode
while (1) {
power_manage();
}
}