<?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>re-init or resetting nrf52 dongle with pc-ble-driver-py</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/41051/re-init-or-resetting-nrf52-dongle-with-pc-ble-driver-py</link><description>Hi, 
 
 I have a python program using an NRF52 dongle and its working great with the a minor detail that if the program crashes and does not get a chance to close the adapter, then it does not allow you to open it again until the dongle is unplugged and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 27 Jun 2019 01:13:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/41051/re-init-or-resetting-nrf52-dongle-with-pc-ble-driver-py" /><item><title>RE: re-init or resetting nrf52 dongle with pc-ble-driver-py</title><link>https://devzone.nordicsemi.com/thread/194974?ContentTypeID=1</link><pubDate>Thu, 27 Jun 2019 01:13:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:363bef9c-87f1-4be0-905b-364d0efb2068</guid><dc:creator>Jake Zimmer</dc:creator><description>&lt;p&gt;Using the comments from this thread I was able to come up with a solution that does not require modification of the pc-ble-driver-py library. For anyone else looking for an answer, here is my code snippet:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;def parametrizedDecorator(dec):
    def layer(*args, **kwargs):
        def repl(f):
            return dec(f, *args, **kwargs)
        return repl
    return layer

@parametrizedDecorator
def extendClass(func, c):
    setattr(c, func.__name__, func)
    return func

from pc_ble_driver_py import config
config.__conn_ic_id__ = &amp;quot;NRF52&amp;quot;
from pc_ble_driver_py.ble_driver import NordicSemiErrorCheck
from pc_ble_driver_py.ble_driver import driver

@NordicSemiErrorCheck
@wrapt.synchronized(BLEDriver.api_lock)
@extendClass(BLEDriver)
def reset(self, resetType=0):
    return driver.sd_rpc_conn_reset(self.rpc_adapter, resetType) &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and to&amp;nbsp;use it you should do something like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;def reset_function():
    driver = BLEDriver(serial_port=self.serial_port, auto_flash=False)
    adapter = BLEAdapter(driver)
    adapter.driver.reset(resetType)
    time.sleep(1)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: re-init or resetting nrf52 dongle with pc-ble-driver-py</title><link>https://devzone.nordicsemi.com/thread/162842?ContentTypeID=1</link><pubDate>Fri, 21 Dec 2018 12:56:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81c24dfe-f74d-4308-9cf7-323b618208e3</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Error code 8 is&amp;nbsp;NRF_ERROR_INVALID_STATE. Looking tha the pc-ble-driver C++ implementation this comes from the send()&amp;nbsp;function and is set if the current transport state is other than&amp;nbsp;STATE_ACTIVE.&amp;nbsp;It is not possible to send any commands in this state (without a working transport).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: re-init or resetting nrf52 dongle with pc-ble-driver-py</title><link>https://devzone.nordicsemi.com/thread/162746?ContentTypeID=1</link><pubDate>Thu, 20 Dec 2018 20:30:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f287d99f-8b6f-4efa-946b-489ccd15ec1a</guid><dc:creator>Riley</dc:creator><description>&lt;p&gt;Hi Einar,&lt;/p&gt;
&lt;p&gt;Thanks for the info. So does this mean I simply need the function to be:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;def reset(self):
        return driver.sd_rpc_conn_reset(self.rpc_adapter,0)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;So that SYS_RESET is chosen?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I tried this and I&amp;#39;m still seeing the error:&lt;/p&gt;
&lt;p&gt;NordicSemiException: Failed to reset. Error code: 8&lt;/p&gt;
&lt;p&gt;What does error code 8 mean exactly?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: re-init or resetting nrf52 dongle with pc-ble-driver-py</title><link>https://devzone.nordicsemi.com/thread/161844?ContentTypeID=1</link><pubDate>Fri, 14 Dec 2018 11:51:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:384f4eb5-4129-4a30-8ff1-4cefea98caab</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Yes, if you are using a pc-ble-driver version that has the&amp;nbsp;&lt;span&gt;reset_mode (&lt;a href="https://github.com/NordicSemiconductor/pc-ble-driver/blob/236d10fc939b5db5e9c11b46b488e4b8dfb44438/include/common/sd_rpc_types.h#L97"&gt;sd_rpc_reset_t&lt;/a&gt;) option for sd_rpc_conn_reset() (for instance the master branch), then you sould set it. It is either&amp;nbsp;SYS_RESET (0) or&amp;nbsp;SOFT_RESET (1). I assume&amp;nbsp;SYS_RESET is what you want.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: re-init or resetting nrf52 dongle with pc-ble-driver-py</title><link>https://devzone.nordicsemi.com/thread/161741?ContentTypeID=1</link><pubDate>Thu, 13 Dec 2018 16:22:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99410c84-968a-46d9-b0e7-44a50b12bc8d</guid><dc:creator>Riley</dc:creator><description>&lt;p&gt;Hi @Einar,&lt;br /&gt;&lt;br /&gt;I gave it shot at adding the sd_rpc_conn_reset() to the python library.&lt;br /&gt;&lt;br /&gt;I added these lines to the blue_driver.py file under the BLEDriver(object): class.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;    @NordicSemiErrorCheck
    @wrapt.synchronized(api_lock
    def reset(self):
        return driver.sd_rpc_conn_reset(self.rpc_adapter)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But it seems the sd_rpc_conn_reset() function has a second argument: &amp;nbsp;&lt;span class="pl-c1"&gt;sd_rpc_reset_t&lt;/span&gt;&lt;span&gt; reset_mode, as per this code:&lt;br /&gt;&lt;a href="https://github.com/NordicSemiconductor/pc-ble-driver/blob/236d10fc939b5db5e9c11b46b488e4b8dfb44438/src/common/sd_rpc_impl.cpp"&gt;https://github.com/NordicSemiconductor/pc-ble-driver/blob/236d10fc939b5db5e9c11b46b488e4b8dfb44438/src/common/sd_rpc_impl.cpp&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;So when I try to call it I get this error:&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;exception=Failed to reset. Error code: 8&lt;br /&gt;&lt;br /&gt;Do you know what the sd_rpc_reset_t reset_mode variable value and type needs to be to make the reset function work?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I&amp;#39;m using an &amp;quot;nRF52 Connectivity&amp;quot; dongle for my python application.&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: re-init or resetting nrf52 dongle with pc-ble-driver-py</title><link>https://devzone.nordicsemi.com/thread/160078?ContentTypeID=1</link><pubDate>Mon, 03 Dec 2018 20:20:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:946044b1-8c66-43ef-a2f9-71557f8060b1</guid><dc:creator>Riley</dc:creator><description>&lt;p&gt;I am also experiencing this issue,&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/gtorres"&gt;gtorres&lt;/a&gt;&amp;nbsp;if you manage to add the C++ implementation to the python wrapper, please let me know. Thanks&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: re-init or resetting nrf52 dongle with pc-ble-driver-py</title><link>https://devzone.nordicsemi.com/thread/159864?ContentTypeID=1</link><pubDate>Mon, 03 Dec 2018 07:15:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9efaae2-3c07-4001-a631-3d59e1ab244c</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can find it in the C++ implementation, where you have &lt;a href="https://github.com/NordicSemiconductor/pc-ble-driver/blob/971241c19abc33bbc6469e1be601a2ab78fbb35b/include/common/sd_rpc.h#L155"&gt;sd_rpc_conn_reset()&lt;/a&gt;. It&amp;nbsp;is not in the python layer, so unfortunately you have to add it to &lt;a href="https://github.com/NordicSemiconductor/pc-ble-driver-py"&gt;pc-ble-driver-py&lt;/a&gt; yourself.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: re-init or resetting nrf52 dongle with pc-ble-driver-py</title><link>https://devzone.nordicsemi.com/thread/159860?ContentTypeID=1</link><pubDate>Mon, 03 Dec 2018 06:21:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fab0bcc2-a678-4e94-833e-32b49e9f71c6</guid><dc:creator>gtorres</dc:creator><description>&lt;p&gt;Einar,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have not been able to figure out how to expose this command. Do you have any advice?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: re-init or resetting nrf52 dongle with pc-ble-driver-py</title><link>https://devzone.nordicsemi.com/thread/159765?ContentTypeID=1</link><pubDate>Fri, 30 Nov 2018 17:19:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0191506e-62d0-458f-b8a8-67fc4c0d08aa</guid><dc:creator>gtorres</dc:creator><description>&lt;p&gt;Einar,&lt;/p&gt;
&lt;p&gt;Is this exposed through the python layer? I will see if I can find it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: re-init or resetting nrf52 dongle with pc-ble-driver-py</title><link>https://devzone.nordicsemi.com/thread/159703?ContentTypeID=1</link><pubDate>Fri, 30 Nov 2018 12:55:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8165e30e-73ee-4fd0-8031-a233a71c7df6</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have not tested myself, but there is a&amp;nbsp;SER_PKT_TYPE_RESET_CMD that could be used to reset the nRF via the serialization API. Have you tried that?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>