@@ -51,7 +51,7 @@ File > Examples > ChirpSDK > Example
5151and 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
6363selecting 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
7171Then 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
113113A 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
153153A 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
164164Or 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
175175To 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
0 commit comments