<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[RemoteXY community — ESP32 - Delay when disconnected]]></title>
	<link rel="self" href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=1329&amp;type=atom" />
	<updated>2021-06-03T01:34:43Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.remotexy.com/viewtopic.php?id=1329</id>
		<entry>
			<title type="html"><![CDATA[Re: ESP32 - Delay when disconnected]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=4023#p4023" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>santo.minniti wrote:</cite><blockquote><p>I use RemoteXY.connect_flag for making DC motors stop when ESP32 lost Bluetooth connection</p></blockquote></div><p>What is the code you used for this method?&nbsp; I personally couldn&#039;t get any response from that flag... or perhaps I didn&#039;t wait long enough?</p><p>Instead, I used this in my <strong>void loop()</strong>…&nbsp; Which gives me the required failsafe stop (and visual disconnection notice) for my rover within a few seconds.</p><div class="codebox"><pre><code>// Connection Failsafe
  if (RemoteXY_isConnected() == 0) {
    RemoteXY.joystick_1_x = 0; // Set for dead stop
    RemoteXY.joystick_1_y = 0; // Set for dead stop
    // Flash headlamp LED when App not connected.
    digitalWrite(PIN_LED, !digitalRead(PIN_LED));
    delay(500);
  }</code></pre></div><br /><p>Also,&nbsp; I use WiFi in my rover, which I believe is just quicker at responding to feedback than Serial, which being slower needs more leeway in it&#039;s timeout settings else it may never stay stably connected.&nbsp; Perhaps try switching to WiFi and see if it is quicker for you as well.</p><p>Otherwise, I suppose you could try some changes to the <strong>RemoteXYComm_AT.h</strong> library (I think that would be applicable for BT/BLE), which does have a few timeout settings in what looks like millisecond ranges.</p><p>NOTE: I have no idea if this would be the proper way to accomplish your goal, but experimenting is half the fun.... make backups <img src="https://forum.remotexy.com/img/smilies/wink.png" width="15" height="15" alt="wink" /></p><div class="codebox"><pre><code>#define REMOTEXYCOMM_AT__COMMAND_TIMEOUT 1000
#define REMOTEXYCOMM_AT__SEND_TIMEOUT 5000
#define REMOTEXYCOMM_AT__TEST_TIMEOUT 30000
#define REMOTEXYCOMM_AT__CONNECT_TIMEOUT 20000</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Gunner]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=1840</uri>
			</author>
			<updated>2021-06-03T01:34:43Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=4023#p4023</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[ESP32 - Delay when disconnected]]></title>
			<link rel="alternate" href="https://forum.remotexy.com/viewtopic.php?pid=4022#p4022" />
			<content type="html"><![CDATA[<p>Hello everyone, I&#039;m noob so forgive me if I ask a stupid question!<br />I&#039;m making my first project with Esp32 and RemoteXY via Bluetooth.</p><p>I use ESP32 board with an H bridge to control two DC Motors.</p><p>I use RemoteXY.connect_flag for making DC motors stop when ESP32 lost Bluetooth connection,but if I disconnect bluetooth from my phone it takes 8-10 seconds for dc motors to stop.</p><p>How can I solve this problem?<br />thank you very much for your attention!</p>]]></content>
			<author>
				<name><![CDATA[santo.minniti]]></name>
				<uri>https://forum.remotexy.com/profile.php?id=1858</uri>
			</author>
			<updated>2021-06-02T23:40:43Z</updated>
			<id>https://forum.remotexy.com/viewtopic.php?pid=4022#p4022</id>
		</entry>
</feed>
