Skip to content

Commit bfd69e9

Browse files
authored
Create BLE_Broadcast.ino
1 parent 610e30c commit bfd69e9

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include <Arduino.h>
2+
#include <BLEDevice.h>
3+
#include <BLEAdvertising.h>
4+
5+
// Function Declaration
6+
void setup_ble(void);
7+
8+
// Create Data
9+
struct IMUData{
10+
float accelX;
11+
float accelY;
12+
float accelZ;
13+
float gyroX;
14+
float gyroY;
15+
float gyroZ;
16+
};
17+
18+
void setup(void) {
19+
// Begin Serial
20+
Serial.begin(115200);
21+
22+
// M5Unified configuration
23+
auto cfg = M5.config();
24+
cfg.internal_imu = true; // Enable internal IMU
25+
M5.begin(cfg);
26+
27+
// Setup BLE
28+
setup_ble();
29+
}
30+
31+
void loop(void) {
32+
Serial.println("Hello World\n");
33+
delay(100);
34+
}
35+
36+
// Function to Setup BLE
37+
void setup_ble(void) {
38+
BLEDevice::init("M5Capsule");
39+
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
40+
pAdvertising->setScanResponse(true);
41+
pAdvertising->setMinPreferred(0x06); // functions that help with iPhone connections issue
42+
pAdvertising->setMinPreferred(0x12);
43+
BLEDevice::startAdvertising();
44+
}
45+
46+

0 commit comments

Comments
 (0)