<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[RemoteXY community — Solved: Optimizing RemoteXY in battery low-power device]]></title>
		<link>https://forum.remotexy.com/viewtopic.php?id=1511</link>
		<atom:link href="https://forum.remotexy.com/extern.php?action=feed&amp;tid=1511&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Solved: Optimizing RemoteXY in battery low-power device.]]></description>
		<lastBuildDate>Tue, 07 Nov 2023 11:24:19 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Solved: Optimizing RemoteXY in battery low-power device]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=5243#p5243</link>
			<description><![CDATA[<p>that sounds very promissing - i am looking for for low-power consumption as well.<br />did you put this code behind void loop()? <br />thanks, thomas</p>]]></description>
			<author><![CDATA[null@example.com (tommispost)]]></author>
			<pubDate>Tue, 07 Nov 2023 11:24:19 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=5243#p5243</guid>
		</item>
		<item>
			<title><![CDATA[Re: Solved: Optimizing RemoteXY in battery low-power device]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=4713#p4713</link>
			<description><![CDATA[<p>Yeah, just got it working:</p><p>I simply altered the handler function like so:</p><div class="codebox"><pre><code>void handler () {
    uint8_t connect_flag = 0;
    
    // threads handler

    CRemoteXYThread * pt = data.threads;
    while (pt) {   
      pt-&gt;handler ();     
      connect_flag += pt-&gt;connect_flag;
      pt = pt-&gt;next;
    }
    *data.connect_flag = connect_flag;

    if (connect_flag == 1) // LeFish
    {

      // communications handler    

      CRemoteXYComm * comm = data.comms; 
      while (comm) {
        comm-&gt;handler (); 
        comm = comm-&gt;next;
      } 

      // connections handler    

      CRemoteXYConnectionComm * connection = data.connections; 
      while (connection) {
        connection-&gt;handler (); 
        connection = connection-&gt;next;
      }   
    }</code></pre></div><p>Now it connects to the gui and still goes into light sleep when no BLE device is connected.</p><p>I think we could mark this as solved...</p>]]></description>
			<author><![CDATA[null@example.com (LeFish)]]></author>
			<pubDate>Thu, 30 Jun 2022 06:14:11 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=4713#p4713</guid>
		</item>
		<item>
			<title><![CDATA[Re: Solved: Optimizing RemoteXY in battery low-power device]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=4712#p4712</link>
			<description><![CDATA[<p>Thanks for your reply.</p><p>I tried to implement BLE interface myself (-&gt;Kodular) all from scratch and got it to work on my android cell phone. So I have some experience in BLE implementation. Disclaimer: Still I am a rookie <img src="https://forum.remotexy.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p><p>I already altered RemoteXYStream_BLEDevice_h to optimize power consumption. This is what I did:</p><div class="codebox"><pre><code>...
    // Start advertising
    pServer-&gt;getAdvertising()-&gt;addServiceUUID(pService-&gt;getUUID());
    pServer-&gt;getAdvertising()-&gt;setMinInterval(0x640); //LeFish
    pServer-&gt;getAdvertising()-&gt;setMaxInterval(0x640); //LeFish
    pServer-&gt;getAdvertising()-&gt;start();
    BLEDevice::setPower(ESP_PWR_LVL_N9); //LeFish
...</code></pre></div><p>This is all one can change to optimize power consumption to my knowledge.</p><p>Therefore I think BLE Communication is perfectly fine when comparing to my own implementation on which automatic light sleep did work. I come to this statement due to the fact that I had i.e. TickTwo.h (<a target="_blank" href="https://github.com/sstaub/TickTwo">https://github.com/sstaub/TickTwo</a>) implemented. And when using this library this also prevented the ESP to go into light sleep. Some locks must be acquired by this library that prevent esp from going into light sleep. And I think this also applies to RemoteXY.</p><p>I tried and the ESP actually goes into light sleeps when not periodically calling the default </p><div class="codebox"><pre><code>remotexy-&gt;handler();</code></pre></div><p> but leaving the rest on default.</p><p>Therefore I think the &quot;problem&quot; must be some statement within the handler function which prevents the esp from sleep.</p><p>Do you have any idea where I could start to dig? I am willing to dig further with your help as I believe RemoteXY is just what I need to finish my project.<br />If we get this to work it could help others to implement RemoteXY in low power consumption devices.</p><p>This is my idea:</p><p>My idea is to set some flag within the CRemoteXYStream_BLEDevice::onConnect() which is readable by CRemoteXY::handler ()</p><p>If this flag is true the full handler funtion is called. Otherwise only necessary portion (none?) for &quot;standby&quot; (able to accept BLE connections, which is afaik not handled by RemoteXY anyways.)</p>]]></description>
			<author><![CDATA[null@example.com (LeFish)]]></author>
			<pubDate>Thu, 30 Jun 2022 05:48:08 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=4712#p4712</guid>
		</item>
		<item>
			<title><![CDATA[Re: Solved: Optimizing RemoteXY in battery low-power device]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=4710#p4710</link>
			<description><![CDATA[<p>Unfortunately the library does not provide for transferring the ESP to low power consumption.<br />You will have to implement this in the module responsible for the BLE, it is file&nbsp; RemoteXYStream_BLEPeripheral.h of RemoteXY library.</p>]]></description>
			<author><![CDATA[null@example.com (remotexy)]]></author>
			<pubDate>Thu, 30 Jun 2022 04:31:47 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=4710#p4710</guid>
		</item>
		<item>
			<title><![CDATA[Solved: Optimizing RemoteXY in battery low-power device]]></title>
			<link>https://forum.remotexy.com/viewtopic.php?pid=4703#p4703</link>
			<description><![CDATA[<p>Hi there,</p><p>First of all: RemoteXY is great! Thank you for this great eco-system!</p><p>I am planning to implement a low-power application on a ESP32C3 with BLE.</p><p>I have come pretty far and basically everything is working fine. Now I would like to optimize current consumption while no BLE device is connected to the ESP32.</p><p>I have activated all the necessary features as stated here: <a target="_blank" href="https://github.com/espressif/esp-idf/issues/947">https://github.com/espressif/esp-idf/issues/947</a></p><p>The problem is, that calling the default </p><div class="codebox"><pre><code>remotexy-&gt;handler();</code></pre></div><p> function in </p><div class="codebox"><pre><code>void loop() </code></pre></div><p> prevents the ESP32 to enter light sleep. Therefore the current consumption is 30mA instead of &lt;5mA without calling the handler function.</p><p>I tried to simply not call&nbsp; </p><div class="codebox"><pre><code>remotexy-&gt;handler();</code></pre></div><p> periodically without established connection (</p><div class="codebox"><pre><code>remotexy-&gt;isConnected() == false</code></pre></div><p> and I come this far:<br /><a target="_blank" href="https://paste.pics/aa26d4d8dec4634c5bf02b34417b60a3">https://paste.pics/aa26d4d8dec4634c5bf02b34417b60a3</a><br />The current consumption drops to &lt;5mA while no device is connected, which is the desired behaviour.</p><p>My intention is to call only the bare minimum handler() portion for establishing a connection periodically and only when BLE device is connected calling the full handler.</p><p>Would you kindly help me on this?</p><p>Thank you!</p><p>Best regards<br />LeFish</p>]]></description>
			<author><![CDATA[null@example.com (LeFish)]]></author>
			<pubDate>Tue, 28 Jun 2022 10:37:29 +0000</pubDate>
			<guid>https://forum.remotexy.com/viewtopic.php?pid=4703#p4703</guid>
		</item>
	</channel>
</rss>
