<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[GUI-O with Nano 33 BLE and the ArduinoBLE Library]]></title><description><![CDATA[<p dir="auto">Does anyone have example code using GUI-O with a Nano 33 BLE and the associated ArduinoBLE library?<br />
The nineteen GUI-O Tutorials all use the ESP32 and different libraries and as a beginner I’m struggling to convert.</p>
<p dir="auto">To get started I have successfully implemented the Arduino ButtonLED.ino example that uses the ArduinoBLE library.<br />
<a href="https://github.com/arduino-libraries/ArduinoBLE/blob/master/examples/Peripheral/ButtonLED/ButtonLED.ino" rel="nofollow ugc">https://github.com/arduino-libraries/ArduinoBLE/blob/master/examples/Peripheral/ButtonLED/ButtonLED.ino</a><br />
And I can successfully send and receive info between the Nano 33 BLE board and my android phone using the “nRF Connect” app but now I want to use GUI-O app.</p>
<p dir="auto">Per the GUI-O Manual I know I have to:<br />
1.) detect when GUI-O sends the “@int” command.<br />
2.) then send the GUI-O commands to create the desired widgets.<br />
3.) then send and receive updates.</p>
<p dir="auto">It is easy to create the desired interface using GUI-O Designer but how do I modify ButtonLED.ino to include the above steps using the ArduinoBLE library? I have tried many ways but keep getting compile errors with no clear explanation. No doubt I’m missing something simple.</p>
<p dir="auto">Thank you in advance.</p>
]]></description><link>https://forum.gui-o.com/topic/150/gui-o-with-nano-33-ble-and-the-arduinoble-library</link><generator>RSS for Node</generator><lastBuildDate>Sun, 07 Jun 2026 16:31:28 GMT</lastBuildDate><atom:link href="https://forum.gui-o.com/topic/150.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 01 Sep 2023 18:38:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to GUI-O with Nano 33 BLE and the ArduinoBLE Library on Wed, 27 Sep 2023 07:20:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.gui-o.com/uid/615">@VNB</a> said in <a href="/post/609">GUI-O with Nano 33 BLE and the ArduinoBLE Library</a>:</p>
<blockquote>
<p dir="auto">There were two minor problems.<br />
1.) The Slider Control knob always stayed at 100% even if it is set to a low brightness. That was fixed by adding the following instruction in the "led drive" section.<br />
sendMsg("@brightness VIS:1 VAL:val\r\n");</p>
</blockquote>
<p dir="auto">The code:</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.gui-o.com/uid/615">@VNB</a> said in <a href="/post/609">GUI-O with Nano 33 BLE and the ArduinoBLE Library</a>:</p>
<blockquote>
<p dir="auto">sendMsg("@brightness VIS:1 VAL:val\r\n");</p>
</blockquote>
<p dir="auto">is not correct  (as you've already pointed out), since the <strong>val</strong> is a non-numeric string that GUI-O cannot convert to numeric string.</p>
<p dir="auto">This is correct:</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.gui-o.com/uid/615">@VNB</a> said in <a href="/post/620">GUI-O with Nano 33 BLE and the ArduinoBLE Library</a>:</p>
<blockquote>
<p dir="auto">sendMsg("@brightness VIS:1 VAL:"+ String(val) + "\r\n");</p>
</blockquote>
<p dir="auto">as the String constructor converts the <strong>val</strong> into numerical representation.</p>
<p dir="auto">This code should not be necessary, since the value originates from CB, which should already have the correct position. The issue seems to originate from somewhere else, but I cannot see the problem...</p>
<p dir="auto">Regards,<br />
kl3m3n</p>
]]></description><link>https://forum.gui-o.com/post/621</link><guid isPermaLink="true">https://forum.gui-o.com/post/621</guid><dc:creator><![CDATA[kl3m3n]]></dc:creator><pubDate>Wed, 27 Sep 2023 07:20:46 GMT</pubDate></item><item><title><![CDATA[Reply to GUI-O with Nano 33 BLE and the ArduinoBLE Library on Tue, 26 Sep 2023 20:14:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.gui-o.com/uid/615">@VNB</a> For what it is worth in the original code (above) if I replace the incomplete/incorrect instruction</p>
<pre><code>sendMsg("@brightness VIS:1 VAL:val\r\n");
</code></pre>
<p dir="auto">with the following</p>
<pre><code>sendMsg("@brightness VIS:1 VAL:"+ String(val) + "\r\n");
</code></pre>
<p dir="auto">then everything works and the CB knob does NOT jump back to 100% and all is well.</p>
]]></description><link>https://forum.gui-o.com/post/620</link><guid isPermaLink="true">https://forum.gui-o.com/post/620</guid><dc:creator><![CDATA[VNB]]></dc:creator><pubDate>Tue, 26 Sep 2023 20:14:56 GMT</pubDate></item><item><title><![CDATA[Reply to GUI-O with Nano 33 BLE and the ArduinoBLE Library on Tue, 26 Sep 2023 20:11:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.gui-o.com/uid/2">@gammda</a> Hi gammda,</p>
<p dir="auto">I’m not sure what you mean. There is nothing listed under “Try this”<br />
but thank you.<br />
Vince</p>
]]></description><link>https://forum.gui-o.com/post/619</link><guid isPermaLink="true">https://forum.gui-o.com/post/619</guid><dc:creator><![CDATA[VNB]]></dc:creator><pubDate>Tue, 26 Sep 2023 20:11:35 GMT</pubDate></item><item><title><![CDATA[Reply to GUI-O with Nano 33 BLE and the ArduinoBLE Library on Tue, 26 Sep 2023 06:03:36 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.gui-o.com/uid/615">@VNB</a> said in <a href="/post/614">GUI-O with Nano 33 BLE and the ArduinoBLE Library</a>:</p>
<blockquote>
<p dir="auto">[2023-09-20T09:13:57.992] @init<br />
[2023-09-20T09:13:57.996] @cls<br />
[2023-09-20T09:13:58.023] @guis BGC:#FFFFFF<br />
[2023-09-20T09:13:58.180] |LB UID:title X:50 Y:15 TXT:"Simple light switch" FFA:"font8" FSZ:3.5<br />
[2023-09-20T09:13:58.239] |LB UID:tap_me X:50 Y:70 TXT:"TAP ME!" FFA:"font8" FSZ:3 FFA:"font5"<br />
[2023-09-20T09:13:58.295] |CB UID:brightness X:50 Y:50 W:90 BTH:5 HAH:8 HAW:8 VIS:0 STA:135 ENA:45 FGC:#000000 SFGC:#FFFF00 BGC:#CBCBCB<br />
[2023-09-20T09:13:58.340] |IM UID:light_off X:50 Y:50 IP:"<a href="https://i.imgur.com/3VbsS0Z.png" rel="nofollow ugc">https://i.imgur.com/3VbsS0Z.png</a>" VIS:1<br />
[2023-09-20T09:13:58.395] |IM UID:light_on X:50 Y:50 IP:"<a href="https://i.imgur.com/gNdck9A.png" rel="nofollow ugc">https://i.imgur.com/gNdck9A.png</a>" VIS:0<br />
[2023-09-20T09:14:05.913] @light_off 1<br />
[2023-09-20T09:14:05.913] @light_off VIS:0<br />
[2023-09-20T09:14:05.943] @light_on VIS:1<br />
[2023-09-20T09:14:06.004] @brightness VIS:1 VAL:100<br />
[2023-09-20T09:14:12.333] @brightness 45.8<br />
[2023-09-20T09:14:15.932] @brightness 16.7<br />
[2023-09-20T09:14:19.772] @brightness 5.4</p>
</blockquote>
<p dir="auto">Try this:</p>
<pre><code></code></pre>
<pre><code></code></pre>
<pre><code></code></pre>
<p dir="auto">@init<br />
@cls<br />
@guis BGC:#FFFFFF<br />
|LB UID:title X:50 Y:15 TXT:"Simple light switch" FFA:"font8" FSZ:3.5<br />
|LB UID:tap_me X:50 Y:70 TXT:"TAP ME!" FFA:"font8" FSZ:3 FFA:"font5"<br />
|CB UID:brightness X:50 Y:50 W:90 BTH:5 HAH:8 HAW:8 VIS:0 STA:135 ENA:45 FGC:#000000 SFGC:#FFFF00 BGC:#CBCBCB<br />
|IM UID:light_off X:50 Y:50 IP:"<a href="https://i.imgur.com/3VbsS0Z.png" rel="nofollow ugc">https://i.imgur.com/3VbsS0Z.png</a>" VIS:1<br />
|IM UID:light_on X:50 Y:50 IP:"<a href="https://i.imgur.com/gNdck9A.png" rel="nofollow ugc">https://i.imgur.com/gNdck9A.png</a>" VIS:0<br />
@light_off 1<br />
@light_off VIS:0<br />
@light_on VIS:1<br />
@brightness VIS:1 VAL:50<br />
@brightness VAL:45.8<br />
@brightness VAL:16.7<br />
@brightness VAL:5.4</p>
<pre><code></code></pre>
<pre><code></code></pre>
<pre><code></code></pre>
<p dir="auto">...VAL:... is missing.</p>
]]></description><link>https://forum.gui-o.com/post/618</link><guid isPermaLink="true">https://forum.gui-o.com/post/618</guid><dc:creator><![CDATA[gammda]]></dc:creator><pubDate>Tue, 26 Sep 2023 06:03:36 GMT</pubDate></item><item><title><![CDATA[Reply to GUI-O with Nano 33 BLE and the ArduinoBLE Library on Wed, 20 Sep 2023 15:01:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.gui-o.com/uid/4">@kl3m3n</a><br />
Here are the test results you requested. Everything looks normal to me and there does not appear to be any reason for the CB control to snap back to 100% but it always does.</p>
<p dir="auto">1.) Reset Nano, and serial prints:<br />
Bluetooth<img src="https://forum.gui-o.com/assets/plugins/nodebb-plugin-emoji/emoji/android/00ae.png?v=29eca934c85" class="not-responsive emoji emoji-android emoji--registered" style="height:23px;width:auto;vertical-align:middle" title=":registered:" alt="®" /> device active, waiting for connections...</p>
<p dir="auto">2.) Start GUI on phone and serial prints:<br />
Connected!</p>
<p dir="auto">3.) Click large center connect button of GUI on phone and serial prints:<br />
Parsing . . .<br />
GUI-O app is requesting INITIALIZATION!<br />
and phone displays the Light Off image</p>
<p dir="auto">4.) Click TAP ME! and serial prints:<br />
Parsing . . .<br />
GUI-O app is requesting LIGHT ON!<br />
Just set CB to 100%<br />
and phone displays Light On image and CB control at 100%.</p>
<p dir="auto">5.) Tap near the center of CB control and when release the serial prints:<br />
Parsing . . .<br />
GUI-O app requesting Brightness change!<br />
GUI-O app is requesting LIGHT BRIGHTNESS: 45<br />
and the phone displays the CB control at 45% as long as I hold it but when I<br />
release it the LED reduces brightness like it should but the CB control snaps back to 100%.</p>
<p dir="auto">6.) Trying a 2nd time, tap lower on CB control and when release the serial prints:<br />
Parsing . . .<br />
GUI-O app requesting Brightness change!<br />
GUI-O app is requesting LIGHT BRIGHTNESS: 16<br />
and the phone displays the CB control at 16% as long as I hold it but<br />
when I release it the LED reduces brightness but the CB control snaps back to 100%.</p>
<p dir="auto">7.) Trying a 3rd time, tap low on CB control and when release the serial prints:<br />
Parsing . . .<br />
GUI-O app requesting Brightness change!<br />
GUI-O app is requesting LIGHT BRIGHTNESS: 5<br />
and the phone displays the CB control at 5% as long as I hold it but<br />
when I release it the LED reduces brightness but the CB control snaps back to 100%.</p>
<p dir="auto">8.) Exit the GUI on the phone and serial prints:<br />
Disconnected!</p>
<p dir="auto">9.) Using PC Explorer open in_messages.log file to get:</p>
<p dir="auto">[2023-09-20T09:13:57.992] @init<br />
[2023-09-20T09:13:57.996] @cls<br />
[2023-09-20T09:13:58.023] @guis BGC:#FFFFFF<br />
[2023-09-20T09:13:58.180] |LB UID:title X:50 Y:15 TXT:"Simple light switch" FFA:"font8" FSZ:3.5<br />
[2023-09-20T09:13:58.239] |LB UID:tap_me X:50 Y:70 TXT:"TAP ME!" FFA:"font8" FSZ:3 FFA:"font5"<br />
[2023-09-20T09:13:58.295] |CB UID:brightness X:50 Y:50 W:90 BTH:5 HAH:8 HAW:8 VIS:0 STA:135 ENA:45 FGC:#000000 SFGC:#FFFF00 BGC:#CBCBCB<br />
[2023-09-20T09:13:58.340] |IM UID:light_off X:50 Y:50 IP:"<a href="https://i.imgur.com/3VbsS0Z.png" rel="nofollow ugc">https://i.imgur.com/3VbsS0Z.png</a>" VIS:1<br />
[2023-09-20T09:13:58.395] |IM UID:light_on X:50 Y:50 IP:"<a href="https://i.imgur.com/gNdck9A.png" rel="nofollow ugc">https://i.imgur.com/gNdck9A.png</a>" VIS:0<br />
[2023-09-20T09:14:05.913] @light_off 1<br />
[2023-09-20T09:14:05.913] @light_off VIS:0<br />
[2023-09-20T09:14:05.943] @light_on VIS:1<br />
[2023-09-20T09:14:06.004] @brightness VIS:1 VAL:100<br />
[2023-09-20T09:14:12.333] @brightness 45.8<br />
[2023-09-20T09:14:15.932] @brightness 16.7<br />
[2023-09-20T09:14:19.772] @brightness 5.4</p>
<p dir="auto">To me the Log shows everything is working correctly but the CB control on the phone always jumps back to 100%.<br />
I have 14 sec video of above but it won't let me upload it (too big).</p>
<p dir="auto">Hope this helps<br />
Vince</p>
]]></description><link>https://forum.gui-o.com/post/614</link><guid isPermaLink="true">https://forum.gui-o.com/post/614</guid><dc:creator><![CDATA[VNB]]></dc:creator><pubDate>Wed, 20 Sep 2023 15:01:09 GMT</pubDate></item><item><title><![CDATA[Reply to GUI-O with Nano 33 BLE and the ArduinoBLE Library on Mon, 18 Sep 2023 20:36:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.gui-o.com/uid/615">@VNB</a> Hi!</p>
<p dir="auto">Can you open GUI-O and navigate to "Settings-&gt;Info" and tap on "Powered by GUI-O version" 10 times. At the bottom, a new menu (Developer mode) should appear. From this menu, you can enable "Log incoming messages".</p>
<p dir="auto">You can then repeat the procedure with Arduino Nano and exit the GUI-O application when done. Then you can open the GUI-O files folder (best viewed on PC) and check the contents of the incoming log file. Does the log show setting the CB value to 100 (or higher, but gets limited at 100) when the CB widget "jumps" to 100?</p>
<p dir="auto">Note that the log file is overwritten on next GUI-O start.</p>
<p dir="auto">Don't forget to disable logging when done.</p>
<p dir="auto">Best regards,<br />
kl3m3n</p>
]]></description><link>https://forum.gui-o.com/post/613</link><guid isPermaLink="true">https://forum.gui-o.com/post/613</guid><dc:creator><![CDATA[kl3m3n]]></dc:creator><pubDate>Mon, 18 Sep 2023 20:36:59 GMT</pubDate></item><item><title><![CDATA[Reply to GUI-O with Nano 33 BLE and the ArduinoBLE Library on Wed, 13 Sep 2023 16:33:38 GMT]]></title><description><![CDATA[<p dir="auto">I agree something strange is happening. As suggested I added a bunch of Serial prints but the program flow looks correct to me.</p>
<p dir="auto">For example I added code to print “Just set CB to 100%” as shown below:<br />
<strong>sendMsg("@light_off VIS:0\r\n");<br />
sendMsg("@light_on VIS:1\r\n");<br />
sendMsg("@brightness VIS:1 VAL:100\r\n");<br />
Serial.println("Just set CB to 100%");</strong><br />
which like you said is the only instruction where the CB slider gets set back to 100.</p>
<p dir="auto">However when I touch CB (at 50% for example) it changes the brightness and prints<br />
<strong>GUI-O app requesting Brightness change!<br />
GUI-O app is requesting LIGHT BRIGHTNESS: 50</strong><br />
just like it should but it never prints<br />
<strong>Just set CB to 100%</strong><br />
even though the CB knob instantly jumps back to 100 when I release it.</p>
<p dir="auto">When I toggle the LED off it prints:<br />
<strong>GUI-O app is requesting LIGHT OFF!</strong><br />
and when I toggle the LED back on it prints:<br />
<strong>GUI-O app is requesting LIGHT ON!<br />
Just set CB to 100%</strong><br />
just like it should. The problem persists and is puzzling.</p>
<p dir="auto">Here is another symptom which may help. When I add the “fix” instruction<br />
<strong>sendMsg("@brightness VIS:1 VAL:val\r\n");</strong><br />
then the first time I change the brightness the CB knob always jumps back to 100 but from then on it works correctly and the knob remains at the position I select. If I toggle the LED off and back on then again the first time I use the CB control the knob always jumps back to 100 but from then on it works correctly.</p>
<p dir="auto">CONCLUSION: When the CB knob incorrectly jumps back to 100 the only instruction that sets CB back to 100 never gets executed. Is there any “hidden” code that gets executed, maybe parts of the Event Handlers or something?</p>
<p dir="auto">Let me know if there is a specific test you would like me to try.</p>
<p dir="auto">Thank you, Vince</p>
]]></description><link>https://forum.gui-o.com/post/611</link><guid isPermaLink="true">https://forum.gui-o.com/post/611</guid><dc:creator><![CDATA[VNB]]></dc:creator><pubDate>Wed, 13 Sep 2023 16:33:38 GMT</pubDate></item><item><title><![CDATA[Reply to GUI-O with Nano 33 BLE and the ArduinoBLE Library on Wed, 13 Sep 2023 10:15:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.gui-o.com/uid/615">@VNB</a> said in <a href="/post/609">GUI-O with Nano 33 BLE and the ArduinoBLE Library</a>:</p>
<blockquote>
<p dir="auto">2.) Once the brightness is adjusted then the Nano Yellow LED STAYS on at the selected brightness even though the "on" and "off" light bulb image toggles okay and Serial Monitor correctly displays "GUI-O app is requesting LIGHT ON!" and "GUI-O app is requesting LIGHT OFF!". That was fixed by always keeping the 'ledPin' in the 'analog' mode by changing digitalWrite(ledPin, HIGH); to analogWrite(ledPin, 0); and digitalWrite(ledPin, LOW); to analogWrite(ledPin, 255);</p>
</blockquote>
<p dir="auto">Ok, my mistake. The <code>digitalWrite</code> overrides the <code>analogWrite</code>, disabling the PWM.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.gui-o.com/uid/615">@VNB</a> said in <a href="/post/609">GUI-O with Nano 33 BLE and the ArduinoBLE Library</a>:</p>
<blockquote>
<p dir="auto">1.) The Slider Control knob always stayed at 100% even if it is set to a low brightness. That was fixed by adding the following instruction in the "led drive" section.<br />
sendMsg("@brightness VIS:1 VAL:val\r\n");</p>
</blockquote>
<p dir="auto">This is strange and requires further investigation... It seems that the <code>@light_on</code> is called - this can be the only reason that sets the slider value to 100... Something is not working correctly.</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.gui-o.com/uid/615">@VNB</a> said in <a href="/post/609">GUI-O with Nano 33 BLE and the ArduinoBLE Library</a>:</p>
<blockquote>
<p dir="auto">sendMsg("@brightness VIS:1 VAL:val\r\n");</p>
</blockquote>
<p dir="auto">This sends the literal "val", not the actual brightness value.</p>
<p dir="auto">I suggest you put some Serial.print's at the beginning of the message parsing function to see what happens.</p>
<p dir="auto">Best regards,<br />
kl3m3n</p>
]]></description><link>https://forum.gui-o.com/post/610</link><guid isPermaLink="true">https://forum.gui-o.com/post/610</guid><dc:creator><![CDATA[kl3m3n]]></dc:creator><pubDate>Wed, 13 Sep 2023 10:15:59 GMT</pubDate></item><item><title><![CDATA[Reply to GUI-O with Nano 33 BLE and the ArduinoBLE Library on Tue, 12 Sep 2023 20:16:23 GMT]]></title><description><![CDATA[<p dir="auto">YES, it works. Thank you so much!</p>
<p dir="auto">There were two minor problems.<br />
1.) The Slider Control knob always stayed at 100% even if it is set to a low brightness. That was fixed by adding the following instruction in the "led drive" section.<br />
sendMsg("@brightness VIS:1 VAL:val\r\n");</p>
<p dir="auto">2.) Once the brightness is adjusted then the Nano Yellow LED STAYS on at the selected brightness even though the "on" and "off" light bulb image toggles okay and Serial Monitor correctly displays "GUI-O app is requesting LIGHT ON!" and "GUI-O app is requesting LIGHT OFF!". That was fixed by always keeping the 'ledPin' in the 'analog' mode by changing digitalWrite(ledPin, HIGH); to	analogWrite(ledPin, 0); and digitalWrite(ledPin, LOW); to analogWrite(ledPin, 255);</p>
<p dir="auto">The modified code is below.</p>
<p dir="auto">Thanks again for GREAT service!<br />
Vince</p>
<pre><code>/*
  GUI-O BLE example (Nano 33 BLE) original file is "ButtonLED_GUI-O.ino"
  The 'Button LED' example found in 'File-Examples-ArdunioBLE-Peripheral-ButtonLED' was
  modified by kl3m3n to work with the Nano 33 BLE Sense board and ArduinoBLE.h library.
  
  Operation:
    * Click TAP HERE to toggle Nano 33 Yellow LED On/Off.
    * When the LED is ON a Slider control is displayed and will adjust the Brightness of LED. 
    * Brightness is not remembered so toggling the LED Off and back On will always select 100% brightness.
*/

#include &lt;ArduinoBLE.h&gt;

const int ledPin = LED_BUILTIN; // set ledPin to on-board LED
const int maxMsgLength{256};

BLEService guioService("0000FFE0-0000-1000-8000-00805F9B34FB"); // create service

// create gui-o (string) characteristic and allow remote device to read and write
BLEStringCharacteristic guioCharacteristic("0000FFE1-0000-1000-8000-00805F9B34FB", BLERead | BLEWrite | BLENotify | BLEIndicate, maxMsgLength);

void setup() {
  Serial.begin(9600);
  while (!Serial);

  pinMode(ledPin, OUTPUT); // use the LED as an output

  // begin initialization
  if (!BLE.begin()) {
    Serial.println("starting Bluetooth® Low Energy module failed!");

    while (1);
  }

  // set the local name peripheral advertises
  BLE.setLocalName("GUI-O_BLE");
  // set the UUID for the service this peripheral advertises:
  BLE.setAdvertisedService(guioService);

  // add the characteristics to the service
  guioService.addCharacteristic(guioCharacteristic);

  // add the service
  BLE.addService(guioService);

  // assign event handlers for connected, disconnected to peripheral
  BLE.setEventHandler(BLEConnected, [](BLEDevice central) -&gt; void {
    Serial.println("Connected!");
  });
  BLE.setEventHandler(BLEDisconnected, [](BLEDevice central) -&gt; void {
    Serial.println("Disconnected!");
  });

  // assign event handlers for characteristic
  guioCharacteristic.setEventHandler(BLEWritten, parseGuioMsg);

  // start advertising
  BLE.advertise();

  Serial.println("Bluetooth® device active, waiting for connections...");
}

void loop() {
  // poll for Bluetooth® Low Energy events
  BLE.poll();
}

/***************************/
/* IMPLEMENT YOUR GUI HERE */
/***************************/
void sendMsg(const String &amp;msg) {
  guioCharacteristic.writeValue(msg);
  delay(50);
}

void parseGuioMsg(BLEDevice central, BLECharacteristic characteristic) {
  const uint8_t* value = characteristic.value();
  const int length = characteristic.valueLength();

  const String msg(reinterpret_cast&lt;const char*&gt;(value), length);

  if(msg.startsWith("@init")) {
    Serial.println("GUI-O app is requesting INITIALIZATION!");

    // clear screen and set background
    sendMsg("@cls\r\n");
    sendMsg("@guis BGC:#FFFFFF\r\n");
    delay(100);

    // initialize simple example GUI
    sendMsg("|LB UID:title X:50 Y:15 TXT:\"Simple light switch\" FFA:\"font8\" FSZ:3.5\r\n");
    sendMsg("|LB UID:tap_me X:50 Y:70 TXT:\"TAP ME!\" FFA:\"font8\" FSZ:3 FFA:\"font5\"\r\n");
    sendMsg("|CB UID:brightness X:50 Y:50 W:90 BTH:5 HAH:8 HAW:8 VIS:0 STA:135 ENA:45 FGC:#000000 SFGC:#FFFF00 BGC:#CBCBCB\r\n");
    sendMsg("|IM UID:light_off X:50 Y:50 IP:\"https://i.imgur.com/3VbsS0Z.png\" VIS:1\r\n");
    sendMsg("|IM UID:light_on X:50 Y:50 IP:\"https://i.imgur.com/gNdck9A.png\" VIS:0\r\n");    
  }
  else if(msg.startsWith("@light_off")) {
    Serial.println("GUI-O app is requesting LIGHT ON!");

    // "drive GUI-O app"
    sendMsg("@light_off VIS:0\r\n");
    sendMsg("@light_on VIS:1\r\n");
    sendMsg("@brightness VIS:1 VAL:100\r\n");

    // led enable
    analogWrite(ledPin, 255);
  }
  else if(msg.startsWith("@light_on")) {
    Serial.println("GUI-O app is requesting LIGHT OFF!");

    // "drive GUI-O app"
    sendMsg("@light_off VIS:1\r\n");
    sendMsg("@light_on VIS:0\r\n");
    sendMsg("@brightness VIS:0 VAL:0\r\n");

    // led disable
    analogWrite(ledPin, 0);
  }
  else if(msg.startsWith("@brightness")) {
    const int idx = msg.indexOf(' ');
    
    if(idx &gt; 0) {
      const int val = msg.substring(idx + 1).toInt();
      
      if(val &gt;= 0 &amp;&amp; val &lt;= 100) {
        Serial.print("GUI-O app is requesting LIGHT BRIGHTNESS: ");
        Serial.println(val);

        // led drive
        analogWrite(ledPin, static_cast&lt;uint8_t&gt;(val * 2.55));
        sendMsg("@brightness VIS:1 VAL:val\r\n");                 // Added to make CB show where I adjust brightness
      }            
    }    
  }  
}
``</code></pre>
]]></description><link>https://forum.gui-o.com/post/609</link><guid isPermaLink="true">https://forum.gui-o.com/post/609</guid><dc:creator><![CDATA[VNB]]></dc:creator><pubDate>Tue, 12 Sep 2023 20:16:23 GMT</pubDate></item><item><title><![CDATA[Reply to GUI-O with Nano 33 BLE and the ArduinoBLE Library on Tue, 12 Sep 2023 09:56:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.gui-o.com/uid/615">@VNB</a> Hi.</p>
<p dir="auto">I have not tested this (don't have Arduino Nano 33 BLE), so I don't guarantee correctness of the code (it compiles fine). It should get you started though (I suggest using serial to debug). Please give some feedback.</p>
<p dir="auto">Best regards,<br />
kl3m3n</p>
<pre><code>/*
  GUI-O BLE example (Nano 33 BLE)
*/

#include &lt;ArduinoBLE.h&gt;

const int ledPin = LED_BUILTIN; // set ledPin to on-board LED
const int maxMsgLength{256};

BLEService guioService("0000FFE0-0000-1000-8000-00805F9B34FB"); // create service

// create gui-o (string) characteristic and allow remote device to read and write
BLEStringCharacteristic guioCharacteristic("0000FFE1-0000-1000-8000-00805F9B34FB", BLERead | BLEWrite | BLENotify | BLEIndicate, maxMsgLength);

void setup() {
  Serial.begin(9600);
  while (!Serial);

  pinMode(ledPin, OUTPUT); // use the LED as an output

  // begin initialization
  if (!BLE.begin()) {
    Serial.println("starting Bluetooth® Low Energy module failed!");

    while (1);
  }

  // set the local name peripheral advertises
  BLE.setLocalName("GUI-O_BLE");
  // set the UUID for the service this peripheral advertises:
  BLE.setAdvertisedService(guioService);

  // add the characteristics to the service
  guioService.addCharacteristic(guioCharacteristic);

  // add the service
  BLE.addService(guioService);

  // assign event handlers for connected, disconnected to peripheral
  BLE.setEventHandler(BLEConnected, [](BLEDevice central) -&gt; void {
    Serial.println("Connected!");
  });
  BLE.setEventHandler(BLEDisconnected, [](BLEDevice central) -&gt; void {
    Serial.println("Disconnected!");
  });

  // assign event handlers for characteristic
  guioCharacteristic.setEventHandler(BLEWritten, parseGuioMsg);

  // start advertising
  BLE.advertise();

  Serial.println("Bluetooth® device active, waiting for connections...");
}

void loop() {
  // poll for Bluetooth® Low Energy events
  BLE.poll();
}

/***************************/
/* IMPLEMENT YOUR GUI HERE */
/***************************/
void sendMsg(const String &amp;msg) {
  guioCharacteristic.writeValue(msg);
  delay(50);
}

void parseGuioMsg(BLEDevice central, BLECharacteristic characteristic) {
  const uint8_t* value = characteristic.value();
  const int length = characteristic.valueLength();

  const String msg(reinterpret_cast&lt;const char*&gt;(value), length);

  if(msg.startsWith("@init")) {
    Serial.println("GUI-O app is requesting INITIALIZATION!");

    // clear screen and set background
    sendMsg("@cls\r\n");
    sendMsg("@guis BGC:#FFFFFF\r\n");
    delay(100);

    // initialize simple example GUI
    sendMsg("|LB UID:title X:50 Y:15 TXT:\"Simple light switch\" FFA:\"font8\" FSZ:3.5\r\n");
    sendMsg("|LB UID:tap_me X:50 Y:70 TXT:\"TAP ME!\" FFA:\"font8\" FSZ:3 FFA:\"font5\"\r\n");
    sendMsg("|CB UID:brightness X:50 Y:50 W:90 BTH:5 HAH:8 HAW:8 VIS:0 STA:135 ENA:45 FGC:#000000 SFGC:#FFFF00 BGC:#CBCBCB\r\n");
    sendMsg("|IM UID:light_off X:50 Y:50 IP:\"https://i.imgur.com/3VbsS0Z.png\" VIS:1\r\n");
    sendMsg("|IM UID:light_on X:50 Y:50 IP:\"https://i.imgur.com/gNdck9A.png\" VIS:0\r\n");    
  }
  else if(msg.startsWith("@light_off")) {
    Serial.println("GUI-O app is requesting LIGHT ON!");

    // "drive GUI-O app"
    sendMsg("@light_off VIS:0\r\n");
    sendMsg("@light_on VIS:1\r\n");
    sendMsg("@brightness VIS:1 VAL:100\r\n");

    // led enable
    digitalWrite(ledPin, HIGH);
  }
  else if(msg.startsWith("@light_on")) {
    Serial.println("GUI-O app is requesting LIGHT OFF!");

    // "drive GUI-O app"
    sendMsg("@light_off VIS:1\r\n");
    sendMsg("@light_on VIS:0\r\n");
    sendMsg("@brightness VIS:0 VAL:0\r\n");

    // led disable
    digitalWrite(ledPin, LOW);
  }
  else if(msg.startsWith("@brightness")) {
    const int idx = msg.indexOf(' ');
    
    if(idx &gt; 0) {
      const int val = msg.substring(idx + 1).toInt();
      
      if(val &gt;= 0 &amp;&amp; val &lt;= 100) {
        Serial.print("GUI-O app is requesting LIGHT BRIGHTNESS: ");
        Serial.println(val);

        // led drive
        analogWrite(ledPin, static_cast&lt;uint8_t&gt;(val * 2.55));
      }            
    }    
  }  
}


</code></pre>
]]></description><link>https://forum.gui-o.com/post/606</link><guid isPermaLink="true">https://forum.gui-o.com/post/606</guid><dc:creator><![CDATA[kl3m3n]]></dc:creator><pubDate>Tue, 12 Sep 2023 09:56:51 GMT</pubDate></item><item><title><![CDATA[Reply to GUI-O with Nano 33 BLE and the ArduinoBLE Library on Mon, 04 Sep 2023 16:00:16 GMT]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">Give me a couple of days, and I will try to modify the example you've provided.</p>
<p dir="auto">I will post the result here.</p>
<p dir="auto">Best regards<br />
kl3m3n</p>
]]></description><link>https://forum.gui-o.com/post/594</link><guid isPermaLink="true">https://forum.gui-o.com/post/594</guid><dc:creator><![CDATA[kl3m3n]]></dc:creator><pubDate>Mon, 04 Sep 2023 16:00:16 GMT</pubDate></item></channel></rss>