Skip to content

Commit cb1a486

Browse files
joextoddDamien Laidin
authored andcommitted
Rename ChirpConnect to ChirpSDK
1 parent 9225c39 commit cb1a486

File tree

10 files changed

+242
-239
lines changed

10 files changed

+242
-239
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
Recent changes to the [Chirp Arduino SDK](https://developers.chirp.io/docs).
44

5-
## v3.3.1 (beta)
5+
## v3.4.0 (beta)
6+
- Rename ChirpConnect to ChirpSDK
7+
8+
## v3.3.1 (22/08/2019)
69
- Use high frequency oscillator in Nano 33 Sense examples
710

811
## v3.3.0 (09/08/2019)

README.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ File > Examples > ChirpSDK > Example
5151
and you can include the headers to use Chirp in your own code by adding:
5252

5353
```
54-
#include "chirp_connect.h"
54+
#include "chirp_sdk.h"
5555
```
5656

5757
## Usage
@@ -62,37 +62,37 @@ secret and config from the [Developer Hub](https://developers.chirp.io).
6262
*Note* You must select the `16khz-mono-embedded` protocol from the dropdown menu, when
6363
selecting your chirp configuration.
6464

65-
chirp = new_chirp_connect(APP_KEY, APP_SECRET);
65+
chirp = new_chirp_sdk(APP_KEY, APP_SECRET);
6666
if (chirp == NULL) {
6767
Serial.println("Chirp initialisation failed.");
6868
return;
6969
}
7070

7171
Then set any required callbacks and start the SDK running.
7272

73-
chirp_connect_error_code_t err = chirp_connect_set_config(chirp, APP_CONFIG);
74-
if (err != CHIRP_CONNECT_OK)
73+
chirp_sdk_error_code_t err = chirp_sdk_set_config(chirp, APP_CONFIG);
74+
if (err != CHIRP_SDK_OK)
7575
return;
7676

77-
chirp_connect_callback_set_t callbacks = {0};
77+
chirp_sdk_callback_set_t callbacks = {0};
7878
callbacks.on_received = onReceivedCallback;
79-
err = chirp_connect_set_callbacks(chirp, callbacks);
80-
if (err != CHIRP_CONNECT_OK)
79+
err = chirp_sdk_set_callbacks(chirp, callbacks);
80+
if (err != CHIRP_SDK_OK)
8181
return;
8282

83-
err = chirp_connect_set_callback_ptr(chirp, chirp);
84-
if (err != CHIRP_CONNECT_OK)
83+
err = chirp_sdk_set_callback_ptr(chirp, chirp);
84+
if (err != CHIRP_SDK_OK)
8585
return;
8686

87-
err = chirp_connect_set_input_sample_rate(chirp, input_sample_rate);
88-
if (err != CHIRP_CONNECT_OK)
87+
err = chirp_sdk_set_input_sample_rate(chirp, input_sample_rate);
88+
if (err != CHIRP_SDK_OK)
8989
return;
90-
err = chirp_connect_set_output_sample_rate(chirp, output_sample_rate);
91-
if (err != CHIRP_CONNECT_OK)
90+
err = chirp_sdk_set_output_sample_rate(chirp, output_sample_rate);
91+
if (err != CHIRP_SDK_OK)
9292
return;
9393

94-
err = chirp_connect_start(chirp);
95-
if (err != CHIRP_CONNECT_OK)
94+
err = chirp_sdk_start(chirp);
95+
if (err != CHIRP_SDK_OK)
9696
return;
9797

9898
## Callbacks
@@ -102,17 +102,17 @@ The received data is passed back to the `onReceivedCallback` function. If the pa
102102
void
103103
onReceivedCallback(void *chirp, uint8_t *payload, size_t length, uint8_t channel) {
104104
if (payload) {
105-
char *hexString = chirp_connect_as_string(chirp, payload, length);
105+
char *hexString = chirp_sdk_as_string(chirp, payload, length);
106106
Serial.printf("Received data = %s\n", hexString);
107-
chirp_connect_free(hexString);
107+
chirp_sdk_free(hexString);
108108
} else {
109109
Serial.println("Decode failed.");
110110
}
111111
}
112112

113113
A complete list of callbacks is shown below.
114114

115-
void onStateChangedCallback(void *ptr, chirp_connect_state_t old_state, chirp_connect_state_t new_state) {
115+
void onStateChangedCallback(void *ptr, chirp_sdk_state_t old_state, chirp_sdk_state_t new_state) {
116116
// Put here what you want to do when the SDK's state is changing.
117117
}
118118

@@ -133,17 +133,17 @@ A complete list of callbacks is shown below.
133133
}
134134

135135
// If you don't set all the callbacks, make sure the unused callbacks are set to NULL.
136-
chirp_connect_callback_set_t callbacks_set = {
136+
chirp_sdk_callback_set_t callbacks_set = {
137137
.on_state_changed = on_state_changed_callback,
138138
.on_sending = on_sending_callback,
139139
.on_sent = on_sent_callback,
140140
.on_receiving = on_receiving_callback,
141141
.on_received = on_received_callback
142142
};
143-
err = chirp_connect_set_callbacks(chirp, callbacks_set);
144-
if (err != CHIRP_CONNECT_OK)
143+
err = chirp_sdk_set_callbacks(chirp, callbacks_set);
144+
if (err != CHIRP_SDK_OK)
145145
{
146-
const char *error_string = chirp_connect_error_code_to_string(err);
146+
const char *error_string = chirp_sdk_error_code_to_string(err);
147147
printf("%s\n", error_string);
148148
}
149149

@@ -152,31 +152,31 @@ A complete list of callbacks is shown below.
152152

153153
A Chirp payload is simply an array of bytes. You can send a random data payload to the speakers like so.
154154

155-
size_t payload_length = chirp_connect_get_max_payload_length(chirp);
156-
uint8_t *payload = chirp_connect_random_payload(chirp, &payload_length);
155+
size_t payload_length = chirp_sdk_get_max_payload_length(chirp);
156+
uint8_t *payload = chirp_sdk_random_payload(chirp, &payload_length);
157157

158-
err = chirp_connect_send(chirp, payload, payload_length);
159-
if (err != CHIRP_CONNECT_OK) {
160-
const char *error_string = chirp_connect_error_code_to_string(err);
158+
err = chirp_sdk_send(chirp, payload, payload_length);
159+
if (err != CHIRP_SDK_OK) {
160+
const char *error_string = chirp_sdk_error_code_to_string(err);
161161
printf("%s\n", error_string);
162162
}
163163

164164
Or you can easily send an ASCII string
165165

166166
char *identifier = "hello";
167-
err = chirp_connect_send(chirp, (uint8_t *)identifier, strlen(identifier));
168-
if (err != CHIRP_CONNECT_OK) {
169-
const char *error_string = chirp_connect_error_code_to_string(err);
167+
err = chirp_sdk_send(chirp, (uint8_t *)identifier, strlen(identifier));
168+
if (err != CHIRP_SDK_OK) {
169+
const char *error_string = chirp_sdk_error_code_to_string(err);
170170
printf("%s\n", error_string);
171171
}
172172

173173
## Processing
174174

175175
To process audio data from the microphone, and fill the output buffer with audio data, call the following functions with data periodically.
176176

177-
err = chirp_connect_process_input(chirp, input_buffer, input_buffer_length);
177+
err = chirp_sdk_process_input(chirp, input_buffer, input_buffer_length);
178178

179-
err = chirp_connect_process_output(chirp, output_buffer, output_buffer_length);
179+
err = chirp_sdk_process_output(chirp, output_buffer, output_buffer_length);
180180

181181
***
182182

examples/ESP32Receive/ESP32Receive.ino

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
----------------------------------------------------------------------------*/
2222
#include <driver/i2s.h>
2323

24-
#include "chirp_connect.h"
24+
#include "chirp_sdk.h"
2525
#include "credentials.h"
2626

2727
#define I2SI_DATA 12 // I2S DATA IN on GPIO32
@@ -46,14 +46,14 @@
4646

4747
// Global variables ------------------------------------------------------------
4848

49-
static chirp_connect_t *chirp = NULL;
50-
static chirp_connect_state_t currentState = CHIRP_CONNECT_STATE_NOT_CREATED;
49+
static chirp_sdk_t *chirp = NULL;
50+
static chirp_sdk_state_t currentState = CHIRP_SDK_STATE_NOT_CREATED;
5151
static bool startTasks = false;
5252

5353
// Function definitions --------------------------------------------------------
5454

5555
void setupChirp();
56-
void chirpErrorHandler(chirp_connect_error_code_t code);
56+
void chirpErrorHandler(chirp_sdk_error_code_t code);
5757
void setupAudioInput(int sample_rate);
5858

5959
// Function declarations -------------------------------------------------------
@@ -72,7 +72,7 @@ void setup()
7272
void loop()
7373
{
7474
esp_err_t audioError;
75-
chirp_connect_error_code_t chirpError;
75+
chirp_sdk_error_code_t chirpError;
7676

7777
if (startTasks)
7878
{
@@ -87,7 +87,7 @@ void initTask(void *parameter)
8787
{
8888
setupChirp();
8989

90-
chirp_connect_error_code_t chirpError = chirp_connect_set_input_sample_rate(chirp, SAMPLE_RATE);
90+
chirp_sdk_error_code_t chirpError = chirp_sdk_set_input_sample_rate(chirp, SAMPLE_RATE);
9191
chirpErrorHandler(chirpError);
9292
setupAudioInput(SAMPLE_RATE);
9393

@@ -99,13 +99,13 @@ void initTask(void *parameter)
9999
void processInputTask(void *parameter)
100100
{
101101
esp_err_t audioError;
102-
chirp_connect_error_code_t chirpError;
102+
chirp_sdk_error_code_t chirpError;
103103

104104
size_t bytesLength = 0;
105105
float buffer[BUFFER_SIZE] = {0};
106106
int32_t ibuffer[BUFFER_SIZE] = {0};
107107

108-
while (currentState >= CHIRP_CONNECT_STATE_RUNNING)
108+
while (currentState >= CHIRP_SDK_STATE_RUNNING)
109109
{
110110
audioError = i2s_read(I2S_NUM_0, ibuffer, BUFFER_SIZE * 4, &bytesLength, portMAX_DELAY);
111111
if (bytesLength)
@@ -115,7 +115,7 @@ void processInputTask(void *parameter)
115115
buffer[i] = (float) CONVERT_INPUT(ibuffer[i]);
116116
}
117117

118-
chirpError = chirp_connect_process_input(chirp, buffer, bytesLength / 4);
118+
chirpError = chirp_sdk_process_input(chirp, buffer, bytesLength / 4);
119119
chirpErrorHandler(chirpError);
120120
}
121121
}
@@ -124,7 +124,7 @@ void processInputTask(void *parameter)
124124

125125
// Chirp -----------------------------------------------------------------------
126126

127-
void onStateChangedCallback(void *chirp, chirp_connect_state_t previous, chirp_connect_state_t current)
127+
void onStateChangedCallback(void *chirp, chirp_sdk_state_t previous, chirp_sdk_state_t current)
128128
{
129129
currentState = current;
130130
Serial.printf("State changed from %d to %d\n", previous, current);
@@ -154,38 +154,38 @@ void onReceivedCallback(void *chirp, uint8_t *payload, size_t length, uint8_t ch
154154

155155
void setupChirp()
156156
{
157-
chirp = new_chirp_connect(CHIRP_APP_KEY, CHIRP_APP_SECRET);
157+
chirp = new_chirp_sdk(CHIRP_APP_KEY, CHIRP_APP_SECRET);
158158
if (chirp == NULL)
159159
{
160160
Serial.println("Chirp initialisation failed.");
161161
return;
162162
}
163163

164-
chirp_connect_error_code_t err = chirp_connect_set_config(chirp, CHIRP_APP_CONFIG);
164+
chirp_sdk_error_code_t err = chirp_sdk_set_config(chirp, CHIRP_APP_CONFIG);
165165
chirpErrorHandler(err);
166166

167-
chirp_connect_callback_set_t callbacks = {0};
167+
chirp_sdk_callback_set_t callbacks = {0};
168168
callbacks.on_state_changed = onStateChangedCallback;
169169
callbacks.on_receiving = onReceivingCallback;
170170
callbacks.on_received = onReceivedCallback;
171171

172-
err = chirp_connect_set_callbacks(chirp, callbacks);
172+
err = chirp_sdk_set_callbacks(chirp, callbacks);
173173
chirpErrorHandler(err);
174174

175-
err = chirp_connect_set_callback_ptr(chirp, chirp);
175+
err = chirp_sdk_set_callback_ptr(chirp, chirp);
176176
chirpErrorHandler(err);
177177

178-
err = chirp_connect_start(chirp);
178+
err = chirp_sdk_start(chirp);
179179
chirpErrorHandler(err);
180180

181-
Serial.println("Chirp Connect initialised.");
181+
Serial.println("Chirp SDK initialised.");
182182
}
183183

184-
void chirpErrorHandler(chirp_connect_error_code_t code)
184+
void chirpErrorHandler(chirp_sdk_error_code_t code)
185185
{
186-
if (code != CHIRP_CONNECT_OK)
186+
if (code != CHIRP_SDK_OK)
187187
{
188-
const char *error_string = chirp_connect_error_code_to_string(code);
188+
const char *error_string = chirp_sdk_error_code_to_string(code);
189189
Serial.println(error_string);
190190
exit(42);
191191
}

0 commit comments

Comments
 (0)