Skip to content

Commit 908f954

Browse files
authored
Merge pull request #78 from fpistm/sync_1.4.0
Sync 1.4.0
2 parents fb3da3b + 3c253e4 commit 908f954

14 files changed

+603
-39
lines changed

.github/workflows/compile-examples.yml

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ on:
1212
- ".github/workflows/compile-examples.yml"
1313
- "examples/**"
1414
- "src/**"
15+
schedule:
16+
# Run every Tuesday at 8 AM UTC to catch breakage caused by changes to external resources (libraries, platforms).
17+
- cron: "0 8 * * TUE"
1518
workflow_dispatch:
1619

1720
jobs:

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ The user can include the file `app_conf_custom.h` to customize the BLE applicati
3131
Options wrapped in `#ifndef`, `#endif` in `app_conf_default.h` can be overwritten.
3232
Additional options can be added.
3333

34+
The user can refer to [AN5270](https://www.st.com/resource/en/application_note/an5270-introduction-to-stm32wb-bluetooth-low-energy-wireless-interface-stmicroelectronics.pdf)
35+
36+
##### Examples
37+
38+
The user can change the Tx Power by redefining `CFG_TX_POWER` using the [`build_opt.h`](https://github.com/stm32duino/Arduino_Core_STM32/wiki/Customize-build-options-using-build_opt.h) file. Possible values are listed in the chapter
39+
**4.2 Tx power level**, default value is `0x18`(`-0.15dBm`). To set it at `+1dBm`, `CFG_TX_POWER` have to be defined at `0x1A`:
40+
41+
```
42+
-DCFG_TX_POWER=0x1A
43+
```
44+
3445
### Shield
3546

3647
The user can include the file `ble_spi_conf.h` to define which shield and configuration to use from the following list:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/*
2+
This file is part of the ArduinoBLE library.
3+
Copyright (c) 2018 Arduino SA. All rights reserved.
4+
5+
This library is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU Lesser General Public
7+
License as published by the Free Software Foundation; either
8+
version 2.1 of the License, or (at your option) any later version.
9+
10+
This library is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
Lesser General Public License for more details.
14+
15+
You should have received a copy of the GNU Lesser General Public
16+
License along with this library; if not, write to the Free Software
17+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18+
*/
19+
20+
#include <catch2/catch_test_macros.hpp>
21+
22+
#define private public
23+
#define protected public
24+
25+
#include "FakeBLELocalDevice.h"
26+
#include "BLEAdvertisingData.h"
27+
#include "BLETypedCharacteristics.h"
28+
#include "BLELocalCharacteristic.h"
29+
#include "BLEStringCharacteristic.h"
30+
#include "BLEProperty.h"
31+
#include <memory>
32+
33+
int property[] = {
34+
BLEBroadcast,
35+
BLERead,
36+
BLEWriteWithoutResponse,
37+
BLEWrite,
38+
BLENotify,
39+
BLEIndicate,
40+
BLEAuthSignedWrite,
41+
BLEExtProp,
42+
BLERead | BLEWrite | BLENotify
43+
};
44+
45+
int permission[] = {
46+
BLEEncryption,
47+
BLEAuthentication,
48+
BLEAuthorization,
49+
BLEEncryption | BLEAuthentication
50+
};
51+
52+
const char uuid[][31] = {
53+
"1 Bool",
54+
"2 Char",
55+
"3 UnsignedChar",
56+
"4 Byte",
57+
"5 Short",
58+
"6 UnsignedShort",
59+
"7 Word",
60+
"8 Int",
61+
"9 UnsignedInt",
62+
"A Long",
63+
"B UnsignedLong",
64+
"C Float",
65+
"D Double",
66+
"E String"
67+
};
68+
69+
std::unique_ptr<BLECharacteristic> createCharacteristic(const char* uuid, unsigned int properties)
70+
{
71+
switch(uuid[0])
72+
{
73+
case '1':
74+
return std::unique_ptr<BLECharacteristic>(new BLEBoolCharacteristic(uuid, properties));
75+
case '2':
76+
return std::unique_ptr<BLECharacteristic>(new BLECharCharacteristic(uuid, properties));
77+
case '3':
78+
return std::unique_ptr<BLECharacteristic>(new BLEUnsignedCharCharacteristic(uuid, properties));
79+
case '4':
80+
return std::unique_ptr<BLECharacteristic>(new BLEByteCharacteristic(uuid, properties));
81+
case '5':
82+
return std::unique_ptr<BLECharacteristic>(new BLEShortCharacteristic(uuid, properties));
83+
case '6':
84+
return std::unique_ptr<BLECharacteristic>(new BLEUnsignedShortCharacteristic(uuid, properties));
85+
case '7':
86+
return std::unique_ptr<BLECharacteristic>(new BLEWordCharacteristic(uuid, properties));
87+
case '8':
88+
return std::unique_ptr<BLECharacteristic>(new BLEIntCharacteristic(uuid, properties));
89+
case '9':
90+
return std::unique_ptr<BLECharacteristic>(new BLEUnsignedIntCharacteristic(uuid, properties));
91+
case 'A':
92+
return std::unique_ptr<BLECharacteristic>(new BLELongCharacteristic(uuid, properties));
93+
case 'B':
94+
return std::unique_ptr<BLECharacteristic>(new BLEUnsignedLongCharacteristic(uuid, properties));
95+
case 'C':
96+
return std::unique_ptr<BLECharacteristic>(new BLEFloatCharacteristic(uuid, properties));
97+
case 'D':
98+
return std::unique_ptr<BLECharacteristic>(new BLEDoubleCharacteristic(uuid, properties));
99+
case 'E':
100+
return std::unique_ptr<BLECharacteristic>(new BLEStringCharacteristic(uuid, properties, 2));
101+
default:
102+
break;
103+
}
104+
return nullptr;
105+
}
106+
107+
TEST_CASE("Test characteristic properties and permissions", "[ArduinoBLE::BLECharacteristic]")
108+
{
109+
WHEN("Create a characteristic")
110+
{
111+
for(int i = 0; i < sizeof(property)/sizeof(int); i++)
112+
{
113+
for(int j = 0; j < sizeof(permission)/sizeof(int); j++)
114+
{
115+
for(int k = 0; k < 14; k++)
116+
{
117+
std::unique_ptr<BLECharacteristic> ptr = createCharacteristic(uuid[k], property[i] | permission[j]);
118+
REQUIRE(ptr != nullptr);
119+
REQUIRE(ptr->properties() == (property[i]));
120+
BLELocalCharacteristic * local = ptr->local();
121+
REQUIRE(local->permissions() == (permission[j] >> 8));
122+
}
123+
}
124+
}
125+
}
126+
}

0 commit comments

Comments
 (0)