Code Monkey home page Code Monkey logo

cmx-indoor-location's Introduction

cmx-socket-indoor-location-emitter

Node.js server to provide indoorLocation from Cisco CMX. Works with socketIndoorLocationProvider libraries on iOS, Android and JS.

Installation

Node.js is required.

  • Clone the repository
  • Go to this folder, and install the modules
    npm i
    

configurator

A configurator tool is provided to create the config file necessary to run the CMX Listener. The config file contains the necessary information to project the coordinates received from CMX onto the Mapwize map.

Here are the steps to follow:

  • Get the maps configuration from CMX by calling the API endpoint /api/config/v1/maps on your CMX instance. Save the output in a json file.
  • Get the images used in CMX to configure the different floors.
  • Add all the CMX images as layers in your Mapwize venue. The images should perfectly overlay the Mapwize map for high accuracy. Name each layer in Mapwize with the same name given to the corresponding floor in CMX.
  • Call the configurator providing the path to the CMX config file, your Mapwize API key, the Mapwize venueId and where to store the output. Please ensure that your Mapwize API Key has read access to your venue.
./configurator/configureFromMapwize.js -k [YOUR MAPWIZE API KEY] -v [MAPWIZE VENUE ID] -c [PATH TO CMX CONFIG FILE] -o [PATH TO OUTPUT]

cmx-listener

NodeJS server to react on CMX notifications. Each notification will be received and processed into an indorLocation object.

The computed indoorLocation will be saved in a redis database with the IP address as userId to be used by the emitter.

If enabled, the CMX notification can also be logged into an Azure Cosmos DB instance, mapped to a MongoDB collection, and/or into an Azure EventHub.

Thanks to redis, we will be notified each time a key value has been changed.

To do so, redis notifications have to be enabled with the command described below.

redis-cli config set notify-keyspace-events K$

Use

  • We first need to correctly set the configuration parameters
    • Directly in the config/all.js file
    • Via environment variables
      • PORT: port used by the server (default: 3004)
      • KEY: key used to authenticate the POST query
      • FLOORS_CONFIGURATION: serialized CMX JSON configuration (required)
      • MAC_ADDRESS_ENABLED: use the MAC address in addition to the IP address as a key in Redis (default: false)
      • REDIS_HOST: redis host (required) (default: localhost)
      • REDIS_PORT: redis port (default: 6379)
      • REDIS_AUTH: redis password (if set)
      • REDIS_CMX_NOTIF_TTL: redis key TTL (default: 3600)
      • MONGODB_ENABLED: enable notifications logging into MongoDB (default: false)
      • MONGODB_URL: MongoDB URL (default: localhost)
      • MONGODB_COLLECTION: MongoDB collection to use (default: logs)
      • AZURE_EVENT_HUB_ENABLED: enable notifications logging into an Azure EventHub (default: false)
      • AZURE_EVENT_HUB_SERVICE_BUS_URI: AZ EventHub URI (e.g. myservice.servicebus.windows.net)
      • AZURE_EVENT_HUB_PATH: AZ EventHub path (e.g. myeventhub)
      • AZURE_EVENT_HUB_SA_NAME: AZ EventHub SharedAccessKeyName
      • AZURE_EVENT_HUB_SA_KEY: AZ EventHub SharedAccessKey
  • Start the server
    npm run start-listener
    

Notes

To correctly serialize the CMX configuration, one can execute the command described below:

export FLOORS_CONFIGURATION=$(node -e 'var json = require("FILEPATH"); console.log(JSON.stringify(json));')

If you want to put this variable into your clipboard instead, please execute the command below:

node -e 'var json = require("FILEPATH"); console.log(JSON.stringify(json));' | pbcopy

An example of a valid JSON CMX configuration can be found at cmx-listener/test/floors-configuration.json.

CMX Notification configuration

In your CMX dashboard, go to Manage/Notifications. Create a notification with the following parameters:

  • type = "location update" or "movement". If you select movement, set a distance like 3 or 5 feet.
  • receiver
    • protocol = http or https depending on your deployment
    • host = the host where the cmxlistener is deployed
    • port = 80 or 443 to match http or https
    • url = "?k={KEY}" where {KEY} is your KEY environment variable

You can use https://cmxlocationsandbox.cisco.com, with learning/learning as credentials, to test your service.

cmx-emitter

NodeJS server to react on socket indoor location providers. Each socket connection will lead to a redis subscription that will help to only get the indoorLocation objects when the location of a user has been changed. These objects will be sent to the providers via a socket channel.

Use

  • We first need to correctly set the configuration parameters
    • Directly in the config/all.js file
    • Via environment variables
      • PORT: port used by the server (default: 3003)
      • SESSIONS_REDIS_HOST: redis host (required) (default: localhost)
      • SESSIONS_REDIS_PORT: redis port (default: 6379)
      • SESSIONS_REDIS_AUTH: redis password (if set)
  • Start the server
    npm run start-emitter
    

cmx-indoor-location's People

Contributors

mathieugerard avatar mcolmant avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.