All Projects → netbeast → react-native-ssdp

netbeast / react-native-ssdp

Licence: other
SSDP client + server to use in your react-native apps

Projects that are alternatives of or similar to react-native-ssdp

Smarthome Tutorial
🎓 Tutorial: smart-home dashboard UI concept.
Stars: ✭ 190 (+387.18%)
Mutual labels:  smart-home
pywavethermo
Basic module to control the Worcester Wave thermostat from Python
Stars: ✭ 26 (-33.33%)
Mutual labels:  smart-home
opencloud-docs
AIOT开放平台官方文档。AIOT Open Cloud documents on official website .
Stars: ✭ 68 (+74.36%)
Mutual labels:  smart-home
Home Assistant Cli
💻 Command-line tool for Home Assistant
Stars: ✭ 243 (+523.08%)
Mutual labels:  smart-home
HomeAssistantMC
Bridge Home Assistant with Minecraft
Stars: ✭ 24 (-38.46%)
Mutual labels:  smart-home
Home-Assistant Config
BeardedTinker Home Assistant configuration. Feel free to browse, edit, tweak, improve, criticize and suggest.
Stars: ✭ 241 (+517.95%)
Mutual labels:  smart-home
Ha client
It was the first Home Assistant fully native Android client from the times when there was no any official alternatives
Stars: ✭ 166 (+325.64%)
Mutual labels:  smart-home
pyvesync
pyvesync is a python library to manage Etekcity & Levoit smart devices
Stars: ✭ 111 (+184.62%)
Mutual labels:  smart-home
Amazon-Alexa-As-LG-TV-Remote
Control your LG WebOS 3.0+ TV with Amazon Alexa
Stars: ✭ 22 (-43.59%)
Mutual labels:  smart-home
node-red-contrib-bosch-shc
Bosch Smart Home Controller (SHC) nodes for Node-Red
Stars: ✭ 15 (-61.54%)
Mutual labels:  smart-home
Tasmota
Alternative firmware for ESP8266 with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
Stars: ✭ 16,624 (+42525.64%)
Mutual labels:  smart-home
home-assistant-config
🏠 My Home Assistant configuration
Stars: ✭ 17 (-56.41%)
Mutual labels:  smart-home
hass-gelight
Home assistant custom component to control C by GE smart light bulb locally via Bluetooth
Stars: ✭ 32 (-17.95%)
Mutual labels:  smart-home
Smart Mirror
The fairest of them all. A DIY voice controlled smart mirror with IoT integration.
Stars: ✭ 2,668 (+6741.03%)
Mutual labels:  smart-home
linux-control
Control your Linux laptop/desktop via Google Assistant
Stars: ✭ 46 (+17.95%)
Mutual labels:  smart-home
Home Assistant Config Fr
🏠Configuration de Home Assistant en français. 👨🏻‍💻 N'hésitez pas à ⭐ mon repo et à copier les bonnes idées ! 🇨🇵
Stars: ✭ 175 (+348.72%)
Mutual labels:  smart-home
tplink-plug-exporter
TP-Link Smart Plug Prometheus Exporter
Stars: ✭ 80 (+105.13%)
Mutual labels:  smart-home
HKHacking
No description or website provided.
Stars: ✭ 29 (-25.64%)
Mutual labels:  smart-home
hue-lights
Gnome Shell extension for Philips Hue compatible lights controlled by the Philips Hue Bridge and for controlling Philips Hue HDMI sync box.
Stars: ✭ 157 (+302.56%)
Mutual labels:  smart-home
Make-Eufy-Smart-Again
Make an web controlled esp8266 remote control for Eufy (v11 or v11+) vacuum cleaners
Stars: ✭ 54 (+38.46%)
Mutual labels:  smart-home

SSDP fork for React Native from node

This is a fork of node-ssdp that uses react-native-udp instead of dgram to enable react multicast messaging and plain socket control. The API is the same as in the forked version.

works with yeti

 This package powers Yeti Smart Home and is used in production. It is maintained with our developers's free time, PRs and issues are more than welcome.

Installation

Unless React Native Version is > 0.29 use rnpm else use react-native link.

npm install react-native-ssdp
rnpm link

Make sure you set Buffer as global in react-native-udp's UdpSockets.js (noted filename end with letter s)

global.Buffer = global.Buffer || require('buffer').Buffer

Things to take note

  • Be aware that the Android emulator does not support incoming UDP traffic, so the client will not get any responses to search requests. For best results, test on a real device when using Android. The iOS simulator, on the other hand, works just fine.

  • Make sure you close all the sockets you open and never try to reopen one already open, mobile OSs and React Native are very aggresive both with security and performance, so a misuse could kill your process.

Usage (Android)

android/settings.gradle

...
include ':react-native-udp'
project(':react-native-udp').projectDir = new File(settingsDir, '../node_modules/react-native-udp/android')
include ':react-native-network-info'
project(':react-native-network-info').projectDir = new File(settingsDir, '../node_modules/react-native-network-info/android')

android/app/build.gradle

...
dependencies {
	...
	compile project(':react-native-udp')
	compile project(':react-native-network-info')
}

register module in MainActivity.java

For RN 0.19.0 and higher

import com.tradle.react.UdpSocketsModule;  // <--- import
import com.pusherman.networkinfo.RNNetworkInfoPackage; // <--- import

public class MainActivity extends ReactActivity {
   // ...
    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
        new MainReactPackage(), // <---- add comma
		new UdpSocketsModule(), // <---- add package
        new RNNetworkInfoPackage() // <---------- add package
      );
    }

For react-native 0.29.0 and higher ( in MainApplication.java )

import com.tradle.react.UdpSocketsModule;  // <--- import
import com.pusherman.networkinfo.RNNetworkInfoPackage; // <--- import

public class MainApplication extends Application implements ReactApplication {
   // ...
    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
        new MainReactPackage(), // <---- add comma
        new UdpSocketsModule(), // <---- add package
		new RNNetworkInfoPackage() <---- add package
      );
    }

Usage (iOS)

Adding with CocoaPads

Add the RNFS pod to your list of applications pods in your podfile, using the path from the Podfile to the installed module.

pod 'RNUDP', :path => './node_modules/react-native-udp'
pod 'RNNetworkInfo', :path => './node_modules/react-native-network-info'

Install pods as usual:

pod install

Adding manually in Xcode

In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name] Go to node_modules ➜ react-native-fs and add the .xcodeproj file

In XCode, in the project navigator, select your project. Add the lib*.a from the RNFS project to your project's Build Phases ➜ Link Binary With Libraries. Click the .xcodeproj file you added before in the project navigator and go the Build Settings tab. Make sure 'All' is toggled on (instead of 'Basic'). Look for Header Search Paths and make sure it contains both $(SRCROOT)/../react-native/React and $(SRCROOT)/../../React - mark both as recursive.

Run your project (Cmd+R)

Note: Library uses these installed native_modules internally for sockets communication.

Usage - Client

    var Client = require('react-native-ssdp').Client
      , client = new Client();

    client.on('response', function (headers, statusCode, rinfo) {
      console.log('Got a response to an m-search.');
    });

    // search for a service type
    client.search('urn:schemas-upnp-org:service:ContentDirectory:1');

    // Or get a list of all services on the network

    client.search('ssdp:all');

Usage - Server

    var Server = require('react-native-ssdp').Server
      , server = new Server()
    ;

    server.addUSN('upnp:rootdevice');
    server.addUSN('urn:schemas-upnp-org:device:MediaServer:1');
    server.addUSN('urn:schemas-upnp-org:service:ContentDirectory:1');
    server.addUSN('urn:schemas-upnp-org:service:ConnectionManager:1');

    server.on('advertise-alive', function (headers) {
      // Expire old devices from your cache.
      // Register advertising device somewhere (as designated in http headers heads)
    });

    server.on('advertise-bye', function (headers) {
      // Remove specified device from cache.
    });

    // start the server
    server.start();

    process.on('exit', function(){
      server.stop() // advertise shutting down and stop listening
    })

Legacy docs from the forked repo

Take a look at example directory as well to see examples or client and server.

##Configuration new SSDP([options, [socket]])

SSDP constructor accepts an optional configuration object and an optional initialized socket. At the moment, the following is supported:

  • ssdpSig String SSDP signature. Default: node.js/NODE_VERSION UPnP/1.1 node-ssdp/PACKAGE_VERSION
  • ssdpIp String SSDP multicast group. Default: 239.255.255.250.
  • ssdpPort Number SSDP port. Default: 1900
  • ssdpTtl Number Multicast TTL. Default: 1
  • adInterval Number advertise event frequency (ms). Default: 10 sec.
  • unicastHost String IP address or hostname of server where SSDP service is running. This is used in HOST header. Default: 0.0.0.0.
  • location String URL pointing to description of your service, or a function which returns that URL
  • udn String Unique Device Name. Default: uuid:f40c2981-7329-40b7-8b04-27f187aecfb5.
  • description String Path to description file. Default: upnp/desc.php.
  • ttl Number Packet TTL. Default: 1800.
  • allowWildcards Boolean Accept wildcards (*) in serviceTypes of M-SEARCH packets, e.g. usn:Belkin:device:**. Default: false

###Logging

You can enable logging via an environment variable DEBUG. Set DEBUG=node-ssdp* to enable all logs. To enable only client or server logs, use DEBUG=node-ssdp:client or DEBUG=node-ssdp:server respectively.

License

(The MIT License)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].