Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
test_provoke_client_server_i470.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
29// #include "dbt_server01.hpp"
30// #include "dbt_client01.hpp"
31
32using namespace direct_bt;
33
34/**
35 * Testing w/o client filtering processing device and hence not blocking deviceFound.
36 *
37 * In other words, relying on BTAdapter to filter out:
38 * - already discovered devices
39 * - already connected devices
40 *
41 * Further, the server will issue a disconnect once only 300 ms after 1st MTU exchange,
42 * disrupting the client's getGATTServices().
43 */
45 public:
46 void test_i470_a() {
48 {
49 const bool serverSC = true;
50 const std::string suffix = "i470_a";
51 const int protocolSessionCount = 10;
52 const int max_connections_per_session = 200;
53 const bool expSuccess = false;
54 const bool server_client_order = true;
55 const BTSecurityLevel secLevelServer = BTSecurityLevel::ENC_ONLY;
56 const BTSecurityLevel secLevelClient = BTSecurityLevel::ENC_ONLY;
57 const ExpectedPairing serverExpPairing = ExpectedPairing::DONT_CARE;
58 const ExpectedPairing clientExpPairing = ExpectedPairing::DONT_CARE;
59 const bool client_do_disconnect_random = true;
60 const bool server_do_disconnect_random = false;
61
62 std::shared_ptr<DBTServerTest> server = std::make_shared<DBTServer01>("S-"+suffix, EUI48::ALL_DEVICE, BTMode::DUAL, serverSC, secLevelServer, server_do_disconnect_random);
63 std::shared_ptr<DBTClientTest> client = std::make_shared<DBTClient01>("C-"+suffix, EUI48::ALL_DEVICE, BTMode::DUAL, client_do_disconnect_random);
64
65 server->setProtocolSessionsLeft( protocolSessionCount );
66
67 client->setProtocolSessionsLeft( protocolSessionCount );
68 client->setDisconnectDevice( true ); // default, auto-disconnect after work is done
69 client->setRemoveDevice( false ); // default, test side-effects
70 client->setDiscoveryPolicy( DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_DISCONNECTED );
71
72 test8x_fullCycle(suffix,
73 max_connections_per_session, expSuccess,
74 server_client_order,
75 server, secLevelServer, serverExpPairing,
76 client, secLevelClient, clientExpPairing);
77 }
79 }
80
81 void test_i470_b() {
83 {
84 const bool serverSC = true;
85 const std::string suffix = "i470_b";
86 const int protocolSessionCount = 10;
87 const int max_connections_per_session = 200;
88 const bool expSuccess = false;
89 const bool server_client_order = true;
90 const BTSecurityLevel secLevelServer = BTSecurityLevel::ENC_ONLY;
91 const BTSecurityLevel secLevelClient = BTSecurityLevel::ENC_ONLY;
92 const ExpectedPairing serverExpPairing = ExpectedPairing::DONT_CARE;
93 const ExpectedPairing clientExpPairing = ExpectedPairing::DONT_CARE;
94 const bool client_do_disconnect_random = false;
95 const bool server_do_disconnect_random = true;
96
97 std::shared_ptr<DBTServerTest> server = std::make_shared<DBTServer01>("S-"+suffix, EUI48::ALL_DEVICE, BTMode::DUAL, serverSC, secLevelServer, server_do_disconnect_random);
98 std::shared_ptr<DBTClientTest> client = std::make_shared<DBTClient01>("C-"+suffix, EUI48::ALL_DEVICE, BTMode::DUAL, client_do_disconnect_random);
99
100 server->setProtocolSessionsLeft( protocolSessionCount );
101
102 client->setProtocolSessionsLeft( protocolSessionCount );
103 client->setDisconnectDevice( true ); // default, auto-disconnect after work is done
104 client->setRemoveDevice( false ); // default, test side-effects
105 client->setDiscoveryPolicy( DiscoveryPolicy::PAUSE_CONNECTED_UNTIL_DISCONNECTED );
106
107 test8x_fullCycle(suffix,
108 max_connections_per_session, expSuccess,
109 server_client_order,
110 server, secLevelServer, serverExpPairing,
111 client, secLevelClient, clientExpPairing);
112 }
114 }
115};
116
117METHOD_AS_TEST_CASE( TestDBTClientServer_i470::test_i470_a, "ClientServer i470 Trial a", "[trial][i470]");
118METHOD_AS_TEST_CASE( TestDBTClientServer_i470::test_i470_b, "ClientServer i470 Trial b", "[trial][i470]");
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 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)
Testing w/o client filtering processing device and hence not blocking deviceFound.
static BaseDBTClientServer & base_test_framework
BTSecurityLevel
Bluetooth Security Level.
Definition: BTTypes0.hpp:267
METHOD_AS_TEST_CASE(TestDBTClientServer_i470::test_i470_a, "ClientServer i470 Trial a", "[trial][i470]")
ExpectedPairing