<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/39819/regarding-python-scripts-for-nrf52840-to-connect-and-transfer-data</link><description>Hi , 
 What I am trying:- 
 -connect the custom board with nrf52840 chip using nrf52 dongle on pc with python. 
 -Already set some commands on custom board so when my pc (via dongle) connects to custom board, I want to send some commands and accordingly</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 06 Dec 2022 15:19:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/39819/regarding-python-scripts-for-nrf52840-to-connect-and-transfer-data" /><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/399238?ContentTypeID=1</link><pubDate>Tue, 06 Dec 2022 15:19:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:01119327-4585-4554-bf47-349454b8e5cb</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There has been a small number of updates to pc-ble-driver and pc-ble-driver-py over the past three to four years, yes. I do not know when support was added, but the nRF52840 Dongle is listed as supported for pc-ble-driver. If you have any issues getting it to work, or any related questions, please create a new thread here on DevZone.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/399172?ContentTypeID=1</link><pubDate>Tue, 06 Dec 2022 12:07:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1d62196-08b5-4a51-a8fd-20055d56fe75</guid><dc:creator>svl</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Have there been any changes regarding the nrf52840 dongles with the python scripts for transferring data?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/250713?ContentTypeID=1</link><pubDate>Tue, 19 May 2020 12:19:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4b2c4d3-8897-42db-9cb0-59c1351a9580</guid><dc:creator>SYJ</dc:creator><description>&lt;p&gt;The problem with connecting your own peripherals is described in the above reply&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/61567/adding-custom-service-uuid-in-pc_ble_driver_py-problems"&gt;problem&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/250690?ContentTypeID=1</link><pubDate>Tue, 19 May 2020 11:50:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de9ce30e-cce6-4975-8e2f-9b3236e65eea</guid><dc:creator>Zero.cool</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/syj"&gt;SYJ&lt;/a&gt;&lt;br /&gt;What problem you have?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/250631?ContentTypeID=1</link><pubDate>Tue, 19 May 2020 09:00:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82d6d58e-5b9a-41d0-9324-fa3baa33e5d8</guid><dc:creator>SYJ</dc:creator><description>&lt;p&gt;hello,How are you doing? I have the same problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/167041?ContentTypeID=1</link><pubDate>Tue, 22 Jan 2019 10:08:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce9c481a-8f89-4c70-a955-876925cbe6d7</guid><dc:creator>Zero.cool</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;Thank you very much for the quick response and I agree with your point as well.&lt;/p&gt;
&lt;p&gt;I was digging a bit and found that.,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In order to receive the data using above UUID, I need to select the service UUID and then Characteristics UUID (might be the normal communication) .&lt;/p&gt;
&lt;p&gt;here the characteristics have their own handles or descriptors ( which I am not able to write or I am not doing in code ).&lt;/p&gt;
&lt;p&gt;From the descriptors or handles I need to choose one and then I need to write (0x0100) to enable notification. Once the notification is&amp;nbsp; enabled the board (slave )will start transmitting data which I wanted to read.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now slave has number of descriptors that I need to read and select first and according to need I will write data and enable notification.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This is the flow which I confirmed with other device.&lt;/p&gt;
&lt;p&gt;May be in python example above you can point out edits so that I can check once.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/167031?ContentTypeID=1</link><pubDate>Tue, 22 Jan 2019 09:17:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b53617f-609a-4b8c-b330-5782f92acd20</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Nothing new, I am afraid, apart from that the team is working on pc-ble-driver-py now and there will be a release some time in the future. I do not know how much time it will take, and what changes they will do other than implement support for pc-ble-driver v4.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/167007?ContentTypeID=1</link><pubDate>Tue, 22 Jan 2019 07:36:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:beb42fd4-b1f6-4323-b899-c82f3be6fbee</guid><dc:creator>Zero.cool</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Is there any update on the python version for scripts which you have mentioned in the thread here?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/164165?ContentTypeID=1</link><pubDate>Mon, 07 Jan 2019 08:48:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be2d61e6-2b52-42e1-9ad9-80da3391fb55</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am sorry for the delays, I have been out-of-office for the holidays and returned today.&lt;/p&gt;
&lt;p&gt;We do not have anything in C# or Java. What we do have is pc-ble-driver-py and &lt;a href="https://github.com/NordicSemiconductor/pc-ble-driver-js"&gt;pc-ble-driver-js&lt;/a&gt;, which is Python and JavaScript respectively. For pc-ble-driver-py we do not have any example that does what you want, so I still refer to what I have written previously in this thread. We also have the base &lt;a href="https://github.com/NordicSemiconductor/pc-ble-driver"&gt;pc-ble-driver&lt;/a&gt;, which is written in c/c++.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/163291?ContentTypeID=1</link><pubDate>Mon, 31 Dec 2018 07:01:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:520f92d9-4409-4586-84db-aed74165c770</guid><dc:creator>Zero.cool</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;I have took the endianness correctly that I have checked. But not able to success. If there is no other reason left then I have to take another approach here.&lt;/p&gt;
&lt;p&gt;I have took windows native ble libs for connecting to nrf board. As of now I am able to connect and explore services UUID&amp;#39;s from board (pairing is also done). For this I am using the same UUID&amp;#39;s as above for reading characteristics. ( If you have experience in that you can point to me correct way if I am wrong. I am coding in C# and open for java as well for example code).&lt;/p&gt;
&lt;p&gt;But While sending read command I am not able to receive data. To debug this issue,I request to point me for any example that utilizes the same libs(windows app for BLE libs) for communication. so that I can compare and make changes accordingly in my application.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Hinesh&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/159543?ContentTypeID=1</link><pubDate>Thu, 29 Nov 2018 12:18:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:011ec015-8faa-4c68-ac42-4651d348ca53</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am sorry, but I cannot think of much more that might be the issue. Make sure that you have gotten the endianness correct (i.e. byte order in the UUIDs) and that you are using the correct UUIDs. Other than that, there is no reason left why it should not work...&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/159133?ContentTypeID=1</link><pubDate>Tue, 27 Nov 2018 02:40:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4ff894b-7320-4727-bc98-cf6963a7d952</guid><dc:creator>Zero.cool</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt; &lt;a href="https://devzone.nordicsemi.com/members/terje"&gt;Terje&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I have tried the change you have suggested but still getting below error.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ATT MTU exchange response: conn_handle=0
Traceback (most recent call last):
  File &amp;quot;C:/My_Projects/CoMo_Docs/BLE_DOCS/Cassia_Data_Collection_Scripts-BLE_Range/Cassia_Data_Collection_Scripts/Range_Test.py&amp;quot;, line 274, in &amp;lt;module&amp;gt;
    main(serial_port)
  File &amp;quot;C:/My_Projects/CoMo_Docs/BLE_DOCS/Cassia_Data_Collection_Scripts-BLE_Range/Cassia_Data_Collection_Scripts/Range_Test.py&amp;quot;, line 255, in main
    conn_handle = collector.connect_and_discover()
  File &amp;quot;C:/My_Projects/CoMo_Docs/BLE_DOCS/Cassia_Data_Collection_Scripts-BLE_Range/Cassia_Data_Collection_Scripts/Range_Test.py&amp;quot;, line 204, in connect_and_discover
    self.adapter.enable_notification(new_conn,  DATA_CHAR_UUID)
  File &amp;quot;C:\Python27\lib\site-packages\pc_ble_driver_py\ble_driver.py&amp;quot;, line 125, in wrapper
    err_code = wrapped(*args, **kwargs)
  File &amp;quot;C:\Python27\lib\site-packages\pc_ble_driver_py\ble_adapter.py&amp;quot;, line 254, in enable_notification
    raise NordicSemiException(&amp;#39;CCCD not found&amp;#39;)
pc_ble_driver_py.exceptions.NordicSemiException: CCCD not found

Process finished with exit code 1&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/159008?ContentTypeID=1</link><pubDate>Mon, 26 Nov 2018 12:11:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f8365c5-e19a-45bf-9ebf-b446c5b98733</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Sorry for the delay, I have been out-of-office.&lt;/p&gt;
&lt;p&gt;It should work if you use the line:&lt;/p&gt;
&lt;p&gt;self.adapter.enable_notification(new_conn, DATA_CHAR_UUID)&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/158739?ContentTypeID=1</link><pubDate>Fri, 23 Nov 2018 02:38:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:970d24c5-fc3b-41c1-899b-5370706f02a8</guid><dc:creator>Zero.cool</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/terje"&gt;Terje&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Do you able to find out the error?&lt;/p&gt;
&lt;p&gt;Is there any other input require from my side?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/158085?ContentTypeID=1</link><pubDate>Tue, 20 Nov 2018 02:22:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ee6c5b6-f777-4aff-aec6-cc8dc8d9210c</guid><dc:creator>Zero.cool</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/terje"&gt;Terje&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thank you for the response.&lt;/p&gt;
&lt;p&gt;You are correct the code on the other end will not change.&lt;/p&gt;
&lt;p&gt;however the code which I am using to connect also I keeping same, except checking with UUID&amp;#39;s. A trial and error to remove the &amp;#39;: CCCD not found&amp;#39; by debugging.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;inserting code which is right now, but not working&lt;pre class="ui-code" data-mode="text"&gt;import Queue

import json
import time
import sys

from datetime import datetime, timedelta
from bitstruct import *
from pprint import pformat
import binascii
from pc_ble_driver_py.observers import *
from nordicsemi.ble_adapter import *

try:
    with open(&amp;quot;Config_Files/Connection_Settings.json&amp;quot;)as conn:
        config = json.load(conn)
except Exception as e:
    print str(e)
    print &amp;#39;Could not open settings file&amp;#39;
    raw_input(&amp;quot;Press ENTER to exit...&amp;quot;)
    quit()




##### NRF PART ################
CCCD_UUID = &amp;#39;00002902-0000-1000-8000-00805f9b34fb&amp;#39;

DC_SERVICE_BASE_UUID = BLEUUIDBase([0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x10, 0x00,
                                    0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb])

DATA_CHAR_UUID  = BLEUUID(0x2222, DC_SERVICE_BASE_UUID)
DATA2_CHAR_UUID = BLEUUID(0x3333, DC_SERVICE_BASE_UUID)


# BASE_UUID = BLEUUIDBase([0x8E, 0xC9, 0x00, 0x00, 0xF3, 0x15, 0x4F, 0x60,
#                          0x9F, 0xB8, 0x83, 0x88, 0x30, 0xDA, 0xEA, 0x50])
# DC_SERVICE_BASE_UUID = BLEUUIDBase([0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x10, 0x00,
#                                     0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb])

CCCD_BASE_UUID = BLEUUIDBase([0x00, 0x00, 0x29, 0x02, 0x00, 0x00, 0x10, 0x00,
                              0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB])
# Buttonless characteristics
BLE_DFU_BUTTONLESS_CHAR_UUID = BLEUUID(0x2902, CCCD_BASE_UUID)
BLE_DFU_BUTTONLESS_BONDED_CHAR_UUID = BLEUUID(0x2902, CCCD_BASE_UUID)
SERVICE_CHANGED_UUID = BLEUUID(0x2A05)


def init(conn_ic_id):
    global BLEDriver, BLEAdvData, BLEEvtID, BLEAdapter, BLEEnableParams, BLEGapTimeoutSrc, BLEUUID
    from pc_ble_driver_py import config
    config.__conn_ic_id__ = conn_ic_id
    from pc_ble_driver_py.ble_driver import BLEDriver, BLEAdvData, BLEEvtID, BLEEnableParams, BLEGapTimeoutSrc, BLEUUID
    from pc_ble_driver_py.ble_adapter import BLEAdapter
    global nrf_sd_ble_api_ver
    nrf_sd_ble_api_ver = config.sd_api_ver_get()


class HRCollector(BLEDriverObserver, BLEAdapterObserver):
    def __init__(self, adapter):
        super(HRCollector, self).__init__()
        self.adapter = adapter
        self.conn_q = Queue.Queue()
        self.adapter.observer_register(self)
        self.adapter.driver.observer_register(self)

    def open(self):
        self.adapter.driver.open()

        ble_enable_params = BLEEnableParams(vs_uuid_count=1,
                                            service_changed=False,
                                            periph_conn_count=0,
                                            central_conn_count=CONNECTIONS,
                                            central_sec_count=CONNECTIONS)
        if nrf_sd_ble_api_ver &amp;gt;= 3:
            print(&amp;quot;Enabling larger ATT MTUs&amp;quot;)
            ble_enable_params.att_mtu = 50

        self.adapter.driver.ble_enable(ble_enable_params)

    def close(self):
        self.adapter.driver.close()

    @property
    def connect_and_discover(self):
        self.adapter.driver.ble_gap_scan_start()
        new_conn = self.conn_q.get(timeout=60)

        if nrf_sd_ble_api_ver &amp;gt;= 3:
            att_mtu = self.adapter.att_mtu_exchange(new_conn)

        self.adapter.service_discovery(new_conn)
        self.adapter.enable_notification(new_conn,BLEUUID(0x2902, CCCD_BASE_UUID))#BLEUUID(0x2902, DC_SERVICE_BASE_UUID))  # BLEUUID(BLEUUID.Standard.battery_level))
        # self.adapter.enable_notification(new_conn, BLEUUID(BLEUUID.Standard.heart_rate))
        return new_conn

    def on_gap_evt_connected(self, ble_driver, conn_handle, peer_addr, role, conn_params):
        print(&amp;#39;New connection: {}&amp;#39;.format(conn_handle))
        self.conn_q.put(conn_handle)

    def on_gap_evt_disconnected(self, ble_driver, conn_handle, reason):
        print(&amp;#39;Disconnected: {} {}&amp;#39;.format(conn_handle, reason))

    def on_gap_evt_timeout(self, ble_driver, conn_handle, src):
        if src == BLEGapTimeoutSrc.scan:
            ble_driver.ble_gap_scan_start()

    def on_gap_evt_adv_report(self, ble_driver, conn_handle, peer_addr, rssi, adv_type, adv_data):
        dev_name_list = None
        if BLEAdvData.Types.complete_local_name in adv_data.records:
            dev_name_list = adv_data.records[BLEAdvData.Types.complete_local_name]

        elif BLEAdvData.Types.short_local_name in adv_data.records:
            dev_name_list = adv_data.records[BLEAdvData.Types.short_local_name]

        else:
            return

        dev_name = &amp;quot;&amp;quot;.join(chr(e) for e in dev_name_list)
        address_string = &amp;quot;&amp;quot;.join(&amp;quot;{0:02X}&amp;quot;.format(b) for b in peer_addr.addr)
        print(&amp;#39;Received advertisment report, address: 0x{}, device_name: {}&amp;#39;.format(address_string,
                                                                                    dev_name))

        if (dev_name == TARGET_DEV_NAME):
            self.adapter.connect(peer_addr)

    def on_notification(self, ble_adapter, conn_handle, uuid, data):
        print(&amp;#39;Connection: {}, {} = {}&amp;#39;.format(conn_handle, uuid, data))

    def on_att_mtu_exchanged(self, ble_driver, conn_handle, att_mtu):
        print(&amp;#39;ATT MTU exchanged: conn_handle={} att_mtu={}&amp;#39;.format(conn_handle, att_mtu))

    def on_gattc_evt_exchange_mtu_rsp(self, ble_driver, conn_handle, **kwargs):
        print(&amp;#39;ATT MTU exchange response: conn_handle={}&amp;#39;.format(conn_handle))


def main(serial_port):
    print(&amp;#39;Serial port used: {}&amp;#39;.format(serial_port))
    driver = BLEDriver(serial_port=serial_port, auto_flash=True)
    adapter = BLEAdapter(driver)
    collector = HRCollector(adapter)
    collector.open()
    conn_handle = collector.connect_and_discover()
    adapter.write_req(conn_handle, CCCD_UUID, [3])#RAW_TYPE)
    # collector.connect_and_discover()
    # collector.wri


if __name__ == &amp;quot;__main__&amp;quot;:
    serial_port = None
    # if len(sys.argv) &amp;lt; 2:
    #     print(&amp;quot;Please specify connectivity IC identifier (NRF51, NRF52)&amp;quot;)
    #     exit(1)
    init(&amp;quot;NRF52&amp;quot;)
    if len(sys.argv) == 3:
        serial_port = sys.argv[2]
    else:
        descs = BLEDriver.enum_serial_ports()
        choices = [&amp;#39;{}: {}&amp;#39;.format(d.port, d.serial_number) for d in descs]
        choice = &amp;#39;0&amp;#39;  # item_choose(choices)
        serial_port = port_enter  # &amp;quot;COM12&amp;quot; #descs[choice].port
        main(serial_port)
        quit()

##### NRF PART ####### HINESH ############## NRF PART ###### #########
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/158049?ContentTypeID=1</link><pubDate>Mon, 19 Nov 2018 16:39:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d48e110d-9fa6-4621-86fe-4623a1e47a1a</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It is still hard to tell without getting to see the exact code that you run. In order to figure out what is wrong, it is necessary to have both the code and the error message.&lt;/p&gt;
&lt;p&gt;In this case also the device in the other end is important, but you have already provided enough information about it and I assume that that one does not change. The code however you have changed several times up until now, and so it is important to know what it looks like right now.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/157807?ContentTypeID=1</link><pubDate>Sat, 17 Nov 2018 04:29:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9265e31f-f71e-446d-9170-4cad521fc923</guid><dc:creator>Zero.cool</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/terje"&gt;Terje&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It is not working.&lt;/p&gt;
&lt;p&gt;My code Is same that I have pasted above.&lt;/p&gt;
&lt;p&gt;Any changes I do I end up in CCCD UUID not valid.&lt;/p&gt;
&lt;p&gt;I needed your input here.&lt;/p&gt;
&lt;p&gt;EDIT: - Still getting the same error.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;Received advertisment report, address: 0x5031ADC0000A, device_name: POC1_2-3
New connection: 0
ATT MTU exchanged: conn_handle=0 att_mtu=23
ATT MTU exchange response: conn_handle=0
Traceback (most recent call last):
  File &amp;quot;C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.3\helpers\pydev\pydevd.py&amp;quot;, line 1664, in &amp;lt;module&amp;gt;
    main()
  File &amp;quot;C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.3\helpers\pydev\pydevd.py&amp;quot;, line 1658, in main
    globals = debugger.run(setup[&amp;#39;file&amp;#39;], None, None, is_module)
  File &amp;quot;C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.3\helpers\pydev\pydevd.py&amp;quot;, line 1068, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File &amp;quot;C:/My_Projects/Script.py&amp;quot;, line 269, in &amp;lt;module&amp;gt;
    main(serial_port)
  File &amp;quot;C:/My_Projects/Script.py&amp;quot;, line 250, in main
    conn_handle = collector.connect_and_discover()
  File &amp;quot;C:/My_Projects/Script.py&amp;quot;, line 200, in connect_and_discover
    self.adapter.enable_notification(new_conn,BLEUUID(0x2902, CCCD_BASE_UUID))#BLEUUID(0x2902, DC_SERVICE_BASE_UUID))  # BLEUUID(BLEUUID.Standard.battery_level))
  File &amp;quot;C:\Python27\lib\site-packages\pc_ble_driver_py\ble_driver.py&amp;quot;, line 125, in wrapper
    err_code = wrapped(*args, **kwargs)
  File &amp;quot;C:\Python27\lib\site-packages\pc_ble_driver_py\ble_adapter.py&amp;quot;, line 254, in enable_notification
    raise NordicSemiException(&amp;#39;CCCD not found&amp;#39;)
pc_ble_driver_py.exceptions.NordicSemiException: CCCD not found
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/157681?ContentTypeID=1</link><pubDate>Fri, 16 Nov 2018 10:21:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20f5b668-e14e-4a33-95d2-507ebd311439</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;So does it work now? If not, what is your code now?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/157535?ContentTypeID=1</link><pubDate>Thu, 15 Nov 2018 14:07:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:578498fe-640a-489f-84d1-41efd4f639e5</guid><dc:creator>Zero.cool</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Enclosing screenshot from app.&lt;/p&gt;
&lt;p&gt;sorry, was misunderstood previously.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/4477.1.JPG" alt=" " /&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/0741.2.JPG" alt=" " /&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/8267.3.JPG" alt=" " /&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/0211.4.JPG" alt=" " /&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/1122.5.JPG" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;In mobile app I can see two unknown services, and for both I am pasting screen shots here. and you were correct about mixed up on several uuid&amp;#39;s.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/157529?ContentTypeID=1</link><pubDate>Thu, 15 Nov 2018 13:45:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a6353bc3-9e01-4460-8a92-8ad55eda3c41</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can you provide a screenshot or image from nRF Connect, showing the UUIDs that are found on the device?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/157523?ContentTypeID=1</link><pubDate>Thu, 15 Nov 2018 13:37:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db22950b-6ea6-4758-a98b-e812594fc122</guid><dc:creator>Zero.cool</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Below is my output of the terminal.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;File &amp;quot;C:\Python27\lib\site-packages\pc_ble_driver_py\ble_adapter.py&amp;quot;, line 254, in enable_notification
    raise NordicSemiException(&amp;#39;CCCD not found&amp;#39;)
pc_ble_driver_py.exceptions.NordicSemiException: CCCD not found&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Also The BLE_DFU_BUTTONLESS_CHAR_UUID is there, but not using them,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/157520?ContentTypeID=1</link><pubDate>Thu, 15 Nov 2018 13:29:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64596d5d-1553-4cfa-b588-a84ca2eb3d34</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Why are you still defining BLE_DFU_BUTTONLESS_CHAR_UUID and BLE_DFU_BUTTONLESS_BONDED_CHAR_UUID? That was an example, for how to make UUIDs. You should do e.g.:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="python"&gt;DC_SERVICE_BASE_UUID = BLEUUIDBase([0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x10, 0x00,
                                    0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb])

DATA_CHAR_UUID  = BLEUUID(0x2222, DC_SERVICE_BASE_UUID)
DATA2_CHAR_UUID = BLEUUID(0x3333, DC_SERVICE_BASE_UUID)

self.adapter.service_discovery(new_conn)
self.adapter.enable_notification(new_conn, DATA_CHAR_UUID)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;If you attach a screenshot of what you get in nRF Connect then I can try to explain what it means. It sounds like you have mixed up several UUIDs (what they mean and how they are used.)&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/157390?ContentTypeID=1</link><pubDate>Thu, 15 Nov 2018 03:48:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ae0edf0-cef0-40f6-9d43-0772647bc428</guid><dc:creator>Zero.cool</dc:creator><description>&lt;p&gt;I have tried your suggestions and changed&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CCCD_UUID = &amp;#39;00002902-0000-1000-8000-00805f9b34fb&amp;#39;

DC_SERVICE_UUID = &amp;#39;00001111-0000-1000-8000-00805f9b34fb&amp;#39;
DATA_CHAR_UUID  = &amp;#39;00002222-0000-1000-8000-00805f9b34fb&amp;#39;
DATA2_CHAR_UUID = &amp;#39;00003333-0000-1000-8000-00805f9b34fb&amp;#39;


DC_SERVICE_BASE_UUID = BLEUUIDBase([0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x10, 0x00,
                                    0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb])
## Also Tried with above CCCD_UUID for checking as below , but not worked
#--CCCD_BASE_UUID = BLEUUIDBase([0x00, 0x00, 0x29, 0x02, 0x00, 0x00, 0x10, 0x00,
#                              0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB])
# Buttonless characteristics
BLE_DFU_BUTTONLESS_CHAR_UUID = BLEUUID(0x2902, DC_SERVICE_BASE_UUID)
BLE_DFU_BUTTONLESS_BONDED_CHAR_UUID = BLEUUID(0x2901, DC_SERVICE_BASE_UUID)
## The 0x2902 and 0x2901 are I have checked via nrf connect app and they are showing
## same. I have also changed as per the suggestionns of 0x2222 and 0x1111. But
## not able to connect

self.adapter.service_discovery(new_conn)
        self.adapter.enable_notification(new_conn,
                                         BLEUUID(0x2901, DC_SERVICE_BASE_UUID))
## Here also changes and tested.&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Still I get this error as below.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ATT MTU exchanged: conn_handle=0 att_mtu=23
ATT MTU exchange response: conn_handle=0
Traceback (most recent call last):
  File &amp;quot;C:/My_Projects/Script.py&amp;quot;, line 267, in &amp;lt;module&amp;gt;
    main(serial_port)
  File &amp;quot;C:/My_Projects/Script.py&amp;quot;, line 248, in main
    conn_handle = collector.connect_and_discover()
  File &amp;quot;C:/My_Projects/Script.py&amp;quot;, line 198, in connect_and_discover
    BLEUUID(0x2901, DC_SERVICE_BASE_UUID))  # BLEUUID(BLEUUID.Standard.battery_level))
  File &amp;quot;C:\Python27\lib\site-packages\pc_ble_driver_py\ble_driver.py&amp;quot;, line 125, in wrapper
    err_code = wrapped(*args, **kwargs)
  File &amp;quot;C:\Python27\lib\site-packages\pc_ble_driver_py\ble_adapter.py&amp;quot;, line 254, in enable_notification
    raise NordicSemiException(&amp;#39;CCCD not found&amp;#39;)
pc_ble_driver_py.exceptions.NordicSemiException: CCCD not found&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I see one function below&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    def enable_notification(self, conn_handle, uuid):
        cccd_list = [1, 0]

        handle = self.db_conns[conn_handle].get_cccd_handle(uuid)
        if handle == None:
            raise NordicSemiException(&amp;#39;CCCD not found&amp;#39;)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So in this function I believe the passed &amp;#39;UUID&amp;#39; is not correct.&lt;/p&gt;
&lt;p&gt;But passed in the function is correct.&lt;/p&gt;
&lt;p&gt;can you input here what Is going wrong?&lt;/p&gt;
&lt;p&gt;(Kindly ignore other copy &amp;amp; paste as it was not showing prior log of and log in)&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/157048?ContentTypeID=1</link><pubDate>Tue, 13 Nov 2018 10:40:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3278982-23d1-4550-9733-613f5d204947</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The line&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="python"&gt;BASE_UUID = BLEUUIDBase([0x8E, 0xC9, 0x00, 0x00, 0xF3, 0x15, 0x4F, 0x60,
                         0x9F, 0xB8, 0x83, 0x88, 0x30, 0xDA, 0xEA, 0x50])&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;creates a base UUID of&lt;/p&gt;
&lt;p&gt;0x8EC9xxxx-F315-4F60-9FB8-838830DAEA50&lt;/p&gt;
&lt;p&gt;As you can see, each value in the array of hexadecimal values corresponds to one byte of the base UUID. The two bytes that are written using x in the UUID are filled in using the call to BLEUUID, so that e.g.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="python"&gt;    BLE_DFU_BUTTONLESS_CHAR_UUID        = BLEUUID(0x0003, BASE_UUID)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;creates the UUID of&lt;/p&gt;
&lt;p&gt;0x8EC90003-F315-4F60-9FB8-838830DAEA50&lt;/p&gt;
&lt;p&gt;So you must divide your UUID into base UUID and 16 bit part, exactly the same way.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding Python Scripts for nrf52840 to connect and transfer data.</title><link>https://devzone.nordicsemi.com/thread/156979?ContentTypeID=1</link><pubDate>Tue, 13 Nov 2018 04:03:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a4649f8-23b6-4bd6-94b9-03ef4c506425</guid><dc:creator>Zero.cool</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/tesc"&gt;tesc&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You have explained well.&lt;/p&gt;
&lt;p&gt;But two questions:-&lt;/p&gt;
&lt;p&gt;1. How do I convert UUID to BLEUUDIBase Format? just separating&amp;nbsp; with &amp;#39;0x00&amp;#39; will not work (I think).&lt;/p&gt;
&lt;p&gt;2. This is for writing, once this command given , device will start transmitting data. So I have to initiate a reader thread/function as well. is there any read function as I was not able to find in examples.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Hinesh&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>