Skip to content

Home Network Administration Protocol (HNAP) Client Java Library

Notifications You must be signed in to change notification settings

jbuncle/hnap-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HNAP Client

Release Build Status codecov.io Codacy Badge

Java Library for interacting with devices using the Home Network Administration Protocol (HNAP).

Usage

    public static void main(String[] args) {
        try {
            final String host = "192.168.1.11"; // The HNAP device's host or IP address
            final String username = "admin"; // Username is normally 'admin'
            final String password = "***"; // Your device password goes here

            // Create HnapClient
            final ClientBuilder clientBuilder = new ClientBuilder();
            final HnapClientI client = clientBuilder.createHnapClient(host, username, password);

            // Discover is part of the HNAP protocol - which is a simple "GET" to HNAP1 path
            // This should tell you the devices capabilities
            // Some devices I tried returned a blank response to this, so don't be too put of if this part didn't work
            final DeviceSettingsI results = client.discover();
            System.out.println(results.toString());


            // Perform a login request (which is a couple of requests) so we can perform requests needing authentication
            final HnapSessionI session = client.login();
            // Return a mixed type map because most responses are basically JSON style structures
            final Map<String, Object> isDeviceReady = client.request(session, "GetDeviceSettings", new LinkedHashMap<>());
            System.out.println(isDeviceReady);
        }
        catch (MalformedURLException | HnapClientException ex) {
            Logger.getLogger(BasicHttpClient.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

Installation

This library can be installed using JitPack (which supports Maven & Gradle) https://jitpack.io/#jbuncle/hnap-client, as it isn't in standard repositories.

About

Home Network Administration Protocol (HNAP) Client Java Library

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages