GithubClient.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <Arduino.h>
  2. #include <WiFiClientSecure.h>
  3. #ifndef _GITHUB_CLIENT
  4. #define _GITHUB_CLIENT
  5. #define GITHUB_CLIENT_BUFFER_SIZE 32
  6. #define GITHUB_RAW_FINGERPRINT "21 99 13 84 63 72 17 13 B9 ED 0E 8F 00 A5 9B 73 0D D0 56 58"
  7. #define GITHUB_RAW_DOMAIN "raw.githubusercontent.com"
  8. #define GITHUB_API_FINGERPRINT "35 85 74 EF 67 35 A7 CE 40 69 50 F3 C0 F6 80 CF 80 3B 2E 19"
  9. #define GITHUB_API_DOMAIN "api.github.com"
  10. class GithubClient {
  11. public:
  12. GithubClient(const char* domain, const char* sslFingerprint)
  13. : domain(String(domain)),
  14. sslFingerprint(String(sslFingerprint))
  15. { }
  16. Stream& stream(const String& path);
  17. bool download(const String& path, Stream& dest);
  18. bool download(const String& path, const String& fsPath);
  19. static GithubClient rawDownloader();
  20. static GithubClient apiClient();
  21. static String buildRepoPath(const String& username, const String& repo, const String& path);
  22. uint8_t buffer[GITHUB_CLIENT_BUFFER_SIZE];
  23. private:
  24. WiFiClientSecure client;
  25. const String domain;
  26. const String sslFingerprint;
  27. };
  28. #endif