def init(conn_ic_id): # noinspection PyGlobalUndefined global config, BLEDriver, BLEAdvData, BLEEvtID, BLEAdapter, BLEEnableParams, BLEGapTimeoutSrc, BLEUUID, BLEConfigCommon, BLEConfig, BLEConfigConnGatt, BLEGapScanParams from pc_ble_driver_py import config config.__conn_ic_id__ = conn_ic_id # noinspection PyUnresolvedReferences from pc_ble_driver_py.ble_driver import ( BLEDriver, BLEAdvData, BLEEvtID, BLEEnableParams, BLEGapTimeoutSrc, BLEUUID, BLEGapScanParams, BLEConfigCommon, BLEConfig, BLEConfigConnGatt, ) # noinspection PyUnresolvedReferences 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()
def init(conn_ic_id): global BLEDriver, BLEAdvData, BLEEvtID, BLEAdapter, BLEEnableParams, BLEGapTimeoutSrc, BLEUUID, BLEUUIDBase from pc_ble_driver_py import config config.__conn_ic_id__ = conn_ic_id from pc_ble_driver_py.ble_driver import BLEUUIDBase, BLEDriver, BLEAdvData, BLEUUIDBase, 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()
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()
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # import pc_ble_driver_py.config as config from pc_ble_driver_py.exceptions import NordicSemiException nrf_sd_ble_api_ver = config.sd_api_ver_get() if nrf_sd_ble_api_ver == 2: import pc_ble_driver_py.lib.nrf_ble_driver_sd_api_v2 as ble_driver elif nrf_sd_ble_api_ver == 5: import pc_ble_driver_py.lib.nrf_ble_driver_sd_api_v5 as ble_driver else: raise NordicSemiException( "SoftDevice API {} not supported".format(nrf_sd_ble_api_ver)) UNIT_0_625_MS = 625 # Unit used for scanning and advertising parameters UNIT_1_25_MS = 1250 # Unit used for connection interval parameters UNIT_10_MS = 10000 # Unit used for supervision timeout parameter def msec_to_units(time_ms, resolution):
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # import importlib import pc_ble_driver_py.config as config nrf_sd_ble_api_ver = config.sd_api_ver_get() # Load pc_ble_driver SWIG_MODULE_NAME = "pc_ble_driver_sd_api_v{}".format(nrf_sd_ble_api_ver) try: ble_driver = importlib.import_module(SWIG_MODULE_NAME) except Exception: print("Error. No ble_driver module found.") UNIT_0_625_MS = 625 # Unit used for scanning and advertising parameters UNIT_1_25_MS = 1250 # Unit used for connection interval parameters UNIT_10_MS = 10000 # Unit used for supervision timeout parameter def msec_to_units(time_ms, resolution): """Convert milliseconds to BLE specific time units."""