-
Notifications
You must be signed in to change notification settings - Fork 0
/
RF24SensorNet_temp.cpp
53 lines (43 loc) · 1.02 KB
/
RF24SensorNet_temp.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
/*
RF24SensorNet
A library for sending standard sensor and actuator
messages between nodes connected using RF24Network.
Handling for temperature sensors.
--
Peter Hardy <[email protected]>
*/
#ifndef __RF24_SENSOR_NET_TEMP_H__
#define __RF24_SENSOR_NET_TEMP_H__
#if ARDUINO < 100
#include <WProgram.h>
#else
#include <Arduino.h>
#endif
#include "RF24Network.h"
#include "RF24SensorNet.h"
#include "RF24SensorNet_types.h"
void RF24SensorNet::addTempReadHandler(tempReadHandler handler)
{
_tempReadHandler = handler;
}
void RF24SensorNet::addTempRcvHandler(tempRcvHandler handler)
{
_tempRcvHandler = handler;
}
bool RF24SensorNet::readTemp(uint16_t toAddr, uint16_t id)
{
pkt_temp_t payload;
payload.id = id;
payload.temp = 0;
bool ok = _write(toAddr, PKT_TEMP+32, &payload);
return ok;
}
bool RF24SensorNet::sendTemp(uint16_t toAddr, uint16_t id, int16_t temp)
{
pkt_temp_t payload;
payload.id = id;
payload.temp = temp;
bool ok = _write(toAddr, PKT_TEMP, &payload);
return ok;
}
#endif