Technologia Bluetooth Low Energy w...
Transcript of Technologia Bluetooth Low Energy w...
![Page 1: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/1.jpg)
Technologia
Bluetooth Low Energy
w Delphi
![Page 2: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/2.jpg)
WITAM! Mateusz Gancarczyk
[email protected] www.mattpro.pl
Pierwsze PCB i zamruganie diodą LED – 2008 rok Delphi od 2009 roku
Pierwsza aplikacja mobilna - 2014 rok.
![Page 3: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/3.jpg)
Plan prezentacji
1. O technologii Bluetooth Low Energy
2. Beacon - Smart Flower Pot
3. Urządzenie Bluetooth Low Energy – Led Conroller
4. Podsumowanie
![Page 4: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/4.jpg)
1. O technologii Bluetooth LE
1. Wersje standardów 2. Warstwa fizyczna 3. GAP – Generic Access Profile 4. GATT - Generic Attribute Profile 5. Kilka słów o Bluetooth 5
![Page 5: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/5.jpg)
Wersje standardu
Bluetooth Clasic 1.0., 2.0, 3.0 …
Bluetooth 5
Bluetooth Low Energy
4.0, 4.1, 4.2
![Page 6: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/6.jpg)
Bluetooth Low Energy Wersje standardu - porównanie
Specyfikacja
techniczna Bluetooth Classic
Bluetooth
Low Energy Bluetooth 5
Zasięg 100 m >100 m ~1km
Prędkość transmisji 1–3 Mbit/s 1 Mbit/s 125kbs-2Mbit/s
Przepustowość 0,7–40 Mbit/s 0,27 Mbit/s 1,4 Mbit/s
Opóźnienie ~100 ms 6 ms 6 ms
Minimalny czas do
wysłania ramki 100 ms 3 ms 3 ms
![Page 7: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/7.jpg)
Bluetooth Low Energy Warstwa fizyczna
![Page 8: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/8.jpg)
Rodzaje urządzeń: 1) Peripheral 2) Central
Bluetooth Low Energy Rodzaje urządzeń
![Page 9: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/9.jpg)
Każde peripheral posiada unikalny 6 bajtowy MAC Address Periodyczne wysyłanie do 31 bajtów danych Scan response – na żądanie centrali
Bluetooth Low Energy Advertising
![Page 10: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/10.jpg)
Tryb advertising – wysłanie danych do nieograniczonej ilości urządzeń typu
central będących w zasięgu.
Bluetooth Low Energy Broadcasting
![Page 11: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/11.jpg)
Charakterystyki – pojedyncze dane.
Serwisy – logiczny zbiór charakterystyk.
Profile – predefiniowanie kolekcje serwisów i charakterystyk zatwierdzone przez Bluetooth SIG.
Bluetooth Low Energy Profile, serwisy i charakterystyki
![Page 12: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/12.jpg)
Kontroluje connections i advertising in Bluetooth LE, Determinuje jak dwa urządzenia oddziałowują między sobą.
Bluetooth Low Energy Profil GAP – Generic Access Profile
![Page 13: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/13.jpg)
Definiuje sposób w jaki dwa połączone ze sobą urządzenia (central i peripheral )
przesyłają dane używając koncepcji serwisów i charakterystyk.
W jednym czasie peripheral może połączyć się tylko z jednym urządzeniem typu central ( połączenie wiąże się ze zatrzymaniem advertisingu ).
Urządzenie typu central może w jednym czasie połączyć się z wieloma peripheral.
Bluetooth Low Energy Profil GATT - Generic Attribute Profile
![Page 14: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/14.jpg)
Peripheral – GATT Server ( trzyma definicje charakterystyk i serwisów ) Central – GATT Client ( wysyła żądania do serwera ) W Peripheral zapisany jest tz. - Connection Interval
Bluetooth Low Energy Profil GATT – architektura client/server
![Page 15: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/15.jpg)
Bluetooth Low Energy Bluetooth Mesh
![Page 16: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/16.jpg)
Bluetooth Low Energy Bluetooth 5
Dwa typy advertisingu: 1) Cała ramka na kanałach advertisingu 2) Header na kanałach advertisingu a reszta na jednym kanale
![Page 17: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/17.jpg)
Platforma Wsparcie od wersji
Windows 8+ (10+)
OS X 10.7+
iOS 5+
Android 4.3+
Bluetooth Low Energy Wsparcie Bluetooth LE
![Page 18: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/18.jpg)
2. Beacon - Smart Flower Pot
1. Opis urządzenia 2. Opis działania – format Eddystone 3. Implementacja: 3.1 Android Studio – Java 3.2 Delphi ( Android Firemonkey )
![Page 19: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/19.jpg)
Tryb tylko advertising - analogia z latarnią morską.
Wykrywanie odległości za pomocą pomiaru RSSI ( ref 1 m ).
Różne typy Eddystone, iBeacon, altBeacon.
Identyfikator: UUID, Major, Minor (iBeacon)
Beacony
![Page 20: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/20.jpg)
Pomiar wilgotności ziemi w doniczce,
Pomiar temperatury ziemi,
Pomiar temperatury powietrza,
Pomiar nasłonecznienia,
Zasilanie z baterii CR2032 ( 230mAh ),
Czas działania na baterii 2 lata ( pomiar i
wysłanie danych co 10 sekund ),
Mikrokontroler nRF52832
Smart Flower Pot Opis urządzenia
![Page 21: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/21.jpg)
![Page 22: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/22.jpg)
Smart Flower Pot Opis urządzenia
![Page 23: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/23.jpg)
Bluetooth LE beacon profile
UUID – 0xFEAA
4 rodzaje ramek:
Format beacon - Eddystone
Nazwa ramki Opis
UID Wysyła stałe ID – pomiar odległości.
EID Wysyła kodowane, zmienne ID.
URL Wysyła adres URL.
TLM Wysyła dane telemetryczne – temperatura, napięcie
baterii, licznik ramek.
![Page 24: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/24.jpg)
Ramka TLM - oryginalna
Format beacon - Eddystone
Numer bajtu Opis
0 Typ ramki – TLM – 0x20
1 Wersja
2, 3 Napięcie na baterii w mV
4, 5 Temperatura
6, 7, 8, 9 Licznik
10, 11, 12, 13 Czas od włączenia
Ramka TLM – Smart Flower Pot
Numer bajtu Opis
0 Typ ramki – TLM – 0x20
1, 2, 3 Kod – 0xDE2981
4, 5 Temperatura doniczki w oC
6, 7 Temperatura powietrza w oC
8 Nawodnienie w %
9 Nasłonecznienie w %
10 Stan baterii w %
![Page 25: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/25.jpg)
Implementacja
Android Studio Aplikacja wyświetlająca dane z
beacon’ów Smart Flower Pot
Place your screenshot here
![Page 26: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/26.jpg)
Implementacja Android Studio – struktura projektu
Adapter widoku do ListView
„Dane” – „Widok”
Definicja klasy
SmartFlowerPot
Główny plik
Layout elementu ListView
Layout główny
Android manifest
![Page 27: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/27.jpg)
SmartFlowerPot Scaner
Demo Android Studio
![Page 28: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/28.jpg)
Implementacja
Firemonkey Aplikacja wyświetlająca dane z
beacon’ów Smart Flower Pot
Place your screenshot here
![Page 29: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/29.jpg)
Implementacja Firemonkey
Komponent TBeacon
![Page 30: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/30.jpg)
Implementacja Typ generyczny - słownik
Deklarowanie:
SmartFlowerPotDeviceList: TDictionary<String, TSmartFlowerPot>;
procedure TForm1.FormCreate(Sender: TObject);
begin
SmartFlowerPotDeviceList := TDictionary<String, TSmartFlowerPot>.Create;
end;
Inicjalizacja:
Operacje:
SmartFlowerPotDeviceList.ContainsKey(ABeacon.DeviceIdentifier));
SmartFlowerPotDeviceList.AddOrSetValue(ABeacon.DeviceIdentifier, currentBeacon);
SmartFlowerPot := SmartFlowerPotDeviceList.Items[ABeacon.DeviceIdentifier];
![Page 31: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/31.jpg)
Implementacja Klasa TSmartFlowerPot
function TSmartFlowerPot.getTemp( const data :array of
byte ): real;
var
temp: real;
tempWord: word;
begin
tempWord := Word(( ((Word(data[1]) and $FF ) shl 8 ) or
((Word(data[2]) and $FF ) ) ) );
temp := tempWord / 10. ;
result := temp;
end;
![Page 32: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/32.jpg)
Implementacja Desing i projektant ListView
Toolbar
ListView
![Page 33: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/33.jpg)
SmartFlowerPot Scaner
Demo Firemonkey
![Page 34: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/34.jpg)
Dalszy rozwój projektu
Aplikacja działająca w tle + powiadomienia
Wysyłanie wyników do chmury – strona WWW z danymi pomiarowymi z doniczek –
Raspberry Pi 3 jako koncentrator danych.
![Page 35: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/35.jpg)
Beacony Dlaczego Low Power?
Czas potrzebny na wysłanie = 2,2 ms
Prąd potrzebny na wysłanie = 10mA
Czas w uśpieniu = 10 s
Prąd w uśpieniu = 7,9 uA
_____________________________
Średni prąd = 11,6 uA
Bateria CR2032 = 230mAh
Life Time = 0,8*230mAh /0,06 uA
= 2 lata!
Zmierz jak najszybciej
~ 900μs
Wyślij jak najszybciej
~2,2ms
Idź spać ;)
10 s
![Page 36: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/36.jpg)
Beacony w górnictwie
Pomiar temperatury noża podczas urabiania
![Page 37: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/37.jpg)
3. Urządzenie BLE – Led Conroller
1. Opis urządzenia 2. Opis działania 3. Implementacja: 3.1 Android Studio – Java 3.2 Delphi ( Android Firemonkey )
![Page 38: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/38.jpg)
Sterowanie diodami LED typu WS2812,
WS2811, SK6812…
Zasilanie z 5V DC
Mikrokontroler nRF52832
LED Controller Opis urządzenia
![Page 39: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/39.jpg)
Serwis Led Controller
LED Controller Podział na serwisy i charakterystyki
Charakterystyka „control”
Kolor czerwony
Kolor zielony
Kolor niebieski
Kolor biały
Jasność Prędkość
efektu Typ
efektu
Wartości od 0-255
Wartości od 0-15
0x00 – stały kolor
0x01 – stała tęcza
0x02 – ruchoma tęcza
Wartości od 0-255
![Page 40: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/40.jpg)
Implementacja
Android Studio Aplikacja do sterowania listwą LED
SK6812
Place your screenshot here
![Page 41: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/41.jpg)
LED Controller
Demo Android Studio
![Page 42: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/42.jpg)
Implementacja
Firemonkey Aplikacja do sterowania listwą LED
SK6812
Place your screenshot here
![Page 43: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/43.jpg)
Implementacja Klasa TLedController
TLedController = class
strict private
FDevice : TBluetoothLEDevice;
FControl : TControlCharacteristic;
FName: string;
FSignalPercent: integer;
FActive : boolean;
FBonded : boolean;
FInicjalizacja : boolean;
FAutoConnect: boolean;
public
constructor Create(const ADevice: TBluetoothLEDevice);
property device: TBluetoothLEDevice read FDevice write FDevice;
property control: TControlCharacteristic read FControl write FControl;
property name: string read Fname write Fname;
property signalPercent: integer read FsignalPercent write FsignalPercent;
property active : boolean read Factive write Factive;
property bonded : boolean read Fbonded write Fbonded;
property autoConnect : boolean read FAutoConnect write FAutoConnect;
property inicjalizacja: boolean read FInicjalizacja write FInicjalizacja;
procedure updateRssiPercent;
end;
![Page 44: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/44.jpg)
Implementacja Firemonkey
Komponent TBluetoothLE
![Page 45: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/45.jpg)
Implementacja Połączenie z urządzeniem
Rozpoczęcie skanowania:
BluetoothLE1.DiscoverDevices(100);
Lista wyszukanych urządzeń:
procedure TForm1.BluetoothLE1EndDiscoverDevices(const Sender: TObject;
const ADeviceList: TBluetoothLEDeviceList);
Zapis do słownika:
BlueLedConnectedDevice := TLedController.Create( LDevice );
BlueLedActiveDeviceList: TDictionary<String, TLedController>;
Łączenie się z konkretny urządzeniem
BlueLedConnectedDevice.device.Connect;
Odkrywanie serwisów i charakterystyk
BluetoothLE1.DiscoverServices(BlueLedConnectedDevice.device);
![Page 46: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/46.jpg)
Implementacja Zapis charakterystyk
Zapis charakterystyk
function TForm1.bluetoothSendControl: Boolean;
var
dataToSend: TBytes;
begin
SetLength(dataToSend, 13);
dataToSend[0] := $AB;
dataToSend[1] := $CD;
dataToSend[2] := BlueLedConnectedDevice.control.red;
.
.
.
try
CharacteristicControl.SetValue(dataToSend);
BluetoothLE1.WriteCharacteristic(BlueLedConnectedDevice.device,CharacteristicControl);
Result := true;
except
Result := false;
end;
end;
![Page 47: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/47.jpg)
Implementacja Odczyt charakterystyk
Odczyt charakterystyk
procedure TForm1.BluetoothLE1CharacteristicRead(const Sender: TObject;
const ACharacteristic: TBluetoothGattCharacteristic; AGattStatus:TBluetoothGattStatus);
begin
if ACharacteristic.UUID.ToString.Contains(CONTROL_CHAR.ToUpper) then
begin
BlueLedConnectedDevice.control.red := ACharacteristic.GetValueAsUInt8(2);
.
.
.
tbRed.Value := BlueLedConnectedDevice.control.red;
.
.
.
lbiEffectsType.ItemData.Detail :=EffectsTypeName[BlueLedConnectedDevice.control.effectType];
end;
end;
BluetoothLE1.ReadCharacteristic(BlueLedConnectedDevice.device, CharacteristicControl);
![Page 48: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/48.jpg)
Implementacja Trick Tip: Łatwe debugowanie w Androidzie
Android Monitor – z pakietu Android SDK
Przykład:
1) Tools->SDK Manager->SDK base path
2) C:\Users\Public\Documents\Embarcadero\Studio\19.0\CatalogRepository\AndroidSDK-2433_19.0.27659.1188
3) Katalog tools/monitor.bat
Log.d('Nowe dane z ' + ABeacon.DeviceIdentifier);
![Page 49: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/49.jpg)
LED Controller
Demo Firemonkey
![Page 50: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/50.jpg)
Want big impact?
USE BIG IMAGE.
![Page 51: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/51.jpg)
4. Podsumowanie
1. Porównanie Android Studio vs Firemonkey 2. Dlaczego wybrałem Delphi?
![Page 52: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/52.jpg)
Podsumowanie Porównanie
Parametr Android Studio Firemonkey
Rozmiar aplikacji Smart Flower Pot Scaner 1,64 MB 50,28 MB
Rozmiar aplikacji Led Controller 2,09 MB 46,44 MB
Szybkość działania i stabilność działania Taka sama
Możliwości Brak ograniczeń Ograniczone
Czas pomiędzy startem kompilacji a
uruchomieniem aplikacji na SmartPhonie Krótszy Dłuższy
![Page 53: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/53.jpg)
Dlaczego wybrałem Delphi?
Jeden projekt/kod – wiele platform naraz
Delphi jest po prostu fajne
![Page 54: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/54.jpg)
Podsumowanie
github.com/mattpro „M. Gancarczyk”
![Page 55: Technologia Bluetooth Low Energy w Delphidelphi.pl/zlot/zlot2017/prezentacje/Bluetooth_Low_Energy_MG.pdf · Identyfikator: UUID, Major, Minor (iBeacon) Beacony Pomiar wilgotności](https://reader033.fdocuments.net/reader033/viewer/2022042305/5ed090cf6d95d97b48122c75/html5/thumbnails/55.jpg)
Dziękuję za uwagę! Pytania?