-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeviceInfoService.cpp
More file actions
102 lines (78 loc) · 3.19 KB
/
DeviceInfoService.cpp
File metadata and controls
102 lines (78 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* Copyright © 2018-2019 Blue Knobby Systems Inc.
*
* This work is licensed under the Creative Commons Attribution-ShareAlike
* 4.0 International License. To view a copy of this license, visit
* http://creativecommons.org/licenses/by-sa/4.0/ or send a letter to
* Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
*
* Attribution — You must give appropriate credit, provide a link to the
* license, and indicate if changes were made. You may do so in any
* reasonable manner, but not in any way that suggests the licensor
* endorses you or your use.
*
* ShareAlike — If you remix, transform, or build upon the material, you
* must distribute your contributions under the same license as the
* original.
*
* All other rights reserved.
*
*/
#include "DeviceInfoService.h"
DeviceInfoService::DeviceInfoService()
{
}
void
DeviceInfoService::begin(BLEServer *bleServer, Stream *console)
{
this->console = console;
if (bleServer) {
deviceInfoService = bleServer->createService(DEVICEINFO_SERVICE_UUID);
if (deviceInfoService) {
mfgNameCharacteristic = deviceInfoService->createCharacteristic(DEVICEINFO_MFGNAME_CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ);
modelNumberCharacteristic = deviceInfoService->createCharacteristic(DEVICEINFO_MODELNUM_CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ);
serialNumberCharacteristic = deviceInfoService->createCharacteristic(DEVICEINFO_SERIALNUM_CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ);
hwRevisionCharacteristic = deviceInfoService->createCharacteristic(DEVICEINFO_HWREV_CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ);
fwRevisionCharacteristic = deviceInfoService->createCharacteristic(DEVICEINFO_FWREV_CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ);
swRevisionCharacteristic = deviceInfoService->createCharacteristic(DEVICEINFO_SWREV_CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ);
deviceInfoService->start();
}
console->println("deviceInfo service started");
}
}
void
DeviceInfoService::setMfgName(std::string value)
{
mfgNameCharacteristic->setValue(value);
}
void
DeviceInfoService::setModelNumber(std::string value)
{
modelNumberCharacteristic->setValue(value);
}
void
DeviceInfoService::setSerialNumber(std::string value)
{
serialNumberCharacteristic->setValue(value);
}
void
DeviceInfoService::setHWRevision(std::string value)
{
hwRevisionCharacteristic->setValue(value);
}
void
DeviceInfoService::setFWRevision(std::string value)
{
fwRevisionCharacteristic->setValue(value);
}
void
DeviceInfoService::setSWRevision(std::string value)
{
swRevisionCharacteristic->setValue(value);
}