Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Gpy cannot connect to BLE device

    Scheduled Pinned Locked Moved GPy
    5 Posts 2 Posters 301 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.
    • S Offline
      Skipper90
      last edited by

      Hi,
      i have a problem with my Gpy.
      I used the example code From https://docs.pycom.io/tutorials/all/ble/.

      from network import Bluetooth
      import time
      bt = Bluetooth()
      bt.start_scan(-1)
      
      while True:
        adv = bt.get_adv()
        if adv and bt.resolve_adv_data(adv.data, Bluetooth.ADV_NAME_CMPL) == 'Heartrate':
            print('gefunden')
            bt.stop_scan()
            try:
                print(adv.mac)
                conn = bt.connect(adv.mac)
                #bt.connect(b'\xDA\x0F\xA2\x69\x63\xCA')
                print('verbunden')
                services = conn.services()
                for service in services:
                    time.sleep(0.050)
                    if type(service.uuid()) == bytes:
                        print('Reading chars from service = {}'.format(service.uuid()))
                    else:
                        print('Reading chars from service = %x' % service.uuid())
                    chars = service.characteristics()
                    for char in chars:
                        if (char.properties() & Bluetooth.PROP_READ):
                            print('char {} value = {}'.format(char.uuid(), char.read()))
                conn.disconnect()
                break
            except:
                pass
        else:
            time.sleep(0.050)
      
      
      Uploading project (main folder)...
      Not safe booting, disabled in settings
      
      Reading file status
      [1/1] Writing file main.py (1kb)
      Upload done, resetting board...
      OKets Jun  8 2016 00:22:57
      
      rst:0x7 (TG0WDT_SYS_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
      configsip: 0, SPIWP:0xee
      clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
      mode:DIO, clock div:1
      load:0x3fff8020,len:8
      load:0x3fff8028,len:2136
      load:0x4009fa00,len:19880
      entry 0x400a05d0
      Smart Provisioning started in the background
      See https://docs.pycom.io/smart for details
      gefunden
      b'\xcc\x80\x91J\xfb\x8d'
      
      

      after the print of the mac adresse nothing happen...

      The BLE device work, with NRF Connect its possible to connect and look the services.
      Greetings

      1 Reply Last reply Reply Quote 0
      • S Offline
        sandris
        last edited by

        Hi, you could try to print the exception to get a better understanding of why it's failing.

        except Exception as e:
            print("Failed: " + str(e))
        
        S 1 Reply Last reply Reply Quote 0
        • S Offline
          Skipper90
          last edited by

          So now this is printed.

          Failed: connection refused
          
          1 Reply Last reply Reply Quote 0
          • S Offline
            Skipper90 @sandris
            last edited by

            Thank you for your help.

            Now i searched in the forum an finde a post
            ble-connection-issue

            my issue is very embarrassing.... my Phone with the NRF app blocked the connection while scanning...
            Thank you for your help

            1 Reply Last reply Reply Quote 0
            • S Offline
              Skipper90
              last edited by

              I don´t know what is wrong...
              Now it doesn´t work.

              i is nit possible to connect. every time 'connection refused'

              I have no idea what i am doing wrong.

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

              Pycom on Twitter

              Pycom