Conduit Manual Join to SX1276 MBED (Third party device)

Home Forums Conduit: mLinux Model Conduit Manual Join to SX1276 MBED (Third party device)

Tagged: 

Viewing 30 posts - 1 through 30 (of 30 total)
  • Author
    Posts
  • #9960
    Eduardo Garcia
    Participant

    Hello:

    I am using the mLinux Conduit, trying to add a third party device to the network manually (my SX1276 MBED shield module). I have double checked that every key is the same, but I still get a “read(net): Connection Refused” after I try a ‘node add’. Does anyboday have any tips they could give me or point me in the right direction?

    The code I am using on my 3rd party device is an example directly from the manufacturer( ).

    If somebody has also had success with the SX1276 I would appreciate any comments you may have!

    Thanks!,

    -Ed

    #9961
    Eduardo Garcia
    Participant

    I forgot to mention the code I am using on the SX1276 is (https://developer.mbed.org/teams/Semtech/code/LoRaWAN-lmic-app/).

    Here is my mLinux configuration file:

      GNU nano 2.2.5          File: lora-network-server.conf
    
    {
            "db": "/var/config/lora/lora-network-server.db",
            "backupInterval": 21600,    /* DB write interval (seconds) */
            "lora": {
    
                    "netID": "010203",      /* netID for beacon packets */
                    "frequencyBand": "915", /* US="915", EU="868" */
                    "frequencySubBand": 7,  /* Sub-band for US operation, 1-8 */
                    "rx1DatarateOffset": 0, /* Datarate offset for mote rx window 1 s$
                    "rx2Datarate": 12,              /* Datarate for mote rxwindow 2 $
                    "maxTxPower": 14,       /* Max Tx power (dBm), -6 to 26 */
                    "frequencyEU": 867500000 /* center freq for extra EU channels (Hz$
            },
            "udp": {
    
                    "appPortUp": 1784, /* port for user-developed application use */
                    "appPortDown": 1786 /* port for user-developed application use */
    
            },
            "addressRange": {
                    "start": "00:00:00:01", /* address range used for mDots */
                    "end": "FF:FF:FF:FE"
            },
            "network": {
                    "public": true,    /* set to false for private LoRa network with $
                    "leasetime": 1440,  /* time until mDot join expires (minutes) */
                    "name": "LORA", /* configure network security */
                    "passphrase": "LORA"
            },
            "mqtt" : {
                    "enabled": true, /* set to true to publish/subscribe to MQTT serv$
                    "host": "127.0.0.1",
                    "port": 1883
            },
            "log" : {
                    "console" : true,
                    "syslog" : false,
                    "level" : 30, /* error=10, warn=20, info=30, debug=50, trace=60, $
                    "path": "/var/log/lora-network-server.log"
            }
    }
    
    #9964
    Jason Reiss
    Keymaster

    Can you post an example of the node add command you issued?

    Also post the command you use to connect to command port.

    #9965
    Eduardo Garcia
    Participant

    Sure!
    Here was my first try with the original info:
    node add 12345678 0000000000000000 0123456789ABCDEF 2b7e151628aed2a6abf7158809cf4f3c 2b7e151628aed2a6abf7158809cf4f3c

    I also tried the following (changing all data on the SX1276) just to rule out stuff like endiannes:
    node add 33333333 ffffffffffffffff ffffffffffffffff afafafafafafafafafafafafafafafaf afafafafafafafafafafafafafafafaf

    I am not sure about the command to connect to the command port. I did 'nc -u localhost 6677' after connecting to the Conduit by SSH.

    Thank you!

    #9966
    Jason Reiss
    Keymaster

    Command should be
    nc -u localhost 6677

    #9968
    Jason Reiss
    Keymaster

    Check
    # ps -A | grep lora

    Make sure lora-network-server is running.

    #9969
    Jason Reiss
    Keymaster

    Network name and passphrase need to be at least 8 characters.

    #9970
    Eduardo Garcia
    Participant

    Hi Jason:

    Thanks, I have checked your comments. I did write the nc -u localhost 6677 correctly on my code, I mispelled it on this post (sorry). I will change the network name and passphrase (but aren’t they for OTA?). When I do “ps -A | grep lora” nothing is happening! I believe Lora is not running. I did “/etc/init.d/lora-network-server restart” and got the following:

    Stopping lora-network-server: start-stop-daemon: warning: failed to kill 1145: No such process
    OK
    Found lora card MTAC-LORA-915
    Starting lora-network-server: OK
    

    Then I did “ps -A | grep lora” but nothing appears on screen.

    #9972
    Eduardo Garcia
    Participant

    Also:

    # opkg list | grep lora
    lora-network-server - 0.0.8-r0.0
    lora-packet-forwarder - 1.4.1-r8.16
    lora-query - 0.0.1-r0.0
    #9973
    Jason Reiss
    Keymaster

    You can check /var/log/lora-network-server.log.

    It will mention the short name and passphrase.

    Have you modified lmic for 8 channel operation?

    #9974
    Eduardo Garcia
    Participant

    I have changed the network name to be more than 8 characters long, and after restarting I do not get any errors on the log. I am not sure if the lora process is active, “ps -A | grep lora” returns me nothing.

    I think the LMIC has not been modified for 8 channel operation (I am still new to the code), I will check into it.

    “ps -A” returns me the following:

      PID TTY          TIME CMD
        1 ?        00:00:05 init
        2 ?        00:00:00 kthreadd
        3 ?        00:00:00 ksoftirqd/0
        5 ?        00:00:00 kworker/0:0H
        6 ?        00:00:00 kworker/u2:0
        7 ?        00:00:00 khelper
        8 ?        00:00:00 kdevtmpfs
        9 ?        00:00:00 writeback
       10 ?        00:00:00 bioset
       11 ?        00:00:00 crypto
       12 ?        00:00:00 kblockd
       13 ?        00:00:00 khubd
       23 ?        00:00:00 rpciod
       25 ?        00:00:00 khungtaskd
       26 ?        00:00:00 kswapd0
       27 ?        00:00:00 fsnotify_mark
       28 ?        00:00:00 nfsiod
       29 ?        00:00:00 cifsiod
       62 ?        00:00:00 deferwq
       74 ?        00:00:00 jffs2_gcd_mtd6
       87 ?        00:00:00 udevd
      195 ?        00:00:10 jffs2_gcd_mtd8
      222 ?        00:00:00 kworker/u2:2
      336 ?        00:00:00 udevd
      337 ?        00:00:00 udevd
      373 ?        00:00:00 dbus-daemon
      382 ?        00:00:00 sshd
      393 ?        00:00:00 syslogd
      397 ?        00:00:00 klogd
      446 ?        00:00:37 mosquitto
      464 ?        00:00:00 crond
      470 ?        00:00:00 reset-handler
      477 ttyS0    00:00:00 getty
      479 ttyGS0   00:00:00 getty
      686 ?        00:00:00 kworker/0:0
      705 ?        00:00:00 kworker/0:2
      751 ?        00:00:05 sshd
      756 pts/0    00:00:01 sh
     1292 ?        00:00:23 basic_pkt_fwd
     1298 pts/0    00:00:00 ps
    
    #9975
    Jason Reiss
    Keymaster

    What does the log show?

    #9976
    Eduardo Garcia
    Participant

    Sorry Jason, after changing the name I erased the contents of the log, and no other log has been created! The only thing that it said before I deleted it was that it was complaining about the name being too short. Nothing else.

    I have retried everhing again (restart lora server and manual connection) to see if it would write something to the log, but no luck. The weird part is that the log was erased, and now I cannot find the file!

    #9977
    Jason Reiss
    Keymaster

    Try stop and then start instead of restart.

    #9978
    Jason Reiss
    Keymaster

    Did you change passphrase?

    #9981
    Jason Reiss
    Keymaster

    Another thing to do is check that the lora-network-server.conf file is in proper form. You can copy and paste the contents to jsonlint.com to verify it is still in json format. Fix any errors and copy/paste the file back.

    • This reply was modified 8 years, 5 months ago by Jason Reiss.
    #9987
    Eduardo Garcia
    Participant

    Hi Jason:

    Thank again for your ligthning fast responses!

    Contents of Init script:

    
    #!/bin/bash
    
    NAME="lora-network-server"
    ENABLED="yes"
    
    [ -f /etc/default/$NAME ] && source /etc/default/$NAME
    
    run_dir=/var/run/lora
    conf_dir=/var/config/lora
    conf_file=$conf_dir/lora-network-server.conf
    conf_db=$conf_dir/lora-network-server.db
    
    net_server=/opt/lora/lora-network-server
    net_server_log=/var/log/lora-network-server.log
    net_server_pidfile=$run_dir/$NAME.pid
    
    pkt_fwd=/opt/lora/basic_pkt_fwd
    pkt_fwd_log=/var/log/lora-pkt-fwd.log
    pkt_fwd_pidfile=$run_dir/lora-pkt-fwd.pid
    
    lora_us_id="MTAC-LORA-915"
    lora_eu_id="MTAC-LORA-868"
    
    read_card_info() {
        # product-id of first lora card
        lora_id=$(mts-io-sysfs show lora/product-id 2> /dev/null)
        lora_eui=$(mts-io-sysfs show lora/eui 2> /dev/null)
        # remove all colons
        lora_eui_raw=${lora_eui//:/}
    }
    
    card_found() {
        if [ "$lora_id" = "$lora_us_id" ] || [ "$lora_id" = "$lora_eu_id" ]; then
            echo "Found lora card $lora_id"
            return 0
        else
            return 1
        fi
    }
    
    do_start() {
        read_card_info
    
        if ! [ -f $conf_file ]; then
            echo "$0: $conf_file missing"
            exit 1
        fi
    
        if ! card_found; then
            echo "$0: MTAC-LORA not detected"
            exit 1
        fi
    
        echo -n "Starting $NAME: "
        mkdir -p $run_dir
        # start network server
        start-stop-daemon --start --background --make-pidfile \
            --pidfile $net_server_pidfile --exec $net_server -- \
            -c $conf_file --lora-eui $lora_eui --lora-path $run_dir --db $conf_db \
            --noconsole -l $net_server_log
        sleep 1
        # start packet forwarder
        start-stop-daemon --start --background --make-pidfile \
            --pidfile $pkt_fwd_pidfile --exec $pkt_fwd -- \
            -c $run_dir -l $pkt_fwd_log
        echo "OK"
    }
    
    do_stop() {
        echo -n "Stopping $NAME: "
        start-stop-daemon --stop --quiet --oknodo --pidfile $net_server_pidfile --retry 15
        start-stop-daemon --stop --quiet --oknodo --pidfile $pkt_fwd_pidfile --retry 5
        rm -f $net_server_pidfile $pkt_fwd_pidfile
        echo "OK"
    }
    
    if [ "$ENABLED" != "yes" ]; then
        echo "$NAME: disabled in /etc/default"
        exit
    fi
    
    case "$1" in
        "start")
            do_start
            ;;
        "stop")
            do_stop
            ;;
        "restart")
            ## Stop the service and regardless of whether it was
            ## running or not, start it again.
            do_stop
            do_start
            ;;
        *)
            ## If no parameters are given, print which are avaiable.
            echo "Usage: $0 {start|stop|restart}"
            exit 1
            ;;
    esac

    I also tried the JSON lint. It seems it did not like the comments that the file had, so I removed them until I got no errors. Here is the conf file I am using now:

    
    {
        "db": "/var/config/lora/lora-network-server.db",
        "backupInterval": "21600",
        "lora": {
            "netID": "010203",
            "frequencyBand": "915",
            "frequencySubBand": 7,
            "rx1DatarateOffset": 0,
            "rx2Datarate": 12,
            "maxTxPower": 14,
            "frequencyEU": 867500000
        },
        "udp": {
            "appPortUp": 1784,
            "appPortDown": 1786
        },
        "addressRange": {
            "start": "00:00:00:01",
            "end": "FF:FF:FF:FE"
        },
        "network": {
            "public": true,
            "leasetime": 1440,
            "name": "BGLORANETWORK",
            "passphrase": "BGLORANETWORK"
        },
        "mqtt": {
            "enabled": true,
            "host": "127.0.0.1",
            "port": 1883
        },
        "log": {
            "console": true,
            "syslog": false,
            "level": 30,
            "path": "/var/log/lora-network-server.log"
        }
    }
    

    I also tried stopping and starting the proccess as you suggested, but when I try to stop it tells me the following:

    
    root@mtcdt:/var/config/lora# /etc/init.d/lora-network-server stop
    Stopping lora-network-server: start-stop-daemon: warning: failed to kill 1100: No such process
    OK
    root@mtcdt:/var/config/lora# /etc/init.d/lora-network-server start
    Found lora card MTAC-LORA-915
    Starting lora-network-server: OK
    root@mtcdt:/var/config/lora#
    

    I still believe the process may not be starting correctly!
    Thanks!

    #9989
    Eduardo Garcia
    Participant

    Here is the log from my latest server restart:

    9:55:38:888|INFO| -------------------------------------------
    9:55:38:893|INFO| DB loading...
    9:55:38:900|ERROR| SQL error: [no such table: schema] on first call
    9:55:38:900|INFO| Database version: 0
    9:55:38:900|INFO| Latest version:   5
    9:55:38:901|WARNING| Creating database
    9:55:38:969|INFO| Network settings not found in database, setting to current settings
    9:55:39:37|INFO| Beacon is disabled
    
    #9990
    Jason Reiss
    Keymaster

    When I copy and paste from the above post there are some bad quote characters. Are these in the file on the Conduit?

    Here they are replaced with ‘?’ characters:

    {                                                   
        "db": "/var/config/lora/lora-network-server.db",
        "backupInterval": "21600?,                      
        "lora": {                                     
            "netID": "010203?,                        
            "frequencyBand": "915?,                   
            "frequencySubBand": 7,                    
            "rx1DatarateOffset": 0,                   
            "rx2Datarate": 12,                        
            "maxTxPower": 14,                         
            "frequencyEU": 867500000                  
        },                                            
        "udp": {                                      
            "appPortUp": 1784,                        
            "appPortDown": 1786                       
        },                                            
        "addressRange": {                             
            "start": "00:00:00:01?,                   
            "end": "FF:FF:FF:FE"                      
        },                                            
        "network": {                                  
            "public": true,              
            "leasetime": 1440,           
            "name": "BGLORANETWORK",     
            "passphrase": "BGLORANETWORK"
        },                               
        "mqtt": {                                     
            "enabled": true,                          
            "host": "127.0.0.1?,                      
            "port": 1883                              
        },                                            
        "log": {                                      
            "console": true,                          
            "syslog": false,                          
            "level": 30,                              
            "path": "/var/log/lora-network-server.log"
        }                                             
    }
    #9991
    Jason Reiss
    Keymaster

    OK, things are running?

    #9992
    Eduardo Garcia
    Participant

    I am not sure if they are running correctly: no luck connecting. Also, “ps -A | grep lora” does not return anything.

    I changed the quotes you mentioned (I have no idea how they could be other characters!)

    After doing this change and restarting I am getting the same log message as I posted before.

    #9993
    Eduardo Garcia
    Participant

    I am now trying with every code being filled with 0xFF as shown below:

    
    nc -u localhost 6677
    node add 33333333 ffffffffffffffff ffffffffffffffff ffffffffffffffffffffffffffffffff ffffffffffffffffffffffffffffffff
    

    I also made these changes on the SX1276. I still get connection refused.

    #9994
    Jason Reiss
    Keymaster

    I found the issue with the config.
    Backup interval must be a number, not a string.

    “backupInterval”: 21600,

    #9995
    Eduardo Garcia
    Participant

    Thanks Jason, now when I do ps -A | grep lora I get
    “1383 ? 00:00:03 lora-network-se”

    So I think that fixed the issue.
    I tried to add the node and something seemed to happen. Are there any function I could use to check the nodes in the networks, datalog data or anything to check that the node is indeed in the network?

    Thanks again!

    #9996
    Jason Reiss
    Keymaster

    node list

    #9997
    Jason Reiss
    Keymaster

    Also lora-query

    Usage: lora-query [-t timeout] [-s] [-n]
    Simple UDP client utility to pull info from LoRa Network server
    –timeout (t) : UDP recv timeout, default: 100 (msecs)
    –stats (s) : get LoRa Network server statistics
    –stats-reset (r) : reset LoRa Network server statistics
    –node-list (n) : get Node List
    –json (j) : data in json format
    –help (?) : returns this message
    –version (v) : print version

    #9998
    Eduardo Garcia
    Participant

    I tried both commands and they say that the command is not found.

    #9999
    Eduardo Garcia
    Participant

    Sorry, I wrote the second command wrong. Now I type
    “lora-query -t 5000 -s -n”
    and I get

    null
    ^[[ASyntax error in command "node list"
    Word 1
    
    #10000
    Jason Reiss
    Keymaster

    lora-query will be run on the command line. It will open UDP session and issue command and give result. It makes it easier than using the “nc -u localhost 6677”.

    # lora-query -t 5000 -s -n

    #10001
    Eduardo Garcia
    Participant

    Hi Jason:

    Thank you very much for your help! It seems that the node is now connected and I can see it with the lora-query command.

    Thanks again for your fast responses, and for all your help!

Viewing 30 posts - 1 through 30 (of 30 total)
  • You must be logged in to reply to this topic.