Community.

Your question might be already answered in the FAQ page

?

Issues with bluetoo...
 
Notifications
Clear all

[Solved] Issues with bluetooth connection for webcode

6 Posts
4 Users
2 Reactions
45 Views
(@jobroe)
New Member
Joined: 2 months ago
Posts: 2
Topic starter  

Hi,

I followed the guide but I can't get it working. I click "Save Blue Code" and then otto is blinking blue. If I click on the bluetooth button a window opens for scanning for Bluetooth devices but no device occur. It sounds as it would be an browser issue but for remote control it works like expected.

Any Idea ?

Thanks


   
Quote
Camilo
(@cparrapa)
Developer Admin
Joined: 8 months ago
Posts: 23
 

Hi @jobroe

It seems the Bluetooth code for programming wireless in web code is not being save properly, because if it is blinking blue that means is the code for remote control (it is a different code).

Try again and make sure the right code is inside Otto, for this you can click on settings/ Files in Otto then click on main.py

You should see a code like the attached screenshot.

Alternately you can save this code as main in code text mode or using Thonny IDE:

from machine import Pin, PWM
import bluetooth
from ottoble import BLESimplePeripheral
import time
# Create a Bluetooth Low Energy (BLE) object
ble = bluetooth.BLE()
# Create an instance of the BLESimplePeripheral class with the BLE object
sp = BLESimplePeripheral(ble, "6E400001-B5A3-F393-E0A9-E50E24DCCA9E", "6E400003-B5A3-F393-E0A9-E50E24DCCA9E", "6E400002-B5A3-F393-E0A9-E50E24DCCA9E","Otto")
i = 0
commandSet = bytearray(b'')
key = bytearray(b'EoChunk')
last_chars = b''
      
def on_rx(x):
    global i, commandSet, key, last_chars
    commandSet.extend(x)
    print(x)
    last_command = commandSet[:]
    last_chars = last_command[-len(key):]
    
    if last_chars == key:
        realCommand = commandSet[:-len(key)].decode("utf-8")
        try:
            exec(realCommand)
        except Exception as e:
            print (e)
        commandSet = bytearray(b'')
sp.on_write(on_rx)

   
ReplyQuote
(@alex-just-alex)
New Member
Joined: 7 months ago
Posts: 2
 

I'm running that code but the editor still doesnt see Otto (although my PC does)

Alex


   
ReplyQuote
(@delphi)
New Member
Joined: 1 week ago
Posts: 1
 

@cparrapa

Thx this fixed it for me!

 

webcontrol still won't work, first I get the error

Cannot read properties of null (reading 'appendChild') at new JOYSTICK (joystick.js:1:170)

and as soon as i try to connect using bluetooth

Uncaught (in promise) DOMException: GATT operation not permitted.

 

if I upload the webcontrol code, that screws up my main.py and breaks bluetooth again


   
ReplyQuote
Camilo
(@cparrapa)
Developer Admin
Joined: 8 months ago
Posts: 23
 

Hi @delphi
We have a new feature for re-naming the bluetooth device for webcontrol, uploading any new code will overwrite the main.py file, therefore you only can have one of this options working at the same time:

1. A code saved by you, using the "Save to Otto" button in Otto, (sometimes it could be empty) Whatever you put in block or text it will execute automatically when Otto turns on even without the cable.

2. BLE code "Bluetooth programming mode" for webcode icons or words.

3. control code "remote control mode" for webcontrol only.

So far we have not find a way to have more than one of these codes together without writing on top of the same file, or at least combine ble with control. For now let's just get familiar with their differences. 

With @ivanr3d we will check those errors in web Remote control separate topics.


   
ReplyQuote
(@alex-just-alex)
New Member
Joined: 7 months ago
Posts: 2
 

I posted about a problem with Chrome seeing bluetooth devices. It was cured by a reboot of my PC! 🤦


   
Camilo reacted
ReplyQuote
Share:
Scroll to Top
Thank you for your interest in our robot Otto.
Let us inform you that the Otto Starter Kit will be ready for purchase at the end of January 2024.

If you would like to pre-order Otto Starter kit, feel free to contact us at email address moravia@moravia-consulting.com.
This will be available with the release of this product.