A homepage subtitle here And an awesome description here!

02 August 2025

CoAP using NodeJS | Californium CoAP Client

CoAP using NodeJS | Californium CoAP Client

This post shows the Constrained Application Protocol (CoAP) demonstration using Node.js

Prerequisites:
1. Node.js Software
3. A Coap Client (we are planning to use Californium, which is based on JavaFX)
4. Oracle 11 JDK is needed
5. Java FX 17 version, which is to be unzipped in any folder.

Step 1: The Source code is named coap.js

Listen to the following video for an explanation of the source code:



var coap = require('coap');

function randomInt(min, max) {
    return (Math.floor(Math.random() * (max - min) + min));
}

var portNumber = 5683;
coap.createServer(function(req, res) {
    console.info('CoAP device got a request from %s', req.url);
    if (req.headers['Accept'] != 'application/json') {
        res.code = '4.06';
        return res.end();
    }
    switch (req.url) {
        case "/co2":
            displayOutput(res, {
                'Co2': randomInt(0, 1000)
            });
            break;
        case "/temperature":
            displayOutput(res, {
                'Temperature': randomInt(-10, 50)
            });
            break;
        case "/humidity":
            displayOutput(res, {
                'Humidity': randomInt(0, 100)
            });
            break;
        default:
            displayOutput(res);
    }
}).listen(portNumber);
console.log('CoAP Server is started at port Number 5683');

function displayOutput(res, content) {
    if (content) {
        res.setOption('Content-Format', 'application/json');
        res.code = '2.05';
        res.end(JSON.stringify(content));
    } else {
        res.code = '4.04';
        res.end();
    }
}

Step 2: Node.js

Install the Node.js software in Windows 11. Download it from https://nodejs.org/en/download
Open a command prompt and check whether Node.js is installed

C:/> node

C:/> npm install coap


Step 3 : Californium Browser

Install Oracle JDK 11 or later in your Windows 11 OS.
Install JavaFX 17 and unzip the contents to a folder, preferably D:/

I have installed it in C:\Users\tspra\Downloads\javafx-sdk-17.0.16\lib

And follow the instructions

Open two command prompts

First prompt, run the following command (run the coap.js file)

Prompt> node coap.js 

You will get the following output
CoAP

 
Second prompt, run the following command:

Go to the folder where the  cf-browser-3.6.0.jar is

Prompt> java --module-path C:\Users\tspra\Downloads\javafx-sdk-17.0.16\lib --add-modules javafx.controls,javafx.fxml -jar cf-browser-3.6.0.jar


CoAP
CF browser


In the above browser, since our code is dealing with the MIME as application/JSON, enable that in CoAP Details -> Accept -> application/json 

Then in the URL location, give the following to check the Response Window

coap://localhost:5683/co2
coap://localhost:5683/humidity
coap://localhost:5683/temperature


CoAP
CF Browser




01 August 2025

How to Install Windows 11 on a Laptop Using a USB Drive

✅ What You’ll Need:

  1. A USB drive with at least 8GB of storage
    (Windows 11 installation files are ~5.4GB)

  2. Windows 11 ISO image or installation DVD

  3. Administrator privileges on your current system


🔧 Step-by-Step Instructions:

Step 1: Backup Your USB Drive

  • Plug in your USB drive and back up any important data — this process will erase everything.

Step 2: Improve USB Performance (Optional, but Recommended)

Step 3: Open Command Prompt as Administrator

Step 4: Use DISKPART to Prepare the USB Drive

Type the following commands one by one:

DISKPART LIST DISK SELECT DISK # ← (Replace # with your USB disk number, e.g., 1) CLEAN CREATE PARTITION PRIMARY SELECT PARTITION 1 ACTIVE FORMAT FS=NTFS quick ASSIGN EXIT

🔄 Step 5: Make the USB Bootable

  1.  Extract the ISO to a folder using tools like WinRAR.

  2. Assume the extracted folder is at: E:\win11

Now, in the same Command Prompt window:

E: CD win11\BOOT BOOTSECT.EXE /NT60 G:

(Replace G: with your USB drive’s letter. This sets up the USB with the Windows boot manager.)

📥 Step 6: Copy Windows Installation Files

Copy all contents of the Windows 11 installation folder to your USB drive.


🔧 Final Step: Boot from USB

  • Restart your PC and enter the BIOS setup.

  • Enable USB Boot and set the USB drive as the first boot device.

  • Save changes and exit.

💡 That’s it! The Windows 11 setup will launch, and if optimised, it can complete in as little as 15 minutes — even on basic hardware!




Powered by Blogger.

About Me

Featured Post

5G Network Simulation in NS3 using mmWave | NS3 Tutorial 2024

5G Network Simulation in NS3 Using mmWave This post shows the installation of ns3mmwave in Ubuntu 24.04 and simulates 5G networks in ns3. In...

Contact form

Name

Email *

Message *

Total Pageviews

Search This Blog

Pages

Pages

Pages - Menu

Most Popular

Popular Posts