Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update readme.md with fuota server details. #640

Closed
branek opened this issue Jan 11, 2019 · 2 comments
Closed

Update readme.md with fuota server details. #640

branek opened this issue Jan 11, 2019 · 2 comments

Comments

@branek
Copy link
Contributor

branek commented Jan 11, 2019

As fuota example is more or less working now, some details in readme.md about network/app server setup and configuration for test/poc would be great.

@mluis1
Copy link
Contributor

mluis1 commented Jan 14, 2019

The fuota-test-01example is primarily meant for the network server providers to test their implementation of the LoRa-Alliance, 3 newly defined application packages.

As for the moment this isn't yet fully finalized I followed the instructions provided on the below project in order to be able to start testing the current implementation on this project.

https://github.com/ARMmbed/mbed-os-example-lorawan-fuota

Please read chapter Testing using LoRaServer.io from README.md.

Please note, that I had to make some modifications to the loraserver.js file in order to make it work.
The changes are shown below.

diff --git a/fuota-server/loraserver.js b/fuota-server/loraserver.js
index 59b07ae..29c3b82 100644
--- a/fuota-server/loraserver.js
+++ b/fuota-server/loraserver.js
@@ -4,7 +4,7 @@
  * Note that this is completely hacked together, and I'd suggest to never
  */
 
-const LORASERVER_HOST = process.env.LORA_HOST || '192.168.122.132';
+const LORASERVER_HOST = process.env.LORA_HOST || 'localhost';
 const PACKET_FILE = process.argv[2];
 const DATARATE = process.env.LORA_DR || 0;
 
@@ -19,18 +19,18 @@ const gpsTime = require('gps-time');
 const fs = require('fs');
 const rp = require('request-promise');
 
-const CLASS_C_WAIT_S = 15;
+const CLASS_C_WAIT_S = 60;
 
 // all devices that you want to update
 const devices = [
-    // '00a99d4921b26d75'
-    '00800000040004c9'
+    '0a5032595f506f59', // - NucleoL476
+    //'3037353159347d04' // - NAMote72
 ];
 
 // details for the multicast group
 const mcDetails = {
     applicationID: '1',
-    devEUI: '00a99d4921b26d76',
+    devEUI: 'ffffffffffffffff',
 };
 
 let classCStarted = false;
@@ -78,7 +78,8 @@ client.on('message', async function (topic, message) {
             console.log('deviceTime', deviceTime, 'serverTime', serverTime);
 
             let adjust = serverTime - deviceTime | 0;
-            let resp = [ 1, adjust & 0xff, (adjust >> 8) & 0xff, (adjust >> 16) & 0xff, (adjust >> 24) & 0xff, 0b0000 /* tokenAns */ ];
+            let token = body[5];
+            let resp = [ 1, adjust & 0xff, (adjust >> 8) & 0xff, (adjust >> 16) & 0xff, (adjust >> 24) & 0xff, token & 0x0F ];
 
             let responseMessage = {
                 "reference": "jan" + Date.now(),
@@ -159,7 +160,7 @@ client.on('message', async function (topic, message) {
         }
         else if (body[0] === 0x5) { // DATA_BLOCK_AUTH_REQ
             let hash = '';
-            for (let ix = 5; ix > 1; ix--) {
+            for (let ix = 5; ix > 0; ix--) {
                 hash += body.slice(ix, ix+1).toString('hex');
             }
             console.log('Received DATA_BLOCK_AUTH_REQ', m.devEUI, hash);
@@ -245,7 +246,7 @@ function sendMcClassCSessionReq() {
 
         setTimeout(() => {
             startSendingClassCPackets();
-        }, (CLASS_C_WAIT_S + 10) * 1000); // because the delta drift that we don't know (see above)
+        }, (CLASS_C_WAIT_S + 20) * 1000); // because the delta drift that we don't know (see above)
     }
 
     let msg = {
@@ -315,7 +316,7 @@ async function startSendingClassCPackets() {
 
         console.log('Sent packet', ++counter);
 
-        await sleep(2200); // tpacket on SF12 is 2100 ms. so this should just work (although loraserver doesn't think it's a problem to send faster)
+        await sleep(4000); // tpacket on SF12 is 2100 ms. so this should just work (although loraserver doesn't think it's a problem to send faster)
     }
 
     console.log('Done sending all packets');

@branek
Copy link
Contributor Author

branek commented Jan 15, 2019

Thank you, I was also working on same example. Your changes are very helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants