-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathConfiguration.cpp
62 lines (42 loc) · 1.59 KB
/
Configuration.cpp
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
#include "Configuration.h"
#include "EZB.h"
ConfigurationClass::ConfigurationClass(EZB* ezb){
m_ezb = ezb;
}
void ConfigurationClass::BluetoothName_Set(unsigned char* value){
SetConfiguration(ConfigurationClass::BluetoothName, 9, value);
}
unsigned char* ConfigurationClass::BluetoothName_Get(){
return GetConfiguration(ConfigurationClass::BluetoothName, 9);
}
unsigned char ConfigurationClass::GetConfiguration(ConfigurationEnum memoryPosition){
unsigned char args[2];
args[0] = memoryPosition;
args[1] = 1;
unsigned char* retval = m_ezb->SendCommand(EZB::ReadConfiguration, args, 2, 1);
unsigned char val = retval[0];
delete [] retval;
return val;
}
unsigned char* ConfigurationClass::GetConfiguration(StringConfigurationEnum memoryPosition, unsigned char length){
unsigned char args[2];
args[0] = memoryPosition;
args[1] = length;
unsigned char* retval = m_ezb->SendCommand(EZB::ReadConfiguration, args, 2, length);
return retval;
}
void ConfigurationClass::SetConfiguration(ConfigurationEnum memoryPosition, unsigned char value){
unsigned char args[3];
args[0] = memoryPosition;
args[1] = 1;
args[2] = value;
m_ezb->SendCommand(EZB::WriteConfiguration, args, 3);
}
void ConfigurationClass::SetConfiguration(StringConfigurationEnum memoryPosition, unsigned char maxLength, unsigned char* value){
unsigned char* args = (unsigned char*)malloc(sizeof(unsigned char) * (maxLength + 1));
args[0] = memoryPosition;
memset(&args[1], 20, maxLength);
memcpy(&args[1], value, maxLength);
m_ezb->SendCommand(EZB::WriteConfiguration, args, maxLength+1);
free(args);
}