-
Notifications
You must be signed in to change notification settings - Fork 0
/
rz_version.h
84 lines (63 loc) · 2.01 KB
/
rz_version.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
TITLE:
rz_version.h
BRIEF:
header only library
DESC:
Arduino library, compares two semantic version strings
- based on a function developed by Pankaj Choudhary. Unfortunately I've lost the contact and his website. Please contact me
SOURCE:
https://github.com/Zheng-Bote/ESP32_libs
SYNTAX:
#include "rz_version.h"
RZ_Version *versions = new RZ_Version();
int ret = versions->checkVersions("1.0.0", "1.1.0");
RETURN:
int
0: version 1 is equal version 2 (ok)
1: version 1 is greater than version 2 (older version)
2: version 1 is smaller than version 2 (update available)
HISTORY:
Version | Date | Developer | Comments
------- | ---------- | ---------------- | ---------------------------------------------------------------
0.0.0 | xxxx-xx-xx | Pankaj Choudhary | main function developed
1.0.0 | 2022-02-26 | RZheng | lib created
*/
#ifndef rz_version_h
#define rz_version_h
#include "Arduino.h"
class RZ_Version {
public:
RZ_Version();
int checkVersions(std::string v1, std::string v2);
void setUpdateVersion(std::string v2);
std::string getUpdateVersion();
private:
std::string _updateVersion;
~RZ_Version() {
}
};
#endif
/*
##### Example:
//# Source >>>
#include "ESP32/rz_version.h"
// create instance
RZ_Version *versions = new RZ_Version();
// handle return value from checkVersions
void checkVersion(int ret) {
switch (ret) {
case 0: {Serial.println("case 0: current version is up to date"); break;}
case 1: {Serial.println("case 1: current version is greater than Github version. Pls check"); break;}
case 2: {Serial.println("case 2: a new Firmware is available on Github"); break;}
default:
{Serial.println("case default"); break;}
}
}
checkVersion(versions->checkVersions("1.0.0", "0.1.0"));
delay(1000);
checkVersion(versions->checkVersions("1.0.0", "1.0.0"));
delay(1000);
checkVersion(versions->checkVersions("1.0.0", "1.1.0"));
//# <<< Source
*/