# Pycom Wipy 3.0 read PROP\_NOTIFY

**URL:** <https://forum.core-electronics.com.au/t/pycom-wipy-3-0-read-prop-notify/3803>\
**Category:** Micropython\
**Created:** [28 October 2018 22:44 UTC](https://forum.core-electronics.com.au/t/pycom-wipy-3-0-read-prop-notify/3803 "2018-10-28T22:44:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luke58110](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/luke58110/32/1957_2.png) [@Luke58110](https://forum.core-electronics.com.au/u/Luke58110)\
**Post date:** [28 October 2018 22:44 UTC](https://forum.core-electronics.com.au/t/pycom-wipy-3-0-read-prop-notify/3803/1 "2018-10-28T22:44:09Z")

</div>

Hi Everyone. Thanks in advance to any help you can give me.

I just received my Wipy 3.0 and Track on Friday. I watched Chris’ awesome videos Saturday morning and got lat long and modified the class to give me atomic clock time within a couple of hours, awesome! Connected to a BLE device and read out the services and characteristics in an hour, great!

I’ve got stuck though, trying to read the value of a notify property. I can detect that the property exists and get it’s UUID, properties, instance. But can’t read the actual value of the data. I can connect with a BLE scanner on my phone and with an arduino+HM10 and read the value so know the device is working.

**It is giving me this error: OSError: the requested operation failed**

Here is my code:

```
from network import Bluetooth
import binascii
import time
bt = Bluetooth()
#bt.start_scan(-1)
bt.stop_scan()
bt.start_scan(-1)

while True:
    adv = bt.get_adv()
    if adv:
        mfg_data = bt.resolve_adv_data(adv.data, Bluetooth.ADV_MANUFACTURER_DATA)

        if bt.resolve_adv_data(adv.data, Bluetooth.ADV_NAME_CMPL) == 'earconnect':
            print('connected to: {}'.format(bt.resolve_adv_data(adv.data, Bluetooth.ADV_NAME_CMPL)))
            conn = bt.connect(adv.mac)
            services = conn.services()
            for service in services:
                time.sleep(0.050)
                if type(service.uuid()) == bytes:
                    print('Reading bytes 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 or Bluetooth.PROP_INDICATE or Bluetooth.PROP_NOTIFY)):
                    if ((char.properties()) & (Bluetooth.PROP_NOTIFY)):
                        print('char uuid: {}'.format(char.uuid()))
                        print('char instance: {}'.format(char.instance()))
                        print('char properties: {}'.format(char.properties()))
                        #line below fails with error: OSError: the requested operation failed
                        print('char read: {}'.format(char.read()))
            conn.disconnect()
            break
    else:
        #print('ADV does not exist')
        time.sleep(0.050)
```

---

<div class="post-metadata">

**Author:** ![Stephen](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/stephen/32/1599_2.png) [@Stephen](https://forum.core-electronics.com.au/u/Stephen)\
**Post date:** [30 October 2018 22:24 UTC](https://forum.core-electronics.com.au/t/pycom-wipy-3-0-read-prop-notify/3803/2 "2018-10-30T22:24:47Z")

</div>

Hi Luke!

I may be wrong, but I think that you cannot read the value of a Notify. Notifications are a message type that your device is sending, like a request. You may not be able to read the notification request you are sending. This could just be out of the supported bluetooth operations on Pycom. They say on in their documentation that they only support “Basic BLE functionality” at this time. Perhaps that just isn’t supported yet.

Let me know if you find a solution!

---

<div class="post-metadata">

**Author:** ![Luke58110](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/luke58110/32/1957_2.png) [@Luke58110](https://forum.core-electronics.com.au/u/Luke58110)\
**Post date:** [1 November 2018 03:30 UTC](https://forum.core-electronics.com.au/t/pycom-wipy-3-0-read-prop-notify/3803/3 "2018-11-01T03:30:11Z")

</div>

Thanks @Stephen. Hmmm, I’ve using it as a central and connecting to a peripheral. THat’s a bugger since the characteristic I’m interested in is a notify type and the Wipy can’t read it. I’ll keep digging.

Cheers Luke

---

<div class="post-metadata">

**Author:** ![Luke58110](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/luke58110/32/1957_2.png) [@Luke58110](https://forum.core-electronics.com.au/u/Luke58110)\
**Post date:** [1 November 2018 22:44 UTC](https://forum.core-electronics.com.au/t/pycom-wipy-3-0-read-prop-notify/3803/4 "2018-11-01T22:44:40Z")

</div>

I ended up finding a ‘legacy’ characteristic that contained some of the data that I could process/decode and use.

---

<div class="post-metadata">

**Author:** ![Stephen](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/stephen/32/1599_2.png) [@Stephen](https://forum.core-electronics.com.au/u/Stephen)\
**Post date:** [1 November 2018 22:56 UTC](https://forum.core-electronics.com.au/t/pycom-wipy-3-0-read-prop-notify/3803/5 "2018-11-01T22:56:13Z")

</div>

Luke,

I’d like to know how you did it! Would you mind sharing your code?

---

<div class="post-metadata">

**Author:** ![Luke58110](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/luke58110/32/1957_2.png) [@Luke58110](https://forum.core-electronics.com.au/u/Luke58110)\
**Post date:** [1 November 2018 22:57 UTC](https://forum.core-electronics.com.au/t/pycom-wipy-3-0-read-prop-notify/3803/6 "2018-11-01T22:57:59Z")

</div>

Sure, I’m tidying it into a class, then will share. But basically I printed out every characteristic, looked for ones that had varying output, then used an ascii/hex.dec conversion table to see if it fitted what I was looking for.

---

<div class="post-metadata">

**Author:** ![Luke58110](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/luke58110/32/1957_2.png) [@Luke58110](https://forum.core-electronics.com.au/u/Luke58110)\
**Post date:** [9 November 2018 02:55 UTC](https://forum.core-electronics.com.au/t/pycom-wipy-3-0-read-prop-notify/3803/7 "2018-11-09T02:55:50Z")

</div>

Hi Stephen,

I got this sorted properly, here’s the code. I’ve added a Bluetooth.CHAR\_NOTIFY\_EVENT which calls char\_notify\_callback when the peripheral updates the notify characteristic:

```
from network import Bluetooth
import binascii
import time
bt = Bluetooth()
#bt.start_scan(-1)
bt.stop_scan()
bt.start_scan(-1)

def char_notify_callback(char):
    char_value = (char.value())
    print("Got new char: {} value: {}".format(char.uuid(), char_value))

while True:
    adv = bt.get_adv()
    if adv:
        mfg_data = bt.resolve_adv_data(adv.data, Bluetooth.ADV_MANUFACTURER_DATA)
        your_device_name = "something here"

        if bt.resolve_adv_data(adv.data, Bluetooth.ADV_NAME_CMPL) == your_device_name:
            print('connected to: {}'.format(bt.resolve_adv_data(adv.data, Bluetooth.ADV_NAME_CMPL)))
            conn = bt.connect(adv.mac)
            services = conn.services()
            for service in services:
                time.sleep(0.050)
                if type(service.uuid()) == bytes:
                    print('Reading bytes 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_NOTIFY)):
                        characteristic.callback(trigger=Bluetooth.CHAR_NOTIFY_EVENT,
                                                handler=char_notify_callback,
                                                arg=None)
            conn.disconnect()
            break
    else:
        #print('ADV does not exist')
        time.sleep(0.050)
```
