Beispiel #1
0
 def ble_gatt_discover_all_primary_services(self, session_id):
     """Function defined in GattInterface."""
     link_id = self._ble_sessions_get_link_id_from_session_id(session_id)
     if link_id is not None:
         command = 'BLE_GET_SERV'
         args = ['{:X}'.format(link_id)]
         if self._execute(command, args) is BC127_RESULT_SUCCESS:
             regex = r"BLE_SERV (\d4) (\w+) ([0-9A-F|\-]+) ([0-9A-F]{4}) ([0-9A-F]{4})" \
                      + BC127_EOL
             responses = self._serial.serial_search_regex_all(regex)
             return [
                 BleInterface.GattService(resp[2], True, int(resp[3], 16),
                                          int(resp[4], 16))
                 for resp in responses
             ]
     return None
Beispiel #2
0
 def ble_gatt_discover_all_primary_services(self, session_id):
     """Function defined in GattInterface. """
     if not self._enable_bluetooth():
         return None
     command = '+SRBLEDISCSERV'
     args = [session_id]
     res = None
     if self._write(command, args) is EUL_RESULT_SUCCESS:
         regex = r"\+SRBLEDISCSERV: (%d),\"([0-9a-f|\-]+)\",(1),(\d+),(\d+)" % (
             session_id)
         responses = self._serial.serial_search_regex_all(regex)
         res = []
         for resp in responses:
             res.append(
                 BleInterface.GattService(resp[1].upper(), True,
                                          int(resp[3]), int(resp[4])))
         return res
     return None