-
Notifications
You must be signed in to change notification settings - Fork 24
/
EmailShield.cpp
70 lines (56 loc) · 2.1 KB
/
EmailShield.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
Project: 1Sheeld Library
File: EmailShield.cpp
Version: 1.0
Compiler: Arduino avr-gcc 4.3.2
Author: Integreight
Date: 2014.5
*/
#define FROM_ONESHEELD_LIBRARY
#include "OneSheeld.h"
#include "EmailShield.h"
//Email Sender
void EmailShieldClass::send(const char *email ,const char* subject,const char* message)
{
int emailLength = strlen(email);
int subjectLength = strlen(subject);
int messageLength = strlen(message);
if(!emailLength||!subjectLength||!messageLength) return;
OneSheeld.sendShieldFrame(EMAIL_ID,0,EMAIL_SEND,3,new FunctionArg(emailLength,(byte*)email),
new FunctionArg(subjectLength,(byte*)subject),
new FunctionArg(messageLength,(byte*)message));
}
void EmailShieldClass::send(String email, String subject , String message)
{
send(&email[0],&subject[0],&message[0]);
}
//Attaching picture
void EmailShieldClass::attachLastPicture(const char *email ,const char* subject,const char* message , byte imageSource)
{
int emailLength = strlen(email);
int subjectLength = strlen(subject);
int messageLength = strlen(message);
if(!emailLength||!subjectLength||!messageLength) return;
OneSheeld.sendShieldFrame(EMAIL_ID,0,EMAIL_ATTACH_FILE,4,new FunctionArg(emailLength,(byte*)email),
new FunctionArg(subjectLength,(byte*)subject),
new FunctionArg(messageLength,(byte*)message),
new FunctionArg(1,&imageSource));
}
void EmailShieldClass::attachLastPicture(String email, String subject , String message , byte imageSource)
{
attachLastPicture(&email[0],&subject[0],&message[0],imageSource);
}
void EmailShieldClass::attachFile(int fileType)
{
OneSheeld.sendShieldFrame(EMAIL_ID,0,EMAIL_ATTACH_FILE,1,new FunctionArg(2,(byte*)&fileType));
}
void EmailShieldClass::attachFile(const char * filePath)
{
int filePathLength = strlen(filePath);
if(!filePathLength) return;
OneSheeld.sendShieldFrame(EMAIL_ID,0,EMAIL_ATTACH_FILE_PATH,1,new FunctionArg(filePathLength,(byte*)filePath));
}
void EmailShieldClass::attachFile(String filePath)
{
attachFile(&filePath[0]);
}