Skip to content

Commit 20f61f8

Browse files
committed
Merge branch 'master' into feature/nano33sense_rx_example
2 parents 4168874 + c4fcd6c commit 20f61f8

File tree

14 files changed

+1054
-415
lines changed

14 files changed

+1054
-415
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

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

5+
## v3.3.0 (beta)
6+
- Added send-only support for cortex-m0plus (MKRZero, MKR Vidor 4000)
7+
- Added support for cortex-m4 (Nano 33 Sense)
8+
- Build v3.3.0-rc1
9+
510
## v3.2.0 (14/03/2019)
611

712
- Build v3.2.9

README.md

+58-33
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
11
# Chirp for Arduino
22

3-
*Version 3.2.5, January 2019*
3+
*Version 3.3.0, August 2019*
44

55
## Overview
66

77
Chirp is a library enabling Arduino-based devices to send and receive data using sound. You'll need:
88

9-
* An ESP32 development board
9+
* A compatible Arduino board
1010
* A digital I2S MEMS microphone
1111
* A digital I2S amplifier and compatible speaker
1212

13-
You'll need an ESP32 (or a board with an equivalent processor). For sound input you will need a digital MEMS microphone such as the SPH0645 or ICS-43434. For sound output it is recommended to use a digital I2S output such as the UDA1334A or MAX98357A connected to a compatible speaker, however analogue output is also possible with this board.
14-
You can quickly test the sound input by playing random chirps from the [Developer Hub](https://developers.chirp.io). The quickest way to test the sound output would be to use Chirp on the [command line](https://developers.chirp.io/docs/tutorials/command-line).
13+
For sound input you will need a digital MEMS microphone such as the SPH0645 or ICS-43434. (Not necessary for the Nano 33 Sense as it comes with an on board microphone)
14+
For sound output it is recommended to use a digital I2S output such as the UDA1334A or MAX98357A connected to a compatible speaker.
15+
16+
You can quickly test the sound input by playing random chirps from the [Developer Hub](https://developers.chirp.io).
17+
The easiest way to test the sound output would be to use Chirp on the [command line](https://developers.chirp.io/docs/tutorials/command-line) to receive data from the Arduino.
18+
19+
## Supported hardware
20+
21+
Send and receive capabilities
22+
23+
* Arduino Nano 33 Sense
24+
* Microsoft MXChip
25+
* ESP32
26+
27+
Send only
28+
29+
* Arduino MKRZero
30+
* Arduino Vidor 4000
31+
* Genuino Zero
32+
* MKR Fox 1200
33+
* MKR1000 WiFi
1534

1635
## Installation
1736

@@ -23,45 +42,50 @@ Install ChirpSDK as a library. For instructions, see
2342

2443
Once installed, you can access the example programs from the menu :
2544

26-
```File > Examples > ChirpSDK > example ```
45+
```File > Examples > ChirpSDK > Example ```
2746

28-
and you can include the headers to use Chirp in your own code by using :
47+
and you can include the headers to use Chirp in your own code by adding :
2948

30-
```Sketch > Import Library > ChirpSDK```
49+
```#include "chirp_connect.h"```
3150

3251
## Usage
3352

34-
To set up the Chirp SDK, initialise and configure with your app key, secret and `arduino` config from the [Developer Hub](https://developers.chirp.io). Then set any required callbacks and start the SDK running.
53+
To set up the Chirp SDK, initialise and configure with your app key,
54+
secret and config from the [Developer Hub](https://developers.chirp.io).
55+
56+
*Note* You must select the `arduino` protocol from the dropdown menu, when
57+
selecting your chirp configuration.
3558

36-
connect = new_chirp_connect(APP_KEY, APP_SECRET);
37-
if (connect == NULL) {
59+
chirp = new_chirp_connect(APP_KEY, APP_SECRET);
60+
if (chirp == NULL) {
3861
Serial.println("Chirp initialisation failed.");
3962
return;
4063
}
4164

42-
chirp_connect_error_code_t err = chirp_connect_set_config(connect, APP_CONFIG);
65+
Then set any required callbacks and start the SDK running.
66+
67+
chirp_connect_error_code_t err = chirp_connect_set_config(chirp, APP_CONFIG);
4368
if (err != CHIRP_CONNECT_OK)
4469
return;
4570

4671
chirp_connect_callback_set_t callbacks = {0};
4772
callbacks.on_received = onReceivedCallback;
48-
err = chirp_connect_set_callbacks(connect, callbacks);
73+
err = chirp_connect_set_callbacks(chirp, callbacks);
4974
if (err != CHIRP_CONNECT_OK)
5075
return;
5176

52-
err = chirp_connect_set_callback_ptr(connect, connect);
77+
err = chirp_connect_set_callback_ptr(chirp, chirp);
5378
if (err != CHIRP_CONNECT_OK)
5479
return;
5580

56-
// Set input/output sample rates if not 44.1kHz
57-
err = chirp_connect_set_input_sample_rate(connect, input_sample_rate);
81+
err = chirp_connect_set_input_sample_rate(chirp, input_sample_rate);
5882
if (err != CHIRP_CONNECT_OK)
5983
return;
60-
err = chirp_connect_set_output_sample_rate(connect, output_sample_rate);
84+
err = chirp_connect_set_output_sample_rate(chirp, output_sample_rate);
6185
if (err != CHIRP_CONNECT_OK)
6286
return;
6387

64-
err = chirp_connect_start(connect);
88+
err = chirp_connect_start(chirp);
6589
if (err != CHIRP_CONNECT_OK)
6690
return;
6791

@@ -70,9 +94,9 @@ To set up the Chirp SDK, initialise and configure with your app key, secret and
7094
The received data is passed back to the `onReceivedCallback` function. If the payload pointer is null then there has been an error decoding the data.
7195

7296
void
73-
onReceivedCallback(void *connect, uint8_t *payload, size_t length, uint8_t channel) {
97+
onReceivedCallback(void *chirp, uint8_t *payload, size_t length, uint8_t channel) {
7498
if (payload) {
75-
char *hexString = chirp_connect_as_string(connect, payload, length);
99+
char *hexString = chirp_connect_as_string(chirp, payload, length);
76100
Serial.printf("Received data = %s\n", hexString);
77101
chirp_connect_free(hexString);
78102
} else {
@@ -110,7 +134,7 @@ A complete list of callbacks is shown below.
110134
.on_receiving = on_receiving_callback,
111135
.on_received = on_received_callback
112136
};
113-
err = chirp_connect_set_callbacks(connect, callbacks_set);
137+
err = chirp_connect_set_callbacks(chirp, callbacks_set);
114138
if (err != CHIRP_CONNECT_OK)
115139
{
116140
const char *error_string = chirp_connect_error_code_to_string(err);
@@ -122,30 +146,31 @@ A complete list of callbacks is shown below.
122146

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

125-
size_t payload_length = chirp_connect_get_max_payload_length(connect);
126-
uint8_t *payload = chirp_connect_random_payload(connect, &payload_length);
149+
size_t payload_length = chirp_connect_get_max_payload_length(chirp);
150+
uint8_t *payload = chirp_connect_random_payload(chirp, &payload_length);
127151

128-
err = chirp_connect_send(chirp_connect, payload, payload_length);
152+
err = chirp_connect_send(chirp, payload, payload_length);
129153
if (err != CHIRP_CONNECT_OK) {
130-
const char *error_string = chirp_connect_error_code_to_string(error_code);
154+
const char *error_string = chirp_connect_error_code_to_string(err);
131155
printf("%s\n", error_string);
132156
}
133157

158+
Or you can easily send an ASCII string
159+
160+
char *identifier = "hello";
161+
err = chirp_connect_send(chirp, (uint8_t *)identifier, strlen(identifier));
162+
if (err != CHIRP_CONNECT_OK) {
163+
const char *error_string = chirp_connect_error_code_to_string(err);
164+
printf("%s\n", error_string);
165+
}
134166

135167
## Processing
136168

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

139-
err = chirp_connect_process_input(chirp_connect, input_buffer, input_buffer_length);
140-
141-
err = chirp_connect_process_output(chirp_connect, output_buffer, output_buffer_length);
142-
143-
144-
## Example
145-
146-
Once ChirpSDK is installed as a library an example is supplied in the IDE menu ```File > Examples > ChirpSDK > Example```.
171+
err = chirp_connect_process_input(chirp, input_buffer, input_buffer_length);
147172

148-
This example script demonstrates how to receive data using the SPH0645 microphone.
173+
err = chirp_connect_process_output(chirp, output_buffer, output_buffer_length);
149174

150175
***
151176

0 commit comments

Comments
 (0)