LOPY BLE Peripheral
-
Hi i am beginner of LOPY
I am trying to send pysense data to i phone from BLE
As a result i am trying to {lopy as Peripheral -------(send data)------->i phone (central)}
My question is- Is there any Peripheral example to follow??
- I have import the library on the code however there is no file Bluetooth or network (Not sure where to find the library if i need to upload with Pymakr )
- why the code below result as 9999999999999??
I use the code below
import ubinascii from network import Bluetooth from time import sleep bt = Bluetooth() bt.init() bt.set_advertisement(name="lopy", manufacturer_data="lopy_v1") if bt.isscanning(): bt.stop_scan() bt.start_scan(-1) while bt.isscanning(): adv = bt.get_adv() if adv: print(adv)RESULT::
mode:DIO, clock div:1
load:0x3fff8028,len:8
load:0x3fff8030,len:1728
load:0x4009fa00,len:0
load:0x4009fa00,len:14612
entry 0x400a059c
9
9
9
9
9
9
9
9 -
I get it pair with IOS however i dont know how to sent data over,
Is anyone can give me an example on thisimport binascii from network import Bluetooth from machine import Timer import time bluetooth = Bluetooth() bluetooth.set_advertisement(name='LoPy', service_uuid=b'1234567890123456') def conn_cb (bt_o): events = bt_o.events() # this method returns the flags and clears the internal registry if events & Bluetooth.CLIENT_CONNECTED: print("Client connected") while True: print("data send") bluetooth.set_advertisement(name='LoPy',manufacturer_data="lopy_v1") time.sleep(2.050) elif events & Bluetooth.CLIENT_DISCONNECTED: print("Client disconnected") bluetooth.callback(trigger=Bluetooth.CLIENT_CONNECTED | Bluetooth.CLIENT_DISCONNECTED, handler=conn_cb) bluetooth.advertise(True) -
For BLE pairing is not needed.
Look at this example: https://docs.pycom.io/firmwareapi/pycom/network/bluetooth/gattscharacteristic.html
To send data, use:
chr2.value(MyData)
Johan
-
Thanks for the answer this work prefect
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better đź’—
Register Login