Exemplo n.º 1
0
    def _run_coc_connection_throughput_2_conn(
            self,
            is_secured,
            buffer_size,
            le_connection_interval=0,
            le_tx_data_length=default_le_data_length,
            min_ce_len=0,
            max_ce_len=0):

        # The num_iterations is that number of repetitions of each
        # set of buffers r/w.
        # number_buffers is the total number of data buffers to transmit per
        # set of buffers r/w.
        # buffer_size is the number of bytes per L2CAP data buffer.
        num_iterations = 10
        number_buffers = 100

        # Make sure at least 3 phones are setup
        if len(self.android_devices) <= 2:
            self.log.info("test_coc_connection_throughput_2_conn: "
                          "Error: 3rd phone not configured in file")
            return False

        self.log.info(
            "_run_coc_connection_throughput_2_conn: is_secured={}, Interval={}, buffer_size={}, "
            "le_tx_data_length={}, min_ce_len={}".format(is_secured, le_connection_interval,
                                          buffer_size, le_tx_data_length, min_ce_len))
        status, client_conn_id1, server_conn_id1 = orchestrate_coc_connection(
            self.client_ad, self.server_ad, True, is_secured,
            le_connection_interval, le_tx_data_length, default_bluetooth_socket_timeout_ms,
            min_ce_len, max_ce_len)
        if not status:
            return False

        status, client_conn_id2, server_conn_id2 = orchestrate_coc_connection(
            self.client_ad, self.server2_ad, True, is_secured,
            le_connection_interval, le_tx_data_length, default_bluetooth_socket_timeout_ms,
            min_ce_len, max_ce_len)
        if not status:
            return False

        list_server_ad = [self.server_ad, self.server2_ad]
        list_client_conn_id = [client_conn_id1, client_conn_id2]
        data_rate = do_multi_connection_throughput(
            self.client_ad, list_server_ad, list_client_conn_id,
            num_iterations, number_buffers, buffer_size)
        if data_rate <= 0:
            return False

        self.log.info(
            "test_coc_connection_throughput_2_conn: throughput=%d bytes per "
            "sec", data_rate)

        self.client_ad.droid.bluetoothSocketConnStop(client_conn_id1)
        self.client_ad.droid.bluetoothSocketConnStop(client_conn_id2)
        self.server_ad.droid.bluetoothSocketConnStop(server_conn_id1)
        self.server2_ad.droid.bluetoothSocketConnStop(server_conn_id2)
        return True
Exemplo n.º 2
0
    def test_coc_insecured_connection(self):
        """Test Bluetooth LE CoC insecured connection

        Test LE CoC though establishing a basic connection with no security.

        Steps:
        1. Get the mac address of the server device.
        2. Establish an LE CoC Secured connection from the client to the server AD.
        3. Verify that the LE CoC connection is active from both the client and
        server.
        Expected Result:
        LE CoC connection is established then disconnected succcessfully.

        Returns:
          Pass if True
          Fail if False

        TAGS: BLE, CoC
        Priority: 1
        """
        is_secured = False
        self.log.info(
            "test_coc_insecured_connection: calling orchestrate_coc_connection but "
            "isBle=1 and securedConn={}".format(is_secured))
        status, client_conn_id, server_conn_id = orchestrate_coc_connection(
            self.client_ad, self.server_ad, True, is_secured)
        if not status:
            return False

        return True
def ble_coc_connection(client_ad, server_ad):
    """Sets up the CoC connection between two Android devices.

    Args:
        client_ad: the Android device performing the connection.
        server_ad: the Android device accepting the connection.

    Returns:
        True if connection was successful or false if unsuccessful,
        gatt_callback: GATT callback object
        client connection ID: Client connection ID
        and server connection ID : server connection ID
    """
    #secured_conn: True if using secured connection
    #le_connection_interval: LE Connection interval. 0 means use default.
    #buffer_size : is the number of bytes per L2CAP data buffer
    #le_tx_data_length: LE Data Length used by BT Controller to transmit.
    is_secured = False
    le_connection_interval = 30
    buffer_size = 240
    le_tx_data_length = buffer_size + l2cap_coc_header_size
    gatt_server_cb = server_ad.droid.gattServerCreateGattServerCallback()
    gatt_server = server_ad.droid.gattServerOpenGattServer(gatt_server_cb)

    logging.info(
        "orchestrate_ble_coc_connection. is_secured={}, Connection Interval={}msec, "
        "buffer_size={}bytes".format(is_secured, le_connection_interval,
                                     buffer_size))
    try:
        status, client_conn_id, server_conn_id, bluetooth_gatt, gatt_callback = orchestrate_coc_connection(
            client_ad,
            server_ad,
            True,
            is_secured,
            le_connection_interval,
            le_tx_data_length,
            gatt_disconnection=False)
    except Exception as err:
        logging.info("Failed to esatablish COC connection".format(err))
        return 0
    return True, gatt_callback, gatt_server, bluetooth_gatt, client_conn_id
Exemplo n.º 4
0
    def test_coc_insecured_connection_write_ascii(self):
        """Test LE CoC insecured connection writing and reading ascii data

        Test LE CoC though establishing a connection.

        Steps:
        1. Get the mac address of the server device.
        2. Establish an LE CoC connection from the client to the server AD. The security of
        connection is FALSE.
        3. Verify that the LE CoC connection is active from both the client and
        server.
        4. Write data from the client and read received data from the server.
        5. Verify data matches from client and server
        6. Disconnect the LE CoC connection.

        Expected Result:
        LE CoC connection is established then disconnected succcessfully.

        Returns:
          Pass if True
          Fail if False

        TAGS: BLE, CoC
        Priority: 1
        """
        is_secured = False
        self.log.info(
            "test_coc_secured_connection_write_ascii: calling "
            "orchestrate_coc_connection. is_secured={}".format(is_secured))
        status, client_conn_id, server_conn_id = orchestrate_coc_connection(
            self.client_ad, self.server_ad, True, is_secured)
        if not status:
            return False
        if not write_read_verify_data(self.client_ad, self.server_ad,
                                      self.message, False):
            return False
        if not verify_server_and_client_connected(self.client_ad,
                                                  self.server_ad):
            return False

        return True
Exemplo n.º 5
0
    def _run_coc_connection_throughput(
            self,
            is_secured,
            buffer_size,
            le_connection_interval=0,
            le_tx_data_length=default_le_data_length):

        # The num_iterations is that number of repetitions of each
        # set of buffers r/w.
        # number_buffers is the total number of data buffers to transmit per
        # set of buffers r/w.
        # buffer_size is the number of bytes per L2CAP data buffer.
        number_buffers = 100
        num_iterations = 10

        self.log.info(
            "_run_coc_connection_throughput: calling "
            "orchestrate_coc_connection. is_secured={}, Connection Interval={}msec, "
            "buffer_size={}bytes".format(is_secured, le_connection_interval,
                                         buffer_size))
        status, client_conn_id, server_conn_id = orchestrate_coc_connection(
            self.client_ad, self.server_ad, True, is_secured,
            le_connection_interval, le_tx_data_length)
        if not status:
            return False

        list_server_ad = [self.server_ad]
        list_client_conn_id = [client_conn_id]
        data_rate = do_multi_connection_throughput(self.client_ad,
                                                   list_server_ad,
                                                   list_client_conn_id,
                                                   num_iterations,
                                                   number_buffers, buffer_size)
        if data_rate <= 0:
            return False
        self.log.info(
            "_run_coc_connection_throughput: throughput=%d bytes per sec",
            data_rate)

        return True