Skip to content

Commit

Permalink
Revert "add hid host. but wont connect..."
Browse files Browse the repository at this point in the history
This reverts commit 78c45b4.
  • Loading branch information
KillerInk committed Nov 21, 2022
1 parent 78c45b4 commit 8513259
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 1,103 deletions.
2 changes: 1 addition & 1 deletion data/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function btItemClick(name) {

function connectToBT() {
var macbt = $("#mac").val();
var psxl = $("#psx:checked").val();
var psxl = $("#psx").val();
var jstr = JSON.stringify({ mac: macbt, psx: psxl ? 1 : 0 });
post(jstr, "/bt_connect");
}
Expand Down
28 changes: 12 additions & 16 deletions main/src/bt/BtController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ namespace RestApi
namespace BtController
{


BluetoothSerial btClassic;

bool doConnect = false;
bool connected = false;
bool doScan = false;
bool ENABLE = false;
int BT_DISCOVER_TIME = 5000;
int BT_DISCOVER_TIME = 10000;
BTAddress *mac;

void setup()
Expand All @@ -64,15 +64,13 @@ namespace BtController
//BLEDevice::setCustomGattsHandler(my_gatts_event_handler);
//BLEDevice::setCustomGattcHandler(my_gattc_event_handler);
//BLEDevice::setEncryptionLevel(ESP_BLE_SEC_ENCRYPT_MITM);

btClassic.begin("ESP32-BLE-1");
}

void scanForDevices(DynamicJsonDocument *jdoc)
{
log_i("Start scanning BT");
BluetoothSerial * btClassic = new BluetoothSerial();
btClassic->begin("ESP32-BLE-1");
BTScanResults *foundDevices = btClassic->discover(BT_DISCOVER_TIME);
BTScanResults *foundDevices = btClassic.discover(BT_DISCOVER_TIME);
(*jdoc).clear();
for (int i = 0; i < foundDevices->getCount(); i++)
{
Expand All @@ -81,9 +79,6 @@ namespace BtController
ob["name"] = foundDevices->getDevice(i)->getName();
ob["mac"] = foundDevices->getDevice(i)->getAddress().toString();
}
btClassic->discoverClear();
btClassic->end();
delete(btClassic);
// pBLEScan->clearResults();
// pBLEScan->stop();
}
Expand Down Expand Up @@ -139,18 +134,19 @@ namespace BtController

mac = new BTAddress(m.c_str());
log_i("input mac %s BLEAdress: %s", m.c_str(), mac->toString().c_str());

log_i("connectToServer");
connectToServer();
if (doConnect)
{
log_i("connectToServer");
delay(1000);
connectToServer();
}
else
log_i("failed to find device");
}

bt_hid_host hidhost;
bool connectToServer()
{

log_i("Forming a connection to ");
hidhost.scanAndConnect(mac->getNative());
return true;
// log_i("%s", myDevice->getAddress().toString().c_str());
/*btClassic.connect
BLEClient *pClient = BLEDevice::createClient();
Expand Down
1 change: 0 additions & 1 deletion main/src/bt/BtController.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <ArduinoJson.h>
#include "../../config.h"
#include "../wifi/RestApiCallbacks.h"
#include "bt_hid_host.h"

namespace RestApi
{
Expand Down
143 changes: 0 additions & 143 deletions main/src/bt/bt_hid_host.cpp

This file was deleted.

38 changes: 0 additions & 38 deletions main/src/bt/bt_hid_host.h

This file was deleted.

Loading

0 comments on commit 8513259

Please sign in to comment.