-
Notifications
You must be signed in to change notification settings - Fork 2
/
Sim900.h
62 lines (51 loc) · 1.51 KB
/
Sim900.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//
// Created by Werner Vesterås on 25/04/14.
// Copyright (c) 2014 Werner Vesterås. All rights reserved.
//
#ifndef __Sim900__Sim900__
#define __Sim900__Sim900__
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
class Sim900 {
private:
bool powered;
bool ready;
bool okReceived;
bool errorReceived;
char *parseBuffer;
char *commandBuffer;
char *callerId;
char *lastSMSText;
char *lastSMSFrom;
char *messageToSend;
void process_char(char c);
bool prefix(const char *pre, const char *str);
void process_line(char *line);
char** split(const char *input);
void send(const char *str);
void (*onCallReady)();
void (*onPowerDown)();
void (*onRing)(char *);
void (*onNoCarrier)();
void (*onSMS)(char *, char *);
void (*sendChar)(char);
char (*receiveChar)();
public:
Sim900(void);
virtual ~Sim900();
void setCallReadyHandler(void (*onCRDY)());
void setPowerDownHandler(void (*onPWRDWN)());
void setRingHandler(void (*onRING)(char *));
void setNoCarrierHandler(void (*onNoCarrier)());
void setSMSHandler(void (*onSMS)(char *, char *));
void setSendCharToSerial(void (*sendChar)(char));
void setReceiveCharFromSerial(char (*receiveChar)());
bool call(char *recipient);
bool hangup();
bool answer();
bool sendSMS(char *receiver, char *message);
bool sendATCommand(const char *command);
void parse(char character);
};
#endif /* defined(__Sim900__Sim900__) */