Mapwize

Last modified by Xiaoling on 2023/04/23 15:31

     Table of Contents:

1.  Introduction

This article shows how to use LBT1 to build an Indoor Positioning Solution.

image-20220526150521-2.png

LBT1 Indoor Positioning Network Structure

2.  Prepare Map

2.1  Prepare iBeacons

Any BLE iBeacons should work in this solution, each iBeacon stands for a fix position in the map. Here is an iBeacon for example.

First of all, user needs to accurately place the beacon at each location, which is the reference for positioning.

image-20220526150651-4.png

BCN01 iBeacon

We need to get the UUID, MAJOR, MINOR, TXPOWER where each iBeacon is placed. We can get it with the iBeacon software, such as "EW-beacon".

image-20220526150743-5.png

beacon software

image-20220526150824-6.png

beacon software

2.2  Create Map

Here we use the indoor map at https://studio.mapwize.io/. Below shows the steps for create a map and put the iBeacon on a fix position.

 

1. Register an account at https://studio.mapwize.io/ to create an indoor map.

2. Create Place Types.

 

image-20220526150915-7.png

Create place types

3. Search Venues. (Indoor map area identification)

image-20220526151046-8.png

The map accurately places the beacon of ibeacon, which is the reference for positioning. At this time, UUID, MAJOR and MINOR must be filled in correctly.

 

4. Upload Floor plan.

image-20220526151223-9.png

add images

5. Create Layer

image-20220526151305-10.png

create layer

6. Add iBeacon position info. Drag the iBeacon to match position and input the UUID, MAJOR and MINOR of this iBeacon.

 

image-20220526151519-11.png

create iBeacon

3.  Configure TTN

3.1  Configure LBT1 to Upload data to TTN

Please refer the instruction in the User Manual. Note the LBT1 need to set to MOD=3 here.

3.2  Decoder in TTN

function Decoder(bytes, port) {

// Decode an uplink message from a buffer

// (array) of bytes to an object of fields.

value = bytes[0] << 8 | bytes[1];

var batV = value/1000;//Battery,units:V

var mode = bytes[5];

//var value=(bytes[3]-0x30)*1000 +(bytes[5]-0x30)*100 + (bytes[5]-0x30)*10 +(bytes[6]-0x30);

//var value = bytes.slice(3);

var i;

var con;

var str = "";

var major = 1;

var minor = 1;

var rssi = 0;

var addr = "";

if(mode ==2 ) {

  for(i = 38 ; i<50 ; i++) {

   con = bytes[i].toString();

   str += String.fromCharCode(con);

  }

  addr = str;

  str = "";

  for(i = 6 ; i<38 ; i++) {

     con = bytes[i].toString();

     str += String.fromCharCode(con);

  }

  value = str;

}

if(mode == 3 ) {

  str = "";

  for(i = 18 ; i < 22 ; i++) {

     con = bytes[i].toString();

     str += String.fromCharCode(con);

  }

  major = parseInt(str, 16);

  str = "";

  for(i = 22 ; i < 26 ; i++) {

     con = bytes[i].toString();

     str += String.fromCharCode(con);

  }

  minor = parseInt(str, 16);

  str = "";

  for(i = 28 ; i < 32 ; i++) {

     con = bytes[i].toString();

     str += String.fromCharCode(con);

  }

  rssi = parseInt(str);

  str = "";

  for(i = 6 ; i < 18 ; i++) {

     con = bytes[i].toString();

     str += String.fromCharCode(con);
  }

  value = str;
}

if(mode == 1) {

  for(i = 6 ; i<11 ; i++) {

     con = bytes[i].toString();

     str += String.fromCharCode(con);

  }

  value = str;
}

var uuid = value;

var alarm = bytes[2] >> 4 & 0x0F;

var step_count = (bytes[2] & 0x0F) << 16 | bytes[3] << 8 | bytes[4];

return {
  UUID: uuid,
  ADDR: addr,
  MAJOR: major,
  MINOR: minor,
  RSSI:rssi,
  STEP: step_count,
  ALARM: alarm,
  BatV:batV,
};
}
 

4.  Set Up Converter Server

  • How to install and run this service on Linux?

Step1:  Rent a Linux on Amazon cloud or alicloud to the host, and pre install the Linux system (Debian, Ubuntu, CentOS are available for distribution).

Step2:  Run the code on the server after compiling. Compilation requires the support of libcurl. First, compile libmqtt in the code, and then compile location.

 

System:  Debian / Ubuntu

step:

1. sudo apt install libcurl4-dev 

2. sudo apt install  gcc automake autoconf libtool make cmake

3. git clone -b master https://github.com/mikayong/location.git

4. cd location/libmqtt

5. mkdir build

6. cd build && cmake ../

7. make && sudo make install 

8. cd ../

9. make 

10. sudo cp location_conf.json  /etc/

11. Edit the configuration file, and run the location service in the background: ./location &

Step3: The location service subscribes to the lora information stream on TTN through the mqtt protocol, parses the information to generate a geographic location, and finally creates a geographic location on the mapwize map. The following is the configuration of the location service, the configuration file is in json format, the file is /etc/location_conf.json

 

5.  Configuration file: location_conf.json

  • We use the 120.78.138.177 server as an example. The location service is currently installed on the 120.78.138.177 server, the code is in /root/location, and the configuration file for running location pre-read directly is /etc/location_conf.json.

     

{ "location_conf": {

   "loctype": "indoor",       // indoor/outdoor
   "locmap": "mapwize"    //   Map interface: mapwize, traccar

}, "mqtt_conf": {

    "servaddr": "[str]",    //     Lorawan server address: Refer to TTN app handler:eu.thethings.network
    "servport": [int],       //   Lorawan server port: 1883
    "clientid": "[str]",       //   MQTT client identity: Custom
    "qos":[int],                 //  (Optional) MQTT service quality: 0
    "username":"[str]",     //   Agent name of mqtt: application ID of TTN
    "password":"[str]",      //  The proxy password of mqtt: application access key of TTN
    "topic":"[str]",              // The topic of mqtt subscription: TTN is + / devices / + / up
   "connection":"[str]" },   //(Optional) mqtt is a string used for direct connection, composed of serveraddr and port
   "mapwize_conf":{          //Map settings
    "apikey": "[str]",        // The apikey of the map user can be found on the Api keys page of wapwize, and read and write permissions need to be set
   "venueid":"[str]",        // (Optional)Indoor map area identification
    "orgid":"[str]",           //  The identity of the user organizer
   "universesid":"[str]",   //The range indicator of the indoor map, find it on the universes page
   "placetype": "[str]"     //The type of place used to identify the creation must be created on the placetypes page in the map, where the placetype name is filled in
    },
"loracloud":{
   "token":  "[str]"          //The password string of loracloud location service, the outdoor map must fill in the account token of loracloud

}

"rssi_conf": {
   "rssirate": [int],          // (Optional) A basis for rssi calculation distance, the rssi value (absolute value) when the beacon is 1 meter apart 
   "rssidiv": [float] }        // (Optional) rssi measures an attenuation value of distance. As the distance to the beacon is farther, the value changes speed

}

 

  • Parameter acquisition method of configuration file:

"username":"[str]" 

image-20220526151707-12.png

username

"password":"[str]"      

image-20220526151736-13.png

password

"apikey": "[str]" 

image-20220526151819-14.png

apikey

"orgid":"[str]"

image-20220526152014-15.png

orgid

"universesid":"[str]"

image-20220526152115-16.png

universesid

"placetype": "[str]"

image-20220526152150-17.png

placetype

Here are two ways to enter the server:

1. WinSCP

image-20220526152303-18.png

image-20220526152355-19.png

image-20220526152912-20.png

way1

2. secureCRT

image-20220526153145-22.png

image-20220526153236-23.png

image-20220526153304-24.png

way2

6.  Test Result

The real-time position on the map is obtained according to the moving change of LBT1.

image-20220526153424-25.png

Tags:
    
Copyright ©2010-2022 Dragino Technology Co., LTD. All rights reserved
Dragino Wiki v2.0