-
Notifications
You must be signed in to change notification settings - Fork 0
/
telegram.h
56 lines (44 loc) · 1.22 KB
/
telegram.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
/**
* @package Wildlife Camera
* Telegram support header
* @author WizLab.it
* @version 20240708.032
*/
#ifndef TELEGRAM_H
#define TELEGRAM_H
/**
* Defines
*/
#define _TELEGRAM_HOSTNAME "api.telegram.org"
#define _TELEGRAM_MULTIPART_BOUNDARY "TelegramMultipartBoundary"
#define _TELEGRAM_WAIT_TIMEOUT 10
#define _TELEGRAM_COMMAND_GETUPDATES 1
#define _TELEGRAM_COMMAND_MESSAGE 2
#define _TELEGRAM_COMMAND_PHOTO 3
#define _TELEGRAM_COMMAND_ACTION 4
/**
* Includes
*/
#include <Arduino.h>
#include <ArduinoJson.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
#include <UrlEncode.h>
#include "extern.h"
/**
* Class definition
*/
class Telegram {
private:
String _apiToken;
int64_t _chatId;
void (*_commandProcessorFunction)(const char*); //Pointer to external command processor function
int8_t _httpRequest(uint8_t command, uint8_t* payload, long payloadLength, char** responseToReturn);
public:
Telegram(String apiToken, int64_t chatId, void (*commandProcessorFunction)(const char*) = NULL);
int8_t getUpdates();
int8_t sendMessage(String message);
int8_t sendPhoto(uint8_t *photo, long photoLength);
int8_t sendAction(String action);
};
#endif