🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    micropython with ble

    Scheduled Pinned Locked Moved PRODUCTS
    7 Posts 3 Posters 13.9k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      jpilarski
      last edited by jpilarski

      I came across the following code for ble on dfrobot firebeetle esp32:
      https://www.dfrobot.com/forum/viewtopic.php?t=2985

      import gc
      import sys
      import network as n
      import gc
      import time
      
      b = n.Bluetooth()
      
      found = {}
      complete = True
      
      def bcb(b,e,d,u):
       global complete
       global found
       if e == b.CONNECT:
         print("CONNECT")
         b.ble_settings(adv_man_name = "firebeetle-esp32", adv_dev_name="firebeetle-esp32")
         b.ble_adv_enable(True)
       elif e == b.DISCONNECT:
               print("DISCONNECT")
       else:
         print ('Unknown event', e,d)
      
      def cb (cb, event, value, userdata):
       print('charcb ', cb, userdata, ' ', end='')
       if event == b.READ:
         print('Read')
         return 'ABCDEFG'
       elif event == b.WRITE:
         print ('Write', value)
      
      def gatts():
       s1 = b.Service(0xaabb)
       s2 = b.Service(0xDEAD)
      
       c1 = s1.Char(0xccdd)
       c2 = s2.Char(0xccdd)
      
       c1.callback(cb, 'c1 data')
       c2.callback(cb, 'c2 data')
      
       s1.start()
       s2.start()
      
       b.ble_settings(adv_man_name = "firebeetle-esp32", adv_dev_name="firebeetle-esp32")
       b.ble_adv_enable(True)
      
      b.callback(bcb)
      gatts()
      while(True):
       pass
      

      I tried it on the firebeetle and it works. When I try it on the M5 it uploads but I believe there is a difference in the network module that is keeping it from running. Is it possible for someone with micropython experience to take a look and see how this code can be ported to the m5. I'll take any suggestions I can get. thanks

      RopR 1 Reply Last reply Reply Quote 0
      • RopR Offline
        Rop @jpilarski
        last edited by

        @jpilarski Can't really help you with the problem at hand, but if you edit the message and replace <code> and </code> with three backticks ( ``` ) it will be much easier to read.

        1 Reply Last reply Reply Quote 0
        • J Offline
          jpilarski
          last edited by

          Another way of asking my question is how can I use bluetooth on M5go or M5stack running micropython. It seems to me like a new firmware is needed for bluetooth to be enabled. The LOBO esp32 build now looks to have bluetooth capabilities. How does one go about adding the m5stack libraries to a newer LOBO esp32 firmware or is it possible for the M5 micropython/M5go micropython firmware to be updated to include bluetooth.

          loborisL 1 Reply Last reply Reply Quote 0
          • loborisL Offline
            loboris @jpilarski
            last edited by

            @jpilarski 在 micropython with ble 中说:

            Another way of asking my question is how can I use bluetooth on M5go or M5stack running micropython. It seems to me like a new firmware is needed for bluetooth to be enabled. The LOBO esp32 build now looks to have bluetooth capabilities. How does one go about adding the m5stack libraries to a newer LOBO esp32 firmware or is it possible for the M5 micropython/M5go micropython firmware to be updated to include bluetooth.

            No full BT support is available yet in LoBo-MicroPython. BT RFCOMM is implemented (same functionality as the UART module, the documentation should be available later this week), and I'm planning to finish the BLE support next month.

            1 Reply Last reply Reply Quote 0
            • J Offline
              jpilarski
              last edited by

              That's amazing thanks for the response and for all the hard work. I am trying to learn micropython and the one thing I am trying to understand is for the m5go there are two files the bin and the img. If the img is the filesystem can I use esptools to upload your newer firmware bin files with the existing img file to get newer features while still having access to m5go web ide. Also is it possible to include telnet in M5STACK for webrepl. I saw you suggested in a previous discussion that is a way to use wifi and connect to repl. When I try to use telnet it isn't included in network library on M5STACK. I think what I need to learn is how I can add features to micropython firmware yet still have the M5STACK api. Can you suggest how to do this or where to learn more about this. Sorry for such a long post it's just really interesting and I want to try to understand this better.

              loborisL 1 Reply Last reply Reply Quote 0
              • loborisL Offline
                loboris @jpilarski
                last edited by

                @jpilarski 在 micropython with ble 中说:

                ... Can you suggest how to do this or where to learn more about this...

                You can use my MicroPython port on M5Stack without any changes.
                Most of the information needed can be found on the Wiki pages.
                You can find some helper functions to use it on M5Stack here.
                I'll try to add some information about using this MicroPython port on M5Stack on the Wiki pages when I'll find some time.

                1 Reply Last reply Reply Quote 0
                • J Offline
                  jpilarski
                  last edited by

                  Thanks for your help much appreciated.

                  1 Reply Last reply Reply Quote 0

                  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
                  • First post
                    Last post