Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
test_client_server40_reset.cpp
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
26
28
29using namespace direct_bt;
30
31/**
32 * Testing a full Bluetooth server and client lifecycle of operations including adapter reset, requiring two BT adapter:
33 * - trigger client adapter reset
34 * - operating w/o encryption
35 * - start server advertising
36 * - start client discovery and connect to server when discovered
37 * - client/server processing of connection when ready
38 * - client disconnect
39 * - server stop advertising
40 * - security-level: NONE, ENC_ONLY freshly-paired and ENC_ONLY pre-paired
41 * - reuse server-adapter for client-mode discovery (just toggle on/off)
42 */
44 private:
45 static constexpr const bool serverSC = true;
46
47 public:
50 {
51 const std::string suffix = "40";
52 const int protocolSessionCount = 1;
53 const int max_connections_per_session = DBTConstants::max_connections_per_session;
54 const bool expSuccess = true;
55 const bool server_client_order = true;
56 const BTSecurityLevel secLevelServer = BTSecurityLevel::NONE;
57 const BTSecurityLevel secLevelClient = BTSecurityLevel::NONE;
58 const ExpectedPairing serverExpPairing = ExpectedPairing::DONT_CARE;
59 const ExpectedPairing clientExpPairing = ExpectedPairing::DONT_CARE;
60
61 std::shared_ptr<DBTServerTest> server = std::make_shared<DBTServer01>("S-"+suffix, EUI48::ALL_DEVICE, BTMode::DUAL, serverSC, secLevelServer);
62 std::shared_ptr<DBTClientTest> client = std::make_shared<DBTClient01>("C-"+suffix, EUI48::ALL_DEVICE, BTMode::DUAL);
63
64 server->setProtocolSessionsLeft( protocolSessionCount );
65
66 client->setProtocolSessionsLeft( protocolSessionCount );
67 client->setDisconnectDevice( true ); // default, auto-disconnect after work is done
68 client->setRemoveDevice( false ); // default, test side-effects
69 client->setDiscoveryPolicy( DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_DISCONNECTED );
70
72
73 test8x_fullCycle(suffix,
74 max_connections_per_session, expSuccess,
75 server_client_order,
76 server, secLevelServer, serverExpPairing,
77 client, secLevelClient, clientExpPairing);
78 }
80 }
81
82};
83
84METHOD_AS_TEST_CASE( TestDBTClientServer40_Reset::test40_ClientReset01, "ClientServer 40 Reset Trial", "[trial][serverclient][reset]");
void setupTest(const jau::fraction_i64 timeout=0_s)
Ensure.
Testing a full Bluetooth server and client lifecycle of operations, requiring two BT adapter:
void set_client_reset_at_ready(const bool v) noexcept
void test8x_fullCycle(const std::string &suffix, const int protocolSessionCount, const bool server_client_order, const bool serverSC, const BTSecurityLevel secLevelServer, const ExpectedPairing serverExpPairing, const BTSecurityLevel secLevelClient, const ExpectedPairing clientExpPairing)
static constexpr const int max_connections_per_session
Testing a full Bluetooth server and client lifecycle of operations including adapter reset,...
static BaseDBTClientServer & base_test_framework
BTSecurityLevel
Bluetooth Security Level.
Definition: BTTypes0.hpp:267
METHOD_AS_TEST_CASE(TestDBTClientServer40_Reset::test40_ClientReset01, "ClientServer 40 Reset Trial", "[trial][serverclient][reset]")
ExpectedPairing