-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFourScoreForHomeKit.ino
63 lines (49 loc) · 1.78 KB
/
FourScoreForHomeKit.ino
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
#include <HomeSpan.h>
#include "AccessoryInformation.h"
#include "Player.h"
#include "Button.h"
#include "QueueMaster.h"
#include "Config.h"
QueueMaster* qm;
void setup() {
const int logLevel = LOG_LEVEL;
// variables for wifi and HomeKit:
const char* ssid = WIFI_SSID;
const char* password = WIFI_PASS;
const char* pairingCode = PAIRING_CODE;
// variables for queueMaster:
const int writeGpioPins[2] = ANALOGUE_WRITE_GPIO_PINS;
const int sampleInterval = SAMPLE_INTERVAL;
pinMode(writeGpioPins[0], OUTPUT);
pinMode(writeGpioPins[1], OUTPUT);
// variables for FourScore device
const bool useButtons = USE_BUTTONS;
// start serial communication:
Serial.begin(115200);
// homeSpan.enableAutoStartAP(); // TODO: allow this to be switched in the Config.h if credentials are unknown compile time.
homeSpan.setLogLevel(logLevel);
homeSpan.setWifiCredentials(ssid, password);
homeSpan.setPairingCode(pairingCode);
/*
* we use a bridge containing all features of the FourScore unit to simplify
* management in the HomeApp.
*/
homeSpan.begin(Category::Bridges,"FourScore Key Hanger", "FourScore", "FourScore Key Hanger");
LOG2("Creating QueueMaster"); LOG2("\n");
qm = new QueueMaster(writeGpioPins, sampleInterval);
// NOTE: could use setWifiCallback to wait for connection before creating devices https://github.com/HomeSpan/HomeSpan/blob/master/docs/Reference.md
new SpanAccessory();
new AccessoryInformationNonIdentifiable("FourScore Bridge");
new Service::HAPProtocolInformation();
new Characteristic::Version("1.1.0");
LOG2("Creating players in factory"); LOG2("\n");
playerFactory(qm);
if (useButtons) {
LOG2("Creating buttons in factory"); LOG2("\n");
buttonFactory(qm);
}
}
void loop() {
homeSpan.poll();
qm->loop();
}