npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-aws-iot-device-shadows

v1.0.3

Published

React Native Component for connecting to AWS IoT from a device using SDK JavaScript bundle

Downloads

11

Readme

aws-iot-device-sdk-js-react-native

React Native Component wrapper for connecting to AWS IoT from a device using SDK JavaScript bundle

Allows developers to use the AWS IOT shadow support from a React Native component.

Overview

This document provides instructions on how to install and configure the AWS IoT device/Shadow in React Native.

AWS SDK Dependency

This package is built on top of the AWS SDK aws-sdk.js which provides two classes: 'device' and 'thingShadow'.

Thing Shadows

The 'thingShadow' class implements additional functionality for accessing Thing Shadows via the AWS IoT API; the thingShadow class allows devices to update, be notified of changes to, get the current state of, or delete Thing Shadows from AWS IoT. Thing Shadows allow applications and devices to synchronize their state on the AWS IoT platform.

Device

The 'device' class wraps mqtt.js to provide a secure connection to the AWS IoT platform and expose the mqtt.js interfaces upward. It provides features to simplify handling of intermittent connections, including progressive backoff retries, automatic re-subscription upon connection, and queued offline publishing with configurable drain rate.

Installation

Installing with npm:

npm install react-native-aws-iot-device-shadows

Examples

MQTT React Native IoT Shadow Class

<AWSIoTMQTT
    ref={(ref) => { this.AWSIoTMQTT = ref; }}
    type="shadow"
    region="us-west-2"
    host="asdasd.iot.aws.com"
    onReconnect={() => this.onConnect()}
    onConnect={() => this.onConnect()}
    onDelta={(thingId, stateObject) => this.onDelta(thingId, stateObject)}
    onStatus={(thingId, statusType, clientToken, stateObject) =>
        this.onStatus(thingId, statusType, clientToken, stateObject)}
    onThingConnected={(thingId) => { this.onThingConnected(thingId); }}
/>

MQTT React Native IoT device Class

<AWSIoTMQTT
    ref={(ref) => { this.AWSIoTMQTT = ref; }}
    type="device"
    region="us-west-2"
    host="asdasd.iot.aws.com"
    onReconnect={() => this.onConnect()}
    onConnect={() => this.onConnect()} 
/>

AWSIoTMQTT

Returns a React Native component whichs wraps xxxxxxxx

## API Documentation

  • type: use 'device' for device type and 'shadows' for ShadowThing
  • host: the AWS IoT endpoint you will use to connect
  • region: the AWS IoT region you will use to connect
  • config: extra configuration for the thingShadow
  • onConnect: callback for when the websockets connects
  • onReconnect: callback for when the websockets reconnects
  • onDelta: callback for delta msg
  • onStatus: callback for status msg
  • onThingConnected: callback for each registered thing

Connection Types

This react native component only supports one type of connections to the AWS IoT platform:

  • MQTT over WebSocket/TLS with SigV4 authentication using port 443

Debug

The enable debug mode for display logging information just pass a object with debug:true

<AWSIoTMQTT
    config={debug:true}
    ...
/>

Re-Creating the bundle with webpack

This IOT JS SDK is packaged withwebpack, because currently there is not official support for AWS IOT react native. This is already bundle it for you using the last version.

npm run build

Unit Tests

This package includes unit tests which can be run as follows:

npm test

Running the unit tests will also generate code coverage data in the 'reports' directory.

License

This react native component is distributed under the Apache License, Version 2.0, see LICENSE.txt and NOTICE.txt for more information.

Support

feel free to open any ticket in github issues