UNPKG

lorano

Version:

Compact and opinionated LoRa communications library

487 lines (267 loc) 14.2 kB
<!doctype html> <html lang="en"> <head> <meta charset='utf-8'> <title>lorano 0.0.7 | Documentation</title> <meta name='description' content='Compact and opinionated LoRa communications library'> <meta name='viewport' content='width=device-width,initial-scale=1'> <link href='assets/bass.css' rel='stylesheet'> <link href='assets/style.css' rel='stylesheet'> <link href='assets/github.css' rel='stylesheet'> <link href='assets/split.css' rel='stylesheet'> </head> <body class='documentation m0'> <div class='flex'> <div id='split-left' class='overflow-auto fs0 height-viewport-100'> <div class='py1 px2'> <h3 class='mb0 no-anchor'>lorano</h3> <div class='mb1'><code>0.0.7</code></div> <input placeholder='Filter' id='filter-input' class='col12 block input' spellcheck='false' autocapitalize='off' autocorrect='off' type='text' /> <div id='toc'> <ul class='list-reset h5 py1-ul'> <li><a href='#link' class=" toggle-sibling"> Link <span class='icon'></span> </a> <div class='toggle-target display-none'> <ul class='list-reset py1-ul pl1'> <li class='h5'><span>Instance members</span></li> <li><a href='#linknwk_addr_to_dev_addr' class='regular pre-open'> #nwk_addr_to_dev_addr </a></li> <li><a href='#linkdev_addr_to_nwk_addr' class='regular pre-open'> #dev_addr_to_nwk_addr </a></li> <li><a href='#linkdev_addr_to_deveui' class='regular pre-open'> #dev_addr_to_deveui </a></li> </ul> </div> </li> </ul> </div> <div class='mt1 h6 quiet'> <a href='https://documentation.js.org/reading-documentation.html'>Need help reading this?</a> </div> </div> </div> <div id='split-right' class='relative overflow-auto height-viewport-100'> <section class='p2 mb2 clearfix bg-white minishadow'> <div class='clearfix'> <h3 class='fl m0' id='link'> Link </h3> </div> <p>Creates a Duplex stream (in object mode) which reads and writes to a LoRa radio link.</p> <p>It can perform over-the-air activation of devices it knows about on behalf of your application.</p> <p>Messages received from the radio link are made available to read from the Duplex and have the following properties:</p> <ul> <li><code>nwk_addr (Buffer)</code> - Unique network address of the sending device.</li> <li><code>dev_eui (Buffer)</code> - Unique global device identifier (IEEE EUI64) of the sending device.</li> <li><code>dev_addr (Buffer)</code> - Combined identifier of your network (7 most significant bits) and the unique network address of the sending device (i.e. <code>nwk_addr</code>, 25 least significant bits).</li> <li><code>payload (Buffer)</code> - The data which the sending device sent to your application.</li> <li><code>msg (Object)</code> - The raw packet received by <a href="https://github.com/davedoesdev/packet_forwarder_shared">packet_forwarder_shared</a>. The format is described <a href="https://github.com/davedoesdev/packet_forwarder_shared/blob/master/PROTOCOL.TXT">here</a>.</li> <li><code>packet (Object)</code> - The decoded packet. Anthony Kirby's excellent <a href="https://github.com/anthonykirby/lora-packet">lora-packet</a> is used to do the decoding.</li> <li><code>reply (Object)</code> - This contains nearly everything needed to reply to the message. Your application just has to set the payload. <ul> <li><code>header (Object)</code> - The metadata required by <a href="https://github.com/davedoesdev/packet_forwarder_shared">packet_forwarder_shared</a> to send the reply. See section 6 of <a href="https://github.com/davedoesdev/packet_forwarder_shared/blob/master/PROTOCOL.TXT">here</a>.</li> <li><code>encoding (Object)</code> - The fields required by <a href="https://github.com/anthonykirby/lora-packet#fromfieldsdata">lora-packet</a> to encode the reply.</li> <li><code>payload (undefined)</code> - Your application must set this property to a Buffer containing the data you want to send back to the device.</li> </ul> </li> </ul> <p>If your application wants to reply to the message, set <code>reply.payload</code> to the data that should be sent and then write <code>reply</code> to the Duplex.</p> <div class='pre p1 fill-light mt0'>new Link(Model: class, uplink: <a href="https://nodejs.org/api/stream.html#stream_class_stream_duplex_1">stream.Duplex</a>, downlink: <a href="https://nodejs.org/api/stream.html#stream_class_stream_duplex_1">stream.Duplex</a>, options: <a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</div> <p> Extends <a href="https://nodejs.org/api/stream.html#stream_class_stream_duplex_1">stream.Duplex</a> </p> <div class='py1 quiet mt1 prose-big'>Parameters</div> <div class='prose'> <div class='space-bottom0'> <div> <span class='code bold'>Model</span> <code class='quiet'>(class)</code> The <a href="https://vincit.github.io/objection.js/#models">Objection.js Model class</a> , or a subclass of it, already <a href="https://vincit.github.io/objection.js/#knex">configured for your database using Knex.js</a> . </div> </div> <div class='space-bottom0'> <div> <span class='code bold'>uplink</span> <code class='quiet'>(<a href="https://nodejs.org/api/stream.html#stream_class_stream_duplex_1">stream.Duplex</a>)</code> <a href="https://rawgit-gjgjyaqiln.now.sh/davedoesdev/node-lora-comms/master/docs/index.html#lora-commsuplink">lora-comms uplink stream</a> . Your application must <a href="https://rawgit-gjgjyaqiln.now.sh/davedoesdev/node-lora-comms/master/docs/index.html#lora-commsstart">start</a> the <a href="https://github.com/davedoesdev/node-lora-comms">lora-comms</a> module first and then retrieve the uplink. </div> </div> <div class='space-bottom0'> <div> <span class='code bold'>downlink</span> <code class='quiet'>(<a href="https://nodejs.org/api/stream.html#stream_class_stream_duplex_1">stream.Duplex</a>)</code> <a href="https://rawgit-gjgjyaqiln.now.sh/davedoesdev/node-lora-comms/master/docs/index.html#lora-commsdownlink">lora-comms downlink stream</a> . Your application must <a href="https://rawgit-gjgjyaqiln.now.sh/davedoesdev/node-lora-comms/master/docs/index.html#lora-commsstart">start</a> the <a href="https://github.com/davedoesdev/node-lora-comms">lora-comms</a> module first and then retrieve the downlink. </div> </div> <div class='space-bottom0'> <div> <span class='code bold'>options</span> <code class='quiet'>(<a href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a>)</code> Configuration options. </div> <table class='mt1 mb2 fixed-table h5 col-12'> <colgroup> <col width='30%' /> <col width='70%' /> </colgroup> <thead> <tr class='bold fill-light'> <th>Name</th> <th>Description</th> </tr> </thead> <tbody class='mt1'> <tr> <td class='break-word'><span class='code bold'>options.appid</span> <code class='quiet'><a href="https://nodejs.org/api/buffer.html">Buffer</a></code> </td> <td class='break-word'><span>8-byte identifier of your application in the IEEE EUI64 address space. This is also known as the AppEUI and your OTAA devices must use the same value. </span></td> </tr> <tr> <td class='break-word'><span class='code bold'>options.netid</span> <code class='quiet'><a href="https://nodejs.org/api/buffer.html">Buffer</a></code> </td> <td class='break-word'><span>3-byte identifier of your network. The 7 least significant bits must be unique for neighbouring or overlapping networks. </span></td> </tr> </tbody> </table> </div> </div> <div class='py1 quiet mt1 prose-big'>Instance Members</div> <div class="clearfix"> <div class='border-bottom' id='linknwk_addr_to_dev_addr'> <div class="clearfix small pointer toggle-sibling"> <div class="py1 contain"> <a class='icon pin-right py1 dark-link caret-right'></a> <span class='code strong strong truncate'>nwk_addr_to_dev_addr(nwk_addr)</span> </div> </div> <div class="clearfix display-none toggle-target"> <section class='p2 mb2 clearfix bg-white minishadow'> <p>Combines the unique address of a device with the network identifier configured for this <a href="#link">link</a> (<code>options.netid</code>).</p> <div class='pre p1 fill-light mt0'>nwk_addr_to_dev_addr(nwk_addr: <a href="https://nodejs.org/api/buffer.html">Buffer</a>): <a href="https://nodejs.org/api/buffer.html">Buffer</a></div> <div class='py1 quiet mt1 prose-big'>Parameters</div> <div class='prose'> <div class='space-bottom0'> <div> <span class='code bold'>nwk_addr</span> <code class='quiet'>(<a href="https://nodejs.org/api/buffer.html">Buffer</a>)</code> Device address within the network. </div> </div> </div> <div class='py1 quiet mt1 prose-big'>Returns</div> <code><a href="https://nodejs.org/api/buffer.html">Buffer</a></code>: 25 lsb: <code>nwk_addr</code> ; 7 msb: the 7 lsb of <code>options.netid</code> . </section> </div> </div> <div class='border-bottom' id='linkdev_addr_to_nwk_addr'> <div class="clearfix small pointer toggle-sibling"> <div class="py1 contain"> <a class='icon pin-right py1 dark-link caret-right'></a> <span class='code strong strong truncate'>dev_addr_to_nwk_addr(dev_addr)</span> </div> </div> <div class="clearfix display-none toggle-target"> <section class='p2 mb2 clearfix bg-white minishadow'> <p>Checks if the supplied device address is on the network configured for this <a href="#link">link</a> (<code>options.netid</code>).</p> <div class='pre p1 fill-light mt0'>dev_addr_to_nwk_addr(dev_addr: <a href="https://nodejs.org/api/buffer.html">Buffer</a>): (<a href="https://nodejs.org/api/buffer.html">Buffer</a> | null)</div> <div class='py1 quiet mt1 prose-big'>Parameters</div> <div class='prose'> <div class='space-bottom0'> <div> <span class='code bold'>dev_addr</span> <code class='quiet'>(<a href="https://nodejs.org/api/buffer.html">Buffer</a>)</code> Combined device and network address. </div> </div> </div> <div class='py1 quiet mt1 prose-big'>Returns</div> <code>(<a href="https://nodejs.org/api/buffer.html">Buffer</a> | null)</code>: If the device is on the configured network then the 25 lsb of <code>dev_addr</code> otherwise <code>null</code> . </section> </div> </div> <div class='border-bottom' id='linkdev_addr_to_deveui'> <div class="clearfix small pointer toggle-sibling"> <div class="py1 contain"> <a class='icon pin-right py1 dark-link caret-right'></a> <span class='code strong strong truncate'>dev_addr_to_deveui(dev_addr)</span> </div> </div> <div class="clearfix display-none toggle-target"> <section class='p2 mb2 clearfix bg-white minishadow'> <p>If the supplied device address is on the network configured for this <a href="#link">link</a> (<code>options.netid</code>) then return its unique global device ID (IEEE EUI64).</p> <div class='pre p1 fill-light mt0'>dev_addr_to_deveui(dev_addr: <a href="https://nodejs.org/api/buffer.html">Buffer</a>): (<a href="https://nodejs.org/api/buffer.html">Buffer</a> | null)</div> <div class='py1 quiet mt1 prose-big'>Parameters</div> <div class='prose'> <div class='space-bottom0'> <div> <span class='code bold'>dev_addr</span> <code class='quiet'>(<a href="https://nodejs.org/api/buffer.html">Buffer</a>)</code> Combined device and network address. </div> </div> </div> <div class='py1 quiet mt1 prose-big'>Returns</div> <code>(<a href="https://nodejs.org/api/buffer.html">Buffer</a> | null)</code>: If the device is on the configured network then its IEEE EUI64 ID otherwise <code>null</code> . </section> </div> </div> </div> </section> </div> </div> <script src='assets/anchor.js'></script> <script src='assets/split.js'></script> <script src='assets/site.js'></script> </body> </html>