-
Notifications
You must be signed in to change notification settings - Fork 0
/
spotify.h
70 lines (60 loc) · 1.71 KB
/
spotify.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
/**
* Contains info for the esp32 spotify remote such as named constants, structs containing app state,
* and declarations of functions relating to spotify api calls
*
* @file spotify.h
* @author Ben Russell
*/
#include <Arduino.h>
#include <ArduinoJson.h>
#include <base64.h>
#include <HTTPClient.h>
#define CLIENT_ID ""
#define CLIENT_SECRET ""
#define WIFI_SSID ""
#define WIFI_PASSWORD ""
#define WIFI_SSID_SIZE 32
#define WIFI_PASSWORD_SIZE 63
enum web_page {
HOME,
ERROR,
DONE
};
// represents each possible action based on serial input
typedef enum {
NONE,
PREVIOUS,
NEXT,
PLAY,
PAUSE,
SHUFFLE,
REPEAT,
REMOTE_LAUNCH,
BACK_BUTTON,
CREDENTIALS,
} Action;
typedef struct{
String wifi_ssid;
String wifi_password;
String client_id;
String client_secret;
String auth_code; // code acquired from login
String access_token; // code included in requests
String refresh_token; // used to generate new access token
String repeat_state; // off or context
String redirect_uri;
String ip_address; // ip address of esp32
int request; // next action to call
bool shuffle_state;
bool remote_launched;
} SpotifyClient;
void spotify_init_client(SpotifyClient *spotify);
int spotify_get_tokens(SpotifyClient *spotify);
int spotify_refresh_tokens(SpotifyClient *spotify);
int spotify_previous(SpotifyClient *spotify, HTTPClient &http);
int spotify_next(SpotifyClient *spotify, HTTPClient &http);
int spotify_play(SpotifyClient *spotify, HTTPClient &http);
int spotify_pause(SpotifyClient *spotify, HTTPClient &http);
int spotify_toggle_shuffle_state(SpotifyClient *spotify, HTTPClient &http);
int spotify_toggle_repeat_state(SpotifyClient *spotify, HTTPClient &http);
int spotify_make_request(SpotifyClient *spotify);