<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dinu Chiriac on Medium]]></title>
        <description><![CDATA[Stories by Dinu Chiriac on Medium]]></description>
        <link>https://medium.com/@dinu_88471?source=rss-ae21d3aa988------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*8GTZ4vDjvVeqnRWV_WojWA.jpeg</url>
            <title>Stories by Dinu Chiriac on Medium</title>
            <link>https://medium.com/@dinu_88471?source=rss-ae21d3aa988------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 06:34:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dinu_88471/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Migrating to Kotlin at Chirp.]]></title>
            <link>https://medium.com/chirp-io/migrating-to-kotlin-at-chirp-70bcdb46ee75?source=rss-ae21d3aa988------2</link>
            <guid isPermaLink="false">https://medium.com/p/70bcdb46ee75</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[audio]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Dinu Chiriac]]></dc:creator>
            <pubDate>Fri, 26 Oct 2018 17:16:21 GMT</pubDate>
            <atom:updated>2018-10-26T17:16:21.913Z</atom:updated>
            <content:encoded><![CDATA[<p>At Chirp we love new technologies. As Kotlin is the <a href="https://octoverse.github.com/projects.html">fastest growing language</a> we decided to move forward and start experimenting with Kotlin in our Android SDK. In this article, we are going to show you a couple of examples where Kotlin creates cleaner, more elegant code and makes your life easier as a developer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*OO_xA60RrguiQz0H8WktEw.png" /></figure><p>One of the most critical components of our SDK is our Audio I/O module — it does two things: grab the audio buffer from the microphone and send it to the engine to be processed; and send the processed audio buffer from the engine to the speaker when we are sending data.</p><p>From the first lines of code written in Kotlin, we realised that the code looks tidy and it is much easier to read thanks to lambda expressions.</p><h3>Lambda expressions in Kotlin</h3><p><a href="https://kotlinlang.org/docs/reference/lambdas.html#lambda-expressions-and-anonymous-functions">Lambda expressions</a> in Kotlin are a type of functions that are not declared but passed immediately as an expression. Making an analogy with javascript, a lambda expression is just a callback function passed as an argument. Callbacks are very helpful when you are working with events like “do this when something happens”. For example, a quite common callback in android is OnClickListener for buttons. Here is how you normally have to implement the OnClickListener in Java.</p><pre>/* <strong>Java</strong> */<br>button.setOnClickListener(new OnClickListener() {<br> <a href="http://twitter.com/Override">@Override</a><br> public void onClick(View view) {<br> /* the callback body */ <br> }<br>});</pre><p>This becomes quite frustrating when you have a lot of buttons in your activity and for each one, you have to implement different callbacks. In other words, why repeat yourself?</p><pre>/* <strong>Kotlin</strong> */<br>button.setOnClickListener { /* the callback body */ }</pre><p>Doesn’t this look great? We’ll not go in details about how Kotlin is doing this as there are <a href="https://medium.com/@dbottillo/kotlin-by-examples-methods-and-lambdas-25aef7544365">enough articles</a> about that but in brief, the setOnClickListener method already defines the arguments it accepts, so you don’t need to define it again, just pass a lambda function instead which in the end will be converted to a new OnClickListener during the compilation time.</p><h3>Threads in Kotlin</h3><p>We are not using buttons in our audio library, however, we are using threads quite a lot. The reason for this is that Audio needs to be consistent and every minor delay in processing audio can be critical. Let’s take a look at how Threads can be implemented in Java vs Kotlin.</p><pre>/* <strong>Java</strong> */<br>Thread outAudioThread = new Thread(new Runnable() {<br>    public void run() {<br>        /* Implementation here */<br>        Thread.currentThread().interrupt();<br>    }<br>});<br>outAudioThread.start();</pre><p>And here is how you can create a thread in Kotlin.</p><pre>/* <strong>Kotlin</strong> */<em><br>thread</em>(start = true, priority = <em>THREAD_PRIORITY_URGENT_AUDIO</em>) <strong>{<br>    </strong>/* Implementation here */<br>    Thread.currentThread().interrupt()<br><strong>}</strong></pre><p>Isn’t this better? Sure, and again, as you can see, there is no new <a href="https://docs.oracle.com/javase/7/docs/api/java/lang/Runnable.html">Runnable</a> defined here, Kotlin will do this for you.</p><h3>Instance instantiation in Kotlin</h3><p>Now, going further, as we said, our audio library is used to pass audio buffers between the microphone, speaker and chirp engine. In order to do this in our Java version, we implemented an interface class which instance you have to pass as an argument when the Audio class is instantiated.</p><pre>/* <strong>Java</strong> callback interface*/<br>public interface ChirpAudioBufferCallback {<br>    byte[] processOutput(byte[] buffer);<br>    void processInput(byte[] buffer);<br>}</pre><p>And here is a cut of ChirpAudio class implemented in Java</p><pre>/* ChirpAudio <strong>Java</strong> class*/<br>public class ChirpAudio {<br>    ....<br>    public void startOutAudioLoop() {<br>        Thread outAudioThread = new Thread(new Runnable() {<br>          public void run() {<br>            android.os.Process.setThreadPriority(THREAD_PRIORITY_URGENT_AUDIO);<br>            while (isRunning) {<br>              outBytes = audioBufferCallback.processOutput(outBytes);<br>              audioPlayer.write(outBytes, 0, OUT_BUFFER_SIZE);<br>            }<br>            Thread.currentThread().interrupt();<br>          }<br>        });<br>        outAudioThread.start();<br>    }</pre><pre>    public void setAudioBufferCallback(ChirpAudioBufferCallback     audioBufferCallback) {<br>        this.audioBufferCallback = audioBufferCallback;<br>    }</pre><pre>....<br>}</pre><p>Next, in order to instantiate our ChirpAudio class we have to instantiate ChirpAudioBufferCallback interface first then we’ll be able to set it to ChirpAudio instance with setAudioBufferCallbacksetter.</p><pre>/* Instantiate and use ChirpAudio class in <strong>Java</strong> */<br>ChirpAudioBufferCallback audioBufferCallback = new ChirpAudioBufferCallback() {<br><br>    @Override<br>    public byte[] processOutput(byte[] buffer) {<br>        /* process buffer then return it to be played */<br>        return buffer;<br>    }<br><br>    @Override<br>    public void processInput(byte[] buffer) {<br>        /* process input buffer from the mic */<br>    }<br><br>};<br>ChirpAudio audio = new ChirpAudio();<br>audio.setAudioBufferCallback(audioBufferCallback);</pre><p>How this can be done in Kotlin? First, we don’t really need to create the ChirpAudioBufferCallback Interface for callbacks, we can pass them directly with lambdas. Second, because we removed the callback interface, the instantiation is much cleaner as well.</p><pre>/* ChirpAudio in Kotlin */<br>class ChirpAudio {<br>    ....<br>    fun startOutAudioLoop(outAudioCallback: (buffer: ByteArray?) -&gt; ByteArray?) {<br>    <em>thread</em>(start = true, priority = <em>THREAD_PRIORITY_URGENT_AUDIO</em>) <strong>{<br>        </strong>while (isRunning) {<br>            outBytes = outAudioCallback(outBytes)<br>            if (outBytes !== null) {<br>                audioTrack.write(outBytes, 0, OUT_BUFFER_SIZE)<br>            }<br>        }<br>        Thread.currentThread().interrupt()<br>    <strong>}<br>    </strong>}<br>    ....<br>}</pre><p>And here is how to instantiate the new ChirpAudio class and startAudioLoop</p><pre>/* Instantiate and use ChirpAudio class in Kotlin */<br>val audio = ChirpAudio()<strong><br></strong>audio.startOutAudioLoop <strong>{<br></strong>    /* process buffer then return it to be played */<br>    return@startOutAudioLoop buffer //lambda qualified return<br><strong>}</strong></pre><p>Just this, nothing more, just create the instance and pass the callback function as a lambda and we are done 🎉.</p><p>Overall, the number of lines in our complete ChirpAudio implementation was shrunk from ~270 lines to less than 100 lines of code — almost 3 times less code and clearer syntax.</p><p>This is the first experience with Kotlin we had I can confidently say that this is the feature of mobile development. I’m certain that sooner or later it will replace Java boilerplate and that this is a good thing.</p><p>However, taking in consideration that Kotlin gives you so many features, it can be very easy to write a badly designed code so you must be careful with that.</p><p>Another thing that surprised me is how easy is to write unit tests. Thanks to <a href="https://mockk.io/"><strong>Mockk</strong></a> testing library you don’t have any issues with mocking static methods while <a href="https://spekframework.org/"><strong>Spek</strong></a> framework makes unit tests look beautiful — but this is for another blog post.</p><p>In conclusion, according to<a href="https://insights.stackoverflow.com/survey/2018"> stackoverflow</a>, Kotlin became the second most loved language in 2018 and I bet will become the first most loved language in 2019 and to contribute to this, here is another ❤️ from me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70bcdb46ee75" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chirp-io/migrating-to-kotlin-at-chirp-70bcdb46ee75">Migrating to Kotlin at Chirp.</a> was originally published in <a href="https://medium.com/chirp-io">Chirp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To: Passwordless Wi-Fi sign-in with the Chirp Alexa Toolkit]]></title>
            <link>https://medium.com/chirp-io/how-to-passwordless-wi-fi-sign-in-with-the-chirp-alexa-toolkit-d36c2128749b?source=rss-ae21d3aa988------2</link>
            <guid isPermaLink="false">https://medium.com/p/d36c2128749b</guid>
            <category><![CDATA[iot]]></category>
            <category><![CDATA[alexa]]></category>
            <category><![CDATA[chirp-integrations]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[industrial-iot]]></category>
            <dc:creator><![CDATA[Dinu Chiriac]]></dc:creator>
            <pubDate>Thu, 16 Aug 2018 14:25:18 GMT</pubDate>
            <atom:updated>2018-08-16T14:36:52.759Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In a <a href="https://aws.amazon.com/blogs/startups/send-data-over-voice-using-alexa-with-the-chirp-toolkit/">post for the AWS Startups Blog last year</a>, we described how to build a Chirp-enabled Alexa skill with the Chirp Alexa Toolkit. Since then, we have launched a complete rebuild of the Chirp platform, consisting of improvements to our API, SDKs and websites. During the same time, the Amazon developer interface has been updated with a new skill builder, which obsoletes our earlier post.</p><p>In this article, you’ll learn how to build a Chirp-enabled Alexa skill with our new REST API alongside the new Alexa skill builder. This will allow your Alexa-enabled applications to transmit Chirp signals to communicate with any device within hearing range.</p><p>We’ll then build a complete example which shows how you can share your Wi-Fi credentials from Alexa to a nearby Android device with Chirp, so that nearby devices are able to sign on to your Wi-Fi network with no need to enter passwords.</p><h3>Use Case</h3><p>To implement this demo, we’ll first need to configure Alexa to play an mp3 audio file from the Chirp API, which embeds your Wi-Fi credentials. On the receiving device, we’ll create a simple Android app which will receive, decode credentials from the Chirp signal, and then connect the device to the Wi-Fi network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H8CTbSij3zZ70g9_I6QW1A.png" /><figcaption>Connect to WiFi With Alexa</figcaption></figure><h3>Requirements</h3><p>Before starting, make sure you have these requirements installed on your machine:</p><ul><li>Node and npm if you prefer to use Nodejs for lambda function</li><li>Python 2.7 or higher and pip if you prefer to use Python for lambda function</li><li>Lambda function code samples repository <a href="https://github.com/chirp/chirp-alexa-toolkit">https://github.com/chirp/chirp-alexa-toolkit</a></li><li>Chirp developer account. You can sign up at <a href="https://admin.chirp.io/">admin.chirp.io</a></li><li>Amazon developer account for <a href="https://developer.amazon.com/alexa">Alexa</a> and AWS Lambda</li><li>Android studio to build the demo app on a device</li></ul><h3>Create a new Alexa custom skill</h3><p>Sign in to <a href="https://developer.amazon.com/">https://developer.amazon.com/</a>, and navigate to “Alexa” → “Your Alexa Consoles” → “Skills” to open the Alexa Developer skills page. On the next page, click on the “Create Skill” button to begin creating a new skill.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NxRSZFCVyCWIAB3wo342kw.jpeg" /><figcaption>Creating Alexa skill - step 1</figcaption></figure><p>Here we need to configure our skill name and skill language. In order for your Alexa to understand your skill, you have to select the language that your Alexa was configured with. It is very important that you select “English UK” if you are using UK version of Alexa, and US accordingly if you are using the US Alexa version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XwAG3YCFscTQdUD35YJ5Ug.jpeg" /><figcaption>Creating Alexa skill — Select Title and Language</figcaption></figure><p>Next select a custom skill and click the “Create Skill” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_U6muJpHx7YnDwJ752DqHQ.jpeg" /><figcaption>Creating Alexa skill — Choose a model</figcaption></figure><h3>Configure your newly created skill</h3><p>From the left menu, click on the Invocation button to change the Skill Invocation Name. For our use case, we’ll use “chirp connect” as an invocation name. The invocation name is used by Alexa to start interacting with your skill. It should be two or more words, and can contain only lowercase alphabetic characters, spaces, and possessive apostrophes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RxNfvycTNUk2DU6f9TDxFw.jpeg" /><figcaption>Configure Alexa skill — Choose invocation name</figcaption></figure><p>Next, we need to create an intent that will represent the “connectToWiFi” action. From the left menu click on the “Add Intents” button, enter the intent name, and click on the “Create Custom Intent” button. If your use case is different from ours, you may want to select one of the existing intents from Alexa’s built-in library or create a different custom intent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eyr0rSm-nXE439FRfjvstA.jpeg" /><figcaption>Configure Alexa skill — Create custom intent</figcaption></figure><p>Create intent utterances. Utterances represent the phrases that the user will need to ask Alexa to interact with the skill.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1qxVoAFNg63Ussx072WAFw.jpeg" /><figcaption>Configure Alexa skill — Add intent utterances</figcaption></figure><p>In order to be able to play audio files from Chirp API, we need to enable the AudioPlayer interface. From the left menu, click on Interfaces then click on Audio Player toggle to enable it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*spKNFaFHgVEOjEHShxOr4g.jpeg" /><figcaption>Configure Alexa skill — Enable Audio Player interface</figcaption></figure><p>Now click on the “Save” button to save the configurations, then go to “Endpoints” tab and copy the Alexa skill ID. We’ll need it in the next step to connect it to a Lambda function.</p><p>Next, we need to configure the endpoint that will return a JSON response with instructions for Alexa to play an mp3 file from the Chirp API. For simplicity in this tutorial, we’ll create a Lambda function. However, if you prefer you can set up a dedicated endpoint to serve your responses. Remember that the endpoint needs to be on a secure https connection.</p><h3>Create Lambda function</h3><p>From your Amazon Console, go to the Lambda page and select an appropriate region. At the moment of writing this post, Alexa supports the following regions: US East (N. Virginia) for the NA region, EU (Ireland) for the Europe and India regions, Asia Pacific (Tokyo) for the Far East region. After selecting the region click on the Create Function button to create a new Lambda function.</p><p>On the next page select the “Author from Scratch” option to create a new function from scratch, then enter the function name, runtime and the role. Finally, click the “Create Function” button. Because we don’t need any specific permissions for our lambda function, we can select the “Basic Edge Lambda permissions” built-in role.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0TI2TxiOay4PWYOXwUM4uQ.png" /><figcaption>Creating Lambda function — Choosing name and permissions</figcaption></figure><p>The first thing we need to do after creating our Lambda function is to connect it to our Alexa Skill. From the Designer tab on the Lambda configuration page select API Gateway trigger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0XB1c8FsziiHRIll-i7q3Q.jpeg" /><figcaption>Configure Lambda function — Add Alexa trigger</figcaption></figure><p>Next, scroll down to configure the Alexa Skill Kit trigger and paste the Skill ID that we previously copied from the Alexa Skill configuration page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6e4GmudCOwZGwoyoC7SSzQ.jpeg" /><figcaption>Configure Lambda function — set-up trigger skill id</figcaption></figure><p>Next, we need to clone code samples for the Lambda function from the C<a href="https://github.com/chirp/chirp-alexa-toolkit">hirp Alexa Toolkit GitHub repository</a>.</p><pre><em>git clone </em><a href="/service/mailto:git@github.com"><em>git@github.com</em></a><em>:chirp/chirp-alexa-toolkit.git</em></pre><p>Next, before uploading the function, we need to provide credentials for the Chirp API and your local Wi-Fi network. We are providing samples for node.js and python. In order to update credentials, open the index file for your preferred platform and update the credentials constants in the header of the file.</p><p>For node.js open nodejs/index.js, for python open python/lambda_function.py, and update the following constants:</p><ul><li>APP_KEY and APP_SECRET — represents Chirp credentials from <a href="https://admin.chirp.io/">https://admin.chirp.io</a></li><li>APP_ID — represents your Alexa Skill application id that we copied in previous steps</li><li>WIFI_SSID and WIFI_PASSWORD — represents your WiFi network name and password that you want to connect to. For the sake of this example, we’re assuming the network is secured with WPA2 Personal.</li></ul><p>Next, we need to install dependencies and zip the function with dependencies so Lambda will be able to use the function straight away. We are providing a build script that will zip the sources in a format required by Lambda.</p><pre># For Python run:<br>./build.sh python</pre><pre># For Node.js run:<br>./build.sh nodejs</pre><p>Now we can upload the function to Lambda and test it. In order to do this, go to the Lambda configuration page, scroll to the “Function Code” tab, choose “Upload a .ZIP file” from “Code entry type”, select the zip file created in the previous step and click the Save button to upload the file. Also, make sure that the Runtime and Handler are set up according to your platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ywoqi8xYQHTRyEnYB46yTw.jpeg" /><figcaption>Configure Lambda function — Upload function code</figcaption></figure><p>Almost there! The last thing remaining to do is to connect the Alexa skill to Lambda function and test it. To do this, go back to the Alexa Skill configuration page, open Endpoint tab, select “AWS Lambda ARN” from the “Service Endpoint Type” and paste the Lambda ARN (you can find it on Lambda configuration page, top right corner) in the Default Region field. You may also want to add an endpoint for each region but you’ll need to create Lambda function duplicates for each region. After you are finished with the Lambda ARN configuration, click “Save Interfaces” and “Build Model”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ExlkPzGSC2AWsQp0TvvHng.jpeg" /><figcaption>Configure Alexa skill — Add Lamnda ARN</figcaption></figure><p>After saving and building the skill, you should be able to see your skill in your Alexa app on your mobile device. From the menu go to “Skills and Games” then click on “Your Skills” in the top-right corner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-UKOTtaTbPV95WaEDlBDrg.jpeg" /><figcaption>Check for newly created Alexa skill in your Alexa App</figcaption></figure><p>Now you can go to “Test Console” to test the Lambda function. To interact with your skill you should type your skill invocation name and intent utterances. For our use case, we can type something like “open chirp connect and send wifi credentials”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*FVdesY1p0N1EsFUmdW2kjg.jpeg" /><figcaption>Testing Alexa skill in Alexa Simulator</figcaption></figure><p>Unfortunately, the Alexa Simulator doesn’t yet support the AudioPlayer directive so you’ll not be able to hear the Chirp signal. However, if you are getting an appropriate response from the Lambda function, go ahead and ask Alexa to send you WiFi credentials.</p><h3>Install the Chirp Wi-Fi Android app</h3><p>In the <a href="https://github.com/chirp/chirp-alexa-toolkit">same repository you cloned before</a>, you will find the source code for an accompanying Chirp Wi-Fi Android client app, which uses the <a href="https://developers.chirp.io/docs/getting-started/android">Chirp Android SDK</a> in order to receive credentials sent by Alexa.</p><p>Note that, in this demo, we’re not encrypting credentials so they are sent in plain text (as you can see from the Lambda function). This means that any devices that are in the hearing range will be able to hear and decode the credentials using a Chirp-enabled receiving device. For secure transmission, your credentials could be secured within your app with the addition of cryptography such as RSA or AES, along with a key that is unique to your client’s credentials.</p><p>Before installing the app you have to download Chirp Android SDK from the <a href="https://admin.chirp.io/">admin.chirp.io</a>. After downloading is finished, unzip the package, copy the <em>chirp-connect-release.aar</em> file in to the app/libs folder from the Chirp Wi-Fi Android demo app.</p><p>In order to install the client app, open the project in Android Studio, open “MainActivity.java”, update the Chirp credentials with your key and secret, and build the app on the phone.</p><pre>/*<br>You can download licence string and credentials from your admin panel at admin.chirp.io<br> */<br>String KEY = &quot;YOUR_APP_KEY&quot;;<br>String SECRET = &quot;YOUR_APP_SECRET&quot;;<br>String LICENCE = &quot;YOUR_APP_LICENCE&quot;;</pre><p>Once you start the app for the first time, you’ll see a pop-up window asking to accept “Audio Record” permissions. These are required forthe Chirp SDK in order to listen for the credentials sent by Alexa. Please note that Chirp SDK is actually not recording anything — the audio data from the microphone is processed in real-time and then discarded.</p><p>Once you approve the permissions, click on the “Start Listening” button in order for the Chirp SDK to start listening for data. The status should change from “Idle” to “Listening”, and now you can go ahead and ask Alexa to send Wi-Fi credentials:</p><blockquote>“Alexa, open Chirp Connect and send Wi-Fi credentials.”</blockquote><p>Alexa should start playing a series of tones that encodes your credentials, which will then be decoded by your device. Once the credentials are received, your device will attempt to connect to your Wi-Fi network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AhHpvIMH1WqjLLdEcyKaIQ.jpeg" /><figcaption>Chirp Connect to WiFi Demo app</figcaption></figure><p>Chirp is a technology company enabling a seamless transfer of digital information via sound waves, like an audio QR code, using exclusively a speaker &amp; microphone. The transmission can use audible or inaudible ultrasound tones and takes place with no network connection. To learn more visit <a href="http://chirp.io/">chirp.io</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d36c2128749b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chirp-io/how-to-passwordless-wi-fi-sign-in-with-the-chirp-alexa-toolkit-d36c2128749b">How To: Passwordless Wi-Fi sign-in with the Chirp Alexa Toolkit</a> was originally published in <a href="https://medium.com/chirp-io">Chirp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chirp + Alexa Toolkit]]></title>
            <link>https://medium.com/chirp-io/chirp-alexa-toolkit-aaf84438e8ab?source=rss-ae21d3aa988------2</link>
            <guid isPermaLink="false">https://medium.com/p/aaf84438e8ab</guid>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[alexa]]></category>
            <category><![CDATA[chirp]]></category>
            <category><![CDATA[alexa-toolkit]]></category>
            <dc:creator><![CDATA[Dinu Chiriac]]></dc:creator>
            <pubDate>Tue, 13 Jun 2017 10:18:48 GMT</pubDate>
            <atom:updated>2018-10-10T10:27:55.098Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>An updated version of this how-to is </em></strong><a href="https://blog.chirp.io/how-to-passwordless-wi-fi-sign-in-with-the-chirp-alexa-toolkit-d36c2128749b"><strong><em>here</em></strong></a></p><blockquote>The Chirp Alexa Toolkit is a collection of code snippets, audio API, and guides that make it easy to enable Alexa-enabled devices to send data to other nearby devices using sound.</blockquote><p>Imagine that you could send data over sound using Alexa to any audio-capable, nearby devices that share the same physical space but might not be known on the network, logged-in, authenticated, or otherwise affiliated with the Amazon account of the Alexa owner. For example, you could have Alexa check in a hotel guest by simply “chirping” a code to the guest’s mobile app, or seamlessly providing the guest with Wi-Fi information by having Alexa broadcast Wi-Fi security configuration details, encoded into a sonic barcode.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F220656129&amp;url=https%3A%2F%2Fvimeo.com%2F220656129&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F638920758_1280.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="1280" height="720" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb25cd40c99ed9add3d1d0c3c81d5b10/href">https://medium.com/media/eb25cd40c99ed9add3d1d0c3c81d5b10/href</a></iframe><h3>A few example use cases…</h3><p>This example shows how to enable Alexa to send information to everyone in the room regardless of their authentication state or relationship to the owner’s device or network — the users are simply proximal within the same physical space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RRprFoC32eu_5oseK0lDFw.png" /></figure><p>In the example below the exchange is reversed. Here Alexa can speak to nearby devices and assist with their configuration, their setup or simply send them relevant data for the user’s current demands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R0NL2QggPli9kmccT6tA5Q.png" /></figure><p>We are already looking forward to seeing additional creative ways in which Chirp’s data-over-sound technology can enable new and interesting interactions between devices on the Alexa platform.</p><h3>Creating a Chirp-enabled Alexa Skill</h3><p>The newly released Chirp Alexa Toolkit is a set of three components that is provided to developers to make integration easier.</p><p>In this post we show how to integrate Chirp with Alexa Skills. At the end of this tutorial, you will be able to send a packet of data from Alexa to the Chirp Share iOS or Android app. The data will contain information about the image type, position, and colour.</p><p>We’ll use the following three components:</p><ol><li>Custom Alexa skill, which defines the Alexa configuration and is the basic configuration for Alexa to be able to chirp commands</li><li>Lambda function that defines the logic for the Alexa skill</li><li>Chirp API that serves an mp3 file for Alexa to play</li></ol><p>As shown in the following diagram, a user asks Alexa to chirp. This triggers a Lambda function, which in turn returns a JSON response with the mp3 endpoint URL for Alexa to play. Alexa requests the mp3 file from the Chirp API and plays the chirp.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MvFifAwLOkq__hXd1w0JSA.png" /></figure><p>Before we get started, you need access to the Chirp API. This requires signing up for a developer account on the <a href="https://admin.chirp.io/">Chirp Admin center</a>. After you sign in, download the zip package with code samples from the <a href="https://admin.chirp.io/downloads">Chirp Admin center downloads</a>. We will also use the Chirp Share app as a receiving device for simplicity. You can download the Chirp Share app for Android <a href="https://play.google.com/store/apps/details?id=io.chirp.gemswap">here</a> and for iOS <a href="https://itunes.apple.com/gb/app/chirp-share/id1072110939?mt=8">here</a>.</p><h4>Step 1 — Create and configure a new Alexa custom skill</h4><p>To create a new Amazon Alexa custom skill, go to <a href="https://developer.amazon.com/">https://developer.amazon.com/</a>, choose the <strong>Alexa </strong>tab, and then choose <strong>Get Started</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TZL9D-0FnGzV1_fVUj-dhg.png" /></figure><p>Next, you need to provide some basic skill information. Pay special attention to the <strong>Language </strong>field because it’s important to select the language of the country you are in. Also, don’t forget to enable the Audio Player directive because we are going to play mp3 chirps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7rsG73RKBxJGekUq6FTuig.png" /></figure><p>The next step involves using the interaction model, where we will configure the skill intent schema and the sample utterances. For more information about the intent schema and sample utterances, see <a href="https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interaction-model-reference">Alexa Skills Kit Custom Interaction Model Reference</a>.</p><p>In the Alexa Toolkit zip file that you downloaded from the Chirp Admin Center, you will find a sample JSON document that defines the intent schema. Copy and paste the contents of this document into the intent schema field.</p><p>We are not using Custom Slot Types in our example, so leave it blank.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WDVv3XUZ9jgjwrFr4aMmUQ.png" /></figure><p>The sample utterances represent the phrases that we will use to trigger our custom skill. Provide a few sample utterances, as shown in the following screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MjOPp5HPJiwJuxKvQrv0Ag.png" /></figure><p>Now we need to configure the endpoint that Alexa will trigger when the skill is invoked. In our case, we will create a new Lambda function. For more information about AWS Lambda, see <a href="https://aws.amazon.com/lambda">https://aws.amazon.com/lambda</a>.</p><h4><strong>STEP 2 — Create and configure a new Lambda function</strong></h4><p>Go to the AWS Management Console, choose AWS Lambda, and create a new function. Choose the environment that you prefer. We provide code samples for Python and Node.js.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*92-xQl03GHeZt0XuoUe6Kg.png" /></figure><p>Next, choose Alexa Skills Kit as a trigger.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H2XyH_qXi-6LMVUEnzLkGg.png" /></figure><p>Next, configure the function that will be triggered. In the downloaded zip file, you will find two folders that contain code samples for the Lambda function. Install and include dependencies within the zip folder before you upload it.</p><pre>## Install dependencies for Node.js lambda function</pre><pre>cd nodejs</pre><pre>npm install</pre><pre>## Install dependencies for Python lambda function</pre><pre>cd python</pre><pre>pip install -r requirements.txt -t ./</pre><p>You will also need to update the intent name and Chirp API credentials. To do this, open the index.js or index.py file and update MY_APP_KEY and MY_APP_SECRET with the credentials of your application from the <a href="http://admin.chirp.io/">Chirp</a> Admin Center, and ALEXA_INTENT_NAME with the intent name that you used when you created the Alexa skill.</p><p>The sample code contains a list of identifiers that are predefined icons to work with the Chirp Share demo app. Each of the identifiers represents an icon that has parameters like position, color, and orientation. The script will select a random identifier from the list, and then will create a Play Directive for Alexa to play an mp3 file.</p><p>Now, archive the updated files and upload them to AWS by choosing <strong>Upload a .ZIP file </strong>in the code entry type field on the Lambda function code configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hIDGfCNOw6H8tIAyajNQ0w.png" /></figure><p>Next, configure the function handler and execution method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xvvllYevzaJzXKm8rfw7bA.png" /></figure><h3>STEP 3- Connect an Alexa skill to the Lambda function</h3><p>Copy the ARN from the created function and paste it to the Amazon Alexa Skill configuration tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Vm9sm6qlT6242PdLotWVw.png" /></figure><p>After saving the Alexa configuration, you can test your Lambda function in the Alexa Toolkit Service Simulator. Just type in the utterance you want, and then click on <strong>Ask Chirp</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U4CCsSMVr7KtgDLd-5A9Mg.png" /></figure><p>After you’ve tested it successfully, ask Alexa to chirp using the registered utterance. Open the Chirp Demo app on your device, say “Alexa, chirp using Chirp” and you should receive the played icons on your mobile device.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vPrKjGHUIr9EA4qm." /></figure><h3>Next steps</h3><p>The release of the Chirp Alexa Toolkit is the first step to make it easier for engineers who develop Alexa skills to use Alexa to send data to nearby devices without any prior configuration.</p><p>We are actively listening to feedback from those using the Toolkit about how we can continue to improve for a seamless integration experience. We also very much look forward to hearing which unique opportunities have been taken advantage of by the engineering community through the use of the Chirp Alexa toolkit and the unique capabilities that it delivers.</p><p>Please reach out to <a href="/service/mailto:contact@chirp.io">contact@chirp.io</a> to share your feedback. We look forward to hearing how you get on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sP4VAraTWTzNPYbWrOi4lg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aaf84438e8ab" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chirp-io/chirp-alexa-toolkit-aaf84438e8ab">Chirp + Alexa Toolkit</a> was originally published in <a href="https://medium.com/chirp-io">Chirp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Chirp JavaScriptSDK V2.0]]></title>
            <link>https://medium.com/chirp-io/chirp-javascriptsdk-v2-0-da5d138d725?source=rss-ae21d3aa988------2</link>
            <guid isPermaLink="false">https://medium.com/p/da5d138d725</guid>
            <category><![CDATA[news]]></category>
            <category><![CDATA[es2015]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[promises]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Dinu Chiriac]]></dc:creator>
            <pubDate>Wed, 22 Feb 2017 13:23:27 GMT</pubDate>
            <atom:updated>2017-02-22T13:32:45.260Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*McuGseJWGlscVZSIdH3wYw.jpeg" /><figcaption>ES2015</figcaption></figure><p>We are happy to announce the second major release of the Chirp JavaScript SDK.</p><p>Because JavaScript is evolving rapidly, we are moving forward with it and have developed a new version of the Chirp JS SDK to make developers lives easier. The biggest change is “promises” which will allow you to avoid one of the biggest problems with JavaScript — spaghetti callback code.</p><p>To keep consistency with other Chirp products like<a href="http://developers.chirp.io/docs/chirp-for-android"> Android SDK</a> or<a href="http://developers.chirp.io/docs/chirp-for-ios"> iOS SDK</a>, JavaScript SDK v2.0.0 is now object oriented. There are other lovely improvements, namely:</p><ul><li>We have a few different classes that manage the JavaScript SDK. The first is ChirpSDK() which is the main class used to instantiate the SDK, the second is Chirp() which is used to create chirps.</li><li>Each class has a promise property that you can use to get the creating state.</li><li>Each method of all classes returns a promise as well.</li><li>We implemented a new ChirpError class that you can use to identify errors more clearly.</li></ul><p>To understand the difference, let’s go through a few examples of how the interface has changed since version 1.1.0.</p><h3>Instantiate ChirpSDK</h3><p><strong>Instantiate the SDK and catch the authentication state with old SDK.</strong></p><pre><strong>var </strong>chirpsdk = <strong>new </strong>ChirpSDK(&quot;&lt;%= APP_KEY %&gt;&quot;, <strong>function</strong>(err, res) {<br>  //Catch authentication with callback function.<br>  <strong>if </strong>(err) {<br>    console.error(err);<br>    <strong>return<br>  </strong>}<br>  console.log(res);<br>});</pre><p><strong>Instantiate the SDK and catch the authentication state with new SDK.</strong></p><pre>function<strong> </strong>success(auth_data) {<br>  console.log(&quot;authenticated&quot;);<br>}<br>function<strong> </strong>error(error) {<br>  console.error(&quot;Error: &quot; + error.message);<br>}<br>var<strong> </strong>chirpsdk = new<strong> </strong>ChirpSDK(&quot;&lt;%= APP_KEY %&gt;&quot;);<br>chirpsdk.promise<br>  .then(success)<br>  .catch(error);</pre><h3>Encode an identifier</h3><p><strong>Encode an identifier with old JS SDK.</strong></p><pre>chirpsdk.encode(identifier, function (err, identifierEncoded) {<br>  if (err) {<br>    console.error(err);<br>  }<br>  else {<br>    console.log(identifierEncoded);<br>  }<br>});</pre><p><strong>Encode an identifier with new JS SDK.</strong></p><pre>function error(err) {<br>  console.error(err);<br>}<br>function success(identifierEncoded) {<br>  console.log(chirp.identifierEncoded);<br>}<br>chirp = new Chirp(identifier);<br>chirp.encode()<br>  .then(success)<br>  .catch(error);</pre><h3>Create chirp with associated data</h3><p><strong>Create chirp with associated data with old JS SDK.</strong></p><pre>chirpsdk.create({foo: &#39;bar&#39;}, function (err, chirp) {<br>  if (err) {<br>    console.error(err);<br>  } else {<br>    console.log(chirp);<br>  }<br>});</pre><p><strong>Create chirp with associated data with new JS SDK.</strong></p><pre>var chirp = new Chirp({foo: “bar”});<br>chirp.promise<br>  .then(function() {console.log(“success”)})<br>  .catch(function(err) {console.error(err)});</pre><h3>Create, encode and then getJsonData</h3><p><strong>Create, encode and then getJsonData with old JS SDK.</strong></p><pre>chirpsdk.encode(identifier, function(err, identifierEncoded) {<br>  if (err) {<br>    console.error(err);<br>  } else {<br>    console.log(identifierEncoded);<br>    chirpSdk.get(identifier, function (err, data) {<br>      if (err) {<br>        console.error(err);<br>      }<br>      else {<br>        console.log(data);<br>      }<br>    });  <br>  }<br>});</pre><p><strong>Create, encode and then getJsonData with new JS SDK.</strong></p><pre>chirp = new Chirp(identifier);<br>chirp.promise<br>  .then(chirp.encode.bind(chirp))<br>  .then(chirp.getJsonData.bind(chirp))<br>  .then(function(){<br>    console.log(chirp.identifierEncoded);<br>    console.log(chirp.data);<br>  }).catch(function(error) {<br>    console.error(error);<br>  });</pre><h3>Catch ChirpError</h3><p>The error object returned in catch function is a “ChirpError” type so in case you have a promise chain, you can easily check where the error is coming from:</p><pre>var chirp = new Chirp({foo: “bar”});<br>chirp.promise<br>  .then(doSomething)<br>  .then(doSomethingElse)<br>  .catch(function(error) {<br>    if (error.instanceOf(ChirpError)) {<br>      console.log(“this is a ChirpError”);<br>     }<br>  });</pre><h3>ChirpSDK Class play a chirp.</h3><p><strong>Create and play a chirp with associated data with old JS SDK.</strong></p><pre>chirpsdk.create({foo: &#39;bar&#39;}, <strong>function </strong>(err, chirp) {<br>  <strong>if </strong>(err) {<br>    console.error(err);<br>  } <strong>else </strong>{<br>    chirpsdk.chirp(chirp.identifierEncoded, function(err, res) {<br>      if (err){<br>        console.error(err)<br>      } else {<br>        console.log(&quot;done chirping&quot;);<br>      });<br>  }<br>});</pre><p><strong>Create and play a chirp with associated data with new JS SDK.</strong></p><pre>chirpsdk.chirp(new Chirp({foo: &quot;bar&quot;}))<br>  .then(function() {<br>    console.log(&quot;success&quot;);<br>  }).catch(function(error){<br>    console.error(error);<br>  });</pre><p>Currently JavaScript SDK v2.0.0 is in beta version however you can download it from the <a href="https://admin.chirp.io/">Chirp Admin Centre</a> where you’ll find a demo project and a README file with a full documentaion.</p><h3>Get started</h3><ul><li><a href="http://github.com/chirp/chirp-javascript-sdk">Chirp JavaScript SDK: Source</a> (GitHub)</li><li><a href="https://chirp.github.io/chirp-javascript-sdk/">Chirp JavaScript SDK: Live demo</a></li><li>Sign up for credentials at the <a href="https://admin.chirp.io/">Chirp Admin Centre</a></li></ul><p>To find out more about Chirp’s data-over-sound solutions, please visit us at <a href="http://www.chirp.io/">Chirp.io</a> or get in touch <a href="http://contact@chirp.io/">contact@chirp.io</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da5d138d725" width="1" height="1" alt=""><hr><p><a href="https://medium.com/chirp-io/chirp-javascriptsdk-v2-0-da5d138d725">Chirp JavaScriptSDK V2.0</a> was originally published in <a href="https://medium.com/chirp-io">Chirp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>