Created
October 11, 2020 19:13
-
-
Save neon-izm/3907743f16875858167eedc8de616fd6 to your computer and use it in GitHub Desktop.
これを焼いたM5StickCにBT SPPの接続、切断を繰り返すと勝手にloop()内でSerialBTがコケてloopが止まる。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <M5StickC.h> | |
#include <BluetoothSerial.h> | |
BluetoothSerial SerialBT; | |
/* Set the delay between fresh samples */ | |
#define DELAY_MS (5) | |
int led = HIGH; | |
void setup() { | |
M5.begin(); | |
delay(500); | |
//BluetoothのMACアドレス取得 | |
uint8_t macBT[6]; | |
esp_read_mac(macBT, ESP_MAC_BT); | |
char btname[18]; | |
//PC側で確認するときの名前 | |
sprintf(btname, "BTSPP-%02X%02X", macBT[4], macBT[5]); | |
SerialBT.begin(btname); | |
pinMode(10, OUTPUT); | |
digitalWrite(10, led); | |
} | |
int encoded = 0; | |
void loop() { | |
digitalWrite(10, led); | |
led = !led; | |
encoded++; | |
//数字を取りあえず出しておく | |
SerialBT.print(encoded); | |
delay(DELAY_MS); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment