forked from pebble/ArduinoPebbleSerial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArduinoPebbleSerial.h
48 lines (42 loc) · 1.21 KB
/
ArduinoPebbleSerial.h
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
/*
* This is an Arduino library wrapper around the PebbleSerial library.
*/
#ifndef __ARDUINO_PEBBLE_SERIAL_H__
#define __ARDUINO_PEBBLE_SERIAL_H__
#define USE_HARDWARE_SERIAL 0
#include <Arduino.h>
#include "utility/OneWireSoftSerial.h"
extern "C" {
#include "utility/PebbleSerial.h"
};
typedef enum {
Baud9600,
Baud14400,
Baud19200,
Baud28800,
Baud38400,
Baud57600,
Baud62500,
Baud115200,
Baud125000,
Baud230400,
Baud250000,
Baud460800,
} Baud;
typedef enum {
RequestTypeRead,
RequestTypeWrite,
RequestTypeWriteRead
} RequestType;
class ArduinoPebbleSerial {
public:
static void begin_software(uint8_t pin, uint8_t *buffer, size_t length, Baud baud,
const uint16_t *services, uint8_t num_services);
static void begin_hardware(uint8_t *buffer, size_t length, Baud baud, const uint16_t *services,
uint8_t num_services);
static bool feed(uint16_t *service_id, uint16_t *attribute_id, size_t *length, RequestType *type);
static bool write(bool success, const uint8_t *payload, size_t length);
static void notify(uint16_t service_id, uint16_t attribute_id);
static bool is_connected(void);
};
#endif //__ARDUINO_PEBBLE_SERIAL_H__