on Electronics, HowTo, Ubuntu

Share Internet from WiFi via Ethernet on Ubuntu 17.10

Share Internet from WiFi via Ethernet on Ubuntu 17.10

There is a hidden method to share your WiFi over Ethernet in the latest Gnome.

  1. Type nm-connection-editor in your terminal.
  2. Add a shared network connection by pressing the Add button.
  3. Choose Ethernet from the list and press Create.
  4. Click IPv4 Settings in the left.
  5. Choose Shared to other computers by clicking the Method drop-down menu.
  6. Enter a new name like Shared WiFi LAN as the Connection name at the top
  7. Select the newly created connection from wired connection.
 

Create Cheap Philips Hue Compatible Devices

The Philips Hue range is a great way to add wirelessly controllable lighting to your home, but the protocol is proprietary which makes it difficult to add our own custom hardware. [Peter] found a way to create his own Hue compatible devices based on cheap JN5168 modules that are able to connect to the Hue bridge. This means you can roll out your own lamps using cheap RGB or White LEDs, a power supply and the JN5168 Zigbee Light Link module.

He started off by trying to clone a Zigbee Light Link device to a MeshBee — Seeed studio’s open source Zigbee Pro module based on the NXP JN5168. Even though the MeshBee used the same device as a Hue lamp, it would not connect to the Hue bridge. But another clone lamp called Innr that he purchased from the local hardware store did connect quite easily. Using NXP’s open source tools, he was able to download the flash and EEPROM contents from the Innr and copy them to the MeshBee which did the trick.

After the EEPROM transfer trick, he figured out how to modify the two keys used for the ZigBee protocol — one for Home Automation and the other for the Light Link. With this final discovery, he is able to take the ZigBee Light Link demo project, edit it using Beyond Studio, and then load the binaries on the MeshBee device so it can connect to the Hue bridge.

All of this work culminates in two custom firmware binaries; one for white dimmable lights and another for RGB dimmable ones. It even runs on these cheap JN5168 breakout kits he found for a few bucks. With all of the software taken care of, and having cheap ZigBee Light Link compatible modules on hand, building low-cost Hue compatible lights becomes pretty straight forward.

Thanks [wind-rider] for the tip.

View @hackaday.com

 

validate ip address using regex

The code snippet below will check if the passed string is a valid IP address or not .
An Internet Protocol address (IP address) is a numerical label assigned to each device participating in a computer network that uses the Internet Protocol for communication. Read more about IP address here. This snippet will validate IP version 4 addresses.

/**
 * validate IP address
 * @param String IP address to verify
 * @return Boolean result
 */
public static Boolean isIP(String input) {
    if (input!= null && !input.isEmpty()) {
        //Regex
        String regex = "^((25[0-5])|(2[0-4]\\d)|(1\\d\\d)|([1-9]\\d)|\\d)(\\.((25[0-5])|(2[0-4]\\d)|(1\\d\\d)|([1-9]\\d)|\\d)){3}$";
        //check if input matches the regex
        if (text.matches(regex)) {
            // valid ip
            return true;
        } else {
            // invalid ip
            return false;
        }
    }
    // invalid input
    return false;
}  

 

SIMCOM SIM800H change in hardware. S2-105HG / S2-10651 , S2-1065N / S2-1065Q

SIMCOM has updated the hardware of SIM800H modules with hardware versions (S2-105HG / S2-10651) due to the fact that the power amplifier chip that these modules used (RF7176) is discontinued from production line. The Firmware also had to be changed due to modifications necessary for operation of the new power amplifier chips.

All the new modules ( with hardware versions(S2-1065N / S2-1065Q) ) will be having the new power amplifier chips namely RF7198. According to SIMCOM this change in hardware wont affect the properties and characteristics of the module.

Please note that:

  • firmware for the new hardware version of module differs from the old version of the firmware. Therefore, a new hardware version module can not be flashed with the firmware for the old hardware version module.
  • firmware image files for the old and new hardware versions will be with different names. Firmware for the old version is designated “1308B06SIM800H32_BT” while the firmware for the new version is designated “1309B06SIM800H32_BT”.

sim800H

Firmware files for SIM800H

All the firmware files can be found at the firmware collection page of this blog. If you want to contribute the files you have you can do so by uploading your files to user uploads section or by emailing me the files you have.

 

 

 

isOnline() check if android device has internet connectivity

What do you want?

  • If you just want to check for a connection to any network – not caring if internet is available – then most of the answers here (including the accepted), implementing isConnectedOrConnecting() will work well.
  • If you want to know if you have an internet connection (as the question title indicates) please read on

Ping for the main name servers

public boolean isOnline() {
    Runtime runtime = Runtime.getRuntime();
    try {
       Process ipProcess = runtime.exec("/system/bin/ping -c 1 8.8.8.8");
        int     exitValue = ipProcess.waitFor();
        return (exitValue == 0);
    } catch (IOException e)          { e.printStackTrace(); } 
      catch (InterruptedException e) { e.printStackTrace(); }
    return false;
}

That’s it! Yes that short, yes it is fast, no it does not need to run in background, no you don’t need root privileges.

Possible Questions

  • Is this really fast enough?Yes, very fast!
  • Is there really no reliable way to check if internet is available, other than testing something on the internet?Not as far as I know, but let me know, and I will edit my answer.
  • Couldn’t I just ping my own page, which I want to request anyways?Sure! You could even check both, if you want to differentiate between “internet connection available” and your own servers beeing reachable
  • What if the DNS is down?Google DNS (e.g. 8.8.8.8) is the largest public DNS service in the world. As of 2013 it serves 130 billion requests a day. Let ‘s just say, your app not responding would probably not be the talk of the day.
  • Which permissions are required?
    <uses-permission android:name="android.permission.INTERNET" />

    Just internet access – what surprise ^^ (BTW have you ever thought about, how some of the methods suggested here could even have a remote glue about the availability of internet, without this permission?)