Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
If wifi.Connect2("SSID", "PASS") = True Then
Log("Connected")
RunNative("initiate", Null)
AddLooper("letsaddtolooper")
Else
Log("Failed to connect")
End If
End Sub
Private Sub letsaddtolooper
RunNative("addaslooper", Null)
End Sub
#if C
//Example code that works fine with v1.0.1 and can't connect with v2 (v2.0.2 and latest):
#include "BluetoothSerial.h"
BluetoothSerial SerialBT;
uint8_t address[6] = { 0x20, 0x13, 0x01, 0x18, 0x02, 0x26 };
const char *pin = "1234";
bool connected;
void initiate(B4R::Object* o) {
SerialBT.begin("ESPBT", true);
SerialBT.setPin(pin);
Serial.println("The device started in master mode, make sure remote BT device is on!");
connected = SerialBT.connect(address);
if(connected) {
Serial.println("Connected Succesfully!");
} else {
while(!SerialBT.connected(10000)) {
Serial.println("Failed to connect. Make sure remote device is available and in range, then restart app.");
}
}
}
void addaslooper(B4R::Object* o) {
if (SerialBT.available()) {
Serial.write(SerialBT.read());
}
delay(5);
}
#End if