<?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>How to select Packet type in pc-ble-driver-py and to switch between scan and adv mode</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/45708/how-to-select-packet-type-in-pc-ble-driver-py-and-to-switch-between-scan-and-adv-mode</link><description>Hello 
 
 I used the pc-ble-driver-py to advertise Apple ibeacons, but it seems that they&amp;#39;re advertised as connectable undirected packets which is not good in my case, as I filter in NRF52 firmware packets based on packet type (1- not scan response 2</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 03 Apr 2019 17:31:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/45708/how-to-select-packet-type-in-pc-ble-driver-py-and-to-switch-between-scan-and-adv-mode" /><item><title>RE: How to select Packet type in pc-ble-driver-py and to switch between scan and adv mode</title><link>https://devzone.nordicsemi.com/thread/180095?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2019 17:31:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14a302fc-f241-4059-8f32-36316b0ee627</guid><dc:creator>Yahya Tawil</dc:creator><description>&lt;p&gt;Thanks Jorgen&lt;/p&gt;
&lt;p&gt;I already did that as a change inside the driver, but it will be very helpful to add this option originally in your package.&lt;/p&gt;
&lt;p&gt;About the other problem, There is no special reason behind that, I will try using the other way soon and let you know if could solve it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to select Packet type in pc-ble-driver-py and to switch between scan and adv mode</title><link>https://devzone.nordicsemi.com/thread/180074?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2019 15:25:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d774c03-cf4a-4199-9373-fdebcfb3b495</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Yes, you can change the advertising type there, but you can also extend the driver with a parameter for type in&amp;nbsp;BLEGapAdvParams, that can be configured in the application:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="python"&gt;class BLEGapAdvParams(object):
    def __init__(self, interval_ms, timeout_s, adv_type):
        self.interval_ms    = interval_ms
        self.timeout_s      = timeout_s
        self.adv_type       = adv_type


    def to_c(self):
        adv_params              = driver.ble_gap_adv_params_t()
        adv_params.type         = self.adv_type
        adv_params.p_peer_addr  = None  # Undirected advertisement.
        adv_params.fp           = driver.BLE_GAP_ADV_FP_ANY
        adv_params.p_whitelist  = None
        adv_params.interval     = util.msec_to_units(self.interval_ms,
                                                                util.UNIT_0_625_MS)
        adv_params.timeout      = self.timeout_s

        return adv_params&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You would then also have to modify the setup function:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="python"&gt;    def adv_params_setup(self):
        return BLEGapAdvParams(interval_ms = 40,
                               timeout_s   = 180,
							   adv_type    = BLEGapAdvType.connectable_undirected.value)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;It should then be possible to set the type directly in the application (this is from modified advertising.py example):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="python"&gt;def init(conn_ic_id):
    global BLEDriver, BLEAdvData, BLEEvtID, BLEGapAdvParams, BLEGapAdvType
    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, BLEGapAdvParams, BLEGapAdvType

def main(serial_port):
    print(&amp;quot;Serial port used: {}&amp;quot;.format(serial_port))
    driver      = BLEDriver(serial_port=serial_port, auto_flash=True)
    observer    = TimeoutObserver()
    adv_data    = BLEAdvData(complete_local_name=&amp;#39;Example&amp;#39;)
    adv_params  = BLEGapAdvParams(interval_ms=40, timeout_s=180, adv_type=BLEGapAdvType.non_connectable_undirected)

    driver.observer_register(observer)
    driver.open()
    driver.ble_enable()
    driver.ble_gap_adv_data_set(adv_data)
    driver.ble_gap_adv_start()
    observer.wait_for_timeout()

    print(&amp;quot;Closing&amp;quot;)
    driver.close()&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Is there any specific reason that you start scanning with &amp;#39;self.&lt;strong&gt;adapter&lt;/strong&gt;.driver.ble_gap_scan_start()&amp;#39; and not &amp;#39;self.driver.ble_gap_scan_start()&amp;#39;? I think this will call functions directly in the C library.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to select Packet type in pc-ble-driver-py and to switch between scan and adv mode</title><link>https://devzone.nordicsemi.com/thread/180048?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2019 14:15:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c16e342-f032-4d9c-b4ea-80a71cfdc4a0</guid><dc:creator>Yahya Tawil</dc:creator><description>&lt;p&gt;Hello J&amp;oslash;rgen&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;First question was to know how to switch advertised packet type between connectable and non-connectable ?&lt;br /&gt;Yes, I can advertise correctly but I don&amp;#39;t want the advertisements to be connectable&lt;/p&gt;
&lt;p&gt;Regards, the second question .. I start with adv/scan and then switch to the scan/adv and get &lt;em&gt;Failed to ble_gap_adv/scan_start&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="python"&gt;            self.driver      = BLEDriver(serial_port=&amp;quot;COM8&amp;quot;, auto_flash=False)
            adv_data    = BLEAdvData(flags=flags_data,manufacturer_specific_data=manu_data)
            self.driver.observer_register(self)
            self.adapter.driver.observer_register(self)
            self.driver.open()
            self.driver.ble_enable()
            self.driver.ble_gap_adv_data_set(adv_data)
            self.driver.ble_gap_adv_start()
            time.sleep(2)
            self.driver.ble_gap_adv_stop()
            time.sleep(4)
            self.adapter.driver.ble_gap_scan_start() #here I get the error failed to start scan
            &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have&lt;em&gt; pc-ble-driver-py 0.11.4&lt;/em&gt; with &lt;em&gt;connectivity_1.2.0_115k2_with_s132_3.0.hex &lt;/em&gt;and nrf52 dev kit. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to select Packet type in pc-ble-driver-py and to switch between scan and adv mode</title><link>https://devzone.nordicsemi.com/thread/180041?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2019 13:47:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f81f8f06-afc0-405f-8baa-83f2a66af7e1</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure that I understand your first question. Are you asking if this is the correct way of defining packet type? Have you tested if it works?&lt;/p&gt;
&lt;p&gt;Regarding your second question, which version of pc-ble-driver-py are you using, and on which chip? Error code 18 typically means&amp;nbsp;&lt;a href="https://www.nordicsemi.com/DocLib/Content/SoftDevice_API_Doc/S132/v3-0-0/group__nrf__error.html#ga5fc58fcfed7097d1205c96acb5a66ab8"&gt;NRF_ERROR_CONN_COUNT&lt;/a&gt;, which indicate that you have reached the number of allowed connections and that advertising can therefore not be started.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>