[Solved] Issues with bluetooth connection for webcode
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
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) 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
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.
- 16 Forums
- 60 Topics
- 295 Posts
- 2 Online
- 3,234 Members
