Coder Social home page Coder Social logo

Comments (6)

krzmaz avatar krzmaz commented on September 26, 2024

Hey, I have tested disconnecting and reconnecting in a loop on my local setup and it works fine for me. However there might be problems with the bonding information on the desk controller side when you pair your phone. Do you have a fork of the repo that I could look at to better reproduce it?

from linakdeskesp32controller.

NS-K avatar NS-K commented on September 26, 2024

My linak have a ble remote control and that's the reason why i want to disconnect the esp32 from the linak controller.
so during the test i ve removed the battery from the remote control to be sure that it's not affecting the result.
I have also tried to compile the code with h2zero/NimBLE-Arduino @ 1.3.6 but the same problem remain.
I have also tried to deinit the ble after disconnecting
I will give a try tomorrow to the h2zero/NimBLE-Arduino @ 1.3.7 as they fixed some Memory leak when deleting client instances.
I do not have a fork of the repo but this is the change that i made to your main.cpp.

#define DISCONNECT_TIMEOUT 30000

bool linakConnect() {
	
	if (!controller.isConnected()) {
		controller.connect(BtAddress);
	}

	if (controller.isConnected()) {		
		connectTime = millis();
	}
	
	return controller.isConnected();

}

//  on DeskController.cpp i added
// bool DeskController::isMoving() { return mIsMoving; }

bool linakDisconnect() {

	if(!controller.isMoving()){
		controller.disconnect();		
	}
		
	return !controller.isConnected();
}

// on the loop()

if(millis() - connectTime > DISCONNECT_TIMEOUT && controller.isConnected()) {

		linakDisconnect();
}

from linakdeskesp32controller.

krzmaz avatar krzmaz commented on September 26, 2024

Okay, first of all, if you don't want to create a fork of the repo, please use the output of git diff to share all the changes you made, otherwise I cannot know if something else is not affecting the code.
I.e. in the code you've shared I do not see a call to linakConnect so it seems normal that the controller doesn't reconnect after the first disconnect 😜
Also, please try describing what you are trying to accomplish a bit more. I assumed you want to use another device (like a smartphone) to control the desk while the ESP32 is disconnected. However after your comment about taking the battery out of some controller, I'm a bit confused about the setup you have.

from linakdeskesp32controller.

NS-K avatar NS-K commented on September 26, 2024

i have a linak actuator that is controlled only by a remote control and what i am working on is to create a esp32-homekit that will connect to this actuator and will be integrated into one of my homekit scene. and this is the reason why i didn't share my complete code with you as i removed the DoubleResetDetector, AsyncWebServer, fauxmoESP ... and added the esp32-homekit library.
everything is working fine except the remote control stop working which is normal because only one ble device could be connected to the controller.
so i come with the idea to add a timeout to disconnect the esp32-homekit from the linak and only connected it back when a command is sent from homekit if (linakConnect() && destination >= 0 && destination < MAX_HEIGHT_RAW) { controller.moveToHeightRaw(destination); } but it always end with a "NimBLEClient:" Connection failed; status=534.

from linakdeskesp32controller.

krzmaz avatar krzmaz commented on September 26, 2024

Oh, I see. I think the problem lies in the instability of having both WiFi and BLE running at the same time. I'm guessing (again, because of the lack of the actual code) that you are doing linakConnect() during handling of an HTTP call, so before the HTTP response is sent. I was seeing some of those problems myself when developing the project. That's why I made all the moveToHeight commands non blocking. ESP32 modules use the same radio for both BLE and WiFi so I don't think establishing an BLE connection while handling an HTTP request is achievable.

From the maintainer of NimBLE-Arduino lib I got the info that:

BLE+async are a known problematic combination

I'm actually starting to work on another project due to that limitation - I want to use my Core library and emulate a BLE smarthome device for the smart speakers to connect directly - so that the WiFi stack doesn't need to be used on the ESP32. That will bring it's own limitations, as all configuration will most likely have to be done in compile time. I'm not sure how is the HomeKit BLE support, but that might be one way forward for you if the WiFi + Bluetooth combo won't work 🙂

from linakdeskesp32controller.

NS-K avatar NS-K commented on September 26, 2024

Thank you for the informations and for taking time to answer my question.

from linakdeskesp32controller.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.