Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
TestDBTClientServer40_Reset.java
Go to the documentation of this file.
1/**
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2022 Gothel Software e.K.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25package trial.org.direct_bt;
26
27import org.direct_bt.BTMode;
28import org.direct_bt.BTSecurityLevel;
29import org.direct_bt.DiscoveryPolicy;
30import org.jau.net.EUI48;
31import org.junit.FixMethodOrder;
32import org.junit.Test;
33import org.junit.runners.MethodSorters;
34
35/**
36 * Testing a full Bluetooth server and client lifecycle of operations including adapter reset, requiring two BT adapter:
37 * - trigger client adapter reset
38 * - operating w/o encryption
39 * - start server advertising
40 * - start client discovery and connect to server when discovered
41 * - client/server processing of connection when ready
42 * - client disconnect
43 * - server stop advertising
44 * - security-level: NONE, ENC_ONLY freshly-paired and ENC_ONLY pre-paired
45 * - reuse server-adapter for client-mode discovery (just toggle on/off)
46 */
47@FixMethodOrder(MethodSorters.NAME_ASCENDING)
49 static final boolean serverSC = true;
50
51 @Test(timeout = 20000)
52 public final void test40_ClientReset01() {
53 final String suffix = "40";
54 final int protocolSessionCount = 1;
55 final int max_connections_per_session = DBTConstants.max_connections_per_session;
56 final boolean expSuccess = true;
57 final boolean server_client_order = true;
58 final BTSecurityLevel secLevelServer = BTSecurityLevel.NONE;
59 final BTSecurityLevel secLevelClient = BTSecurityLevel.NONE;
60 final ExpectedPairing serverExpPairing = ExpectedPairing.DONT_CARE;
61 final ExpectedPairing clientExpPairing = ExpectedPairing.DONT_CARE;
62
63 final DBTServerTest server = new DBTServer01("S-"+suffix, EUI48.ALL_DEVICE, BTMode.DUAL, serverSC, secLevelServer);
64 final DBTClientTest client = new DBTClient01("C-"+suffix, EUI48.ALL_DEVICE, BTMode.DUAL);
65
66 server.setProtocolSessionsLeft( protocolSessionCount );
67
68 client.setProtocolSessionsLeft( protocolSessionCount );
69 client.setDisconnectDeviceed( true ); // default, auto-disconnect after work is done
70 client.setRemoveDevice( false ); // default, test side-effects
72
73 set_client_reset_at_ready(true);
74
75 test8x_fullCycle(20000, suffix,
76 max_connections_per_session, expSuccess, server_client_order,
77 server, secLevelServer, serverExpPairing,
78 client, secLevelClient, clientExpPairing);
79 }
80
81 public static void main(final String args[]) {
82 org.junit.runner.JUnitCore.main(TestDBTClientServer40_Reset.class.getName());
83 }
84}
This central BTRole::Master participant works with DBTServer00.
Testing a full Bluetooth server and client lifecycle of operations, requiring two BT adapter:
static final int max_connections_per_session
This peripheral BTRole::Slave test participant works with DBTClient00.
Testing a full Bluetooth server and client lifecycle of operations including adapter reset,...
Bluetooth adapter operating mode.
Definition: BTMode.java:34
DUAL
Dual Bluetooth mode, i.e.
Definition: BTMode.java:38
Bluetooth Security Level.
NONE
No encryption and no authentication.
Discovery policy defines the BTAdapter discovery mode after connecting a remote BTDevice:
PAUSE_CONNECTED_UNTIL_DISCONNECTED
Pause discovery until all connected BTDevice become disconnected, effectively until AdapterStatusList...
void setDisconnectDeviceed(final boolean v)
Set disconnect after processing.
void setRemoveDevice(final boolean v)
Set remove device when disconnecting.
void setDiscoveryPolicy(final DiscoveryPolicy v)
Set DiscoveryPolicy.
void setProtocolSessionsLeft(final int v)