LED Control

How to start a local network connection programmatically via Wi-Fi hotspot on Android?

I want to start a local network connection using the built-in Wi-Fi hotspot on Android devices. Is there a way to accomplish it? And how to communicate between two devices? EDIT: I want to do it programmatically. Then I can transfer my own data between devices.

Can you clarify your question. What do you want to connect to and how? Do you mean to say you want to connect a device (like a PC) to your phone’s wifi hotspot (ie tethering) automatically?

I want to write an app which can communicate between several android devices. (I think it’s up to total 6 devices since the wifi hotspots has limit of 5 clients at most.) For example, a local subnet chatroom.

So that will be a server and 5 clients in the network. And can communicate like server-client structure.

The server itself needs to use the ServerSocket to listen for incoming connections on a particular port and the clients would then connect to the server IP Address on that port. Take a look at NanoHttpd below, as it does exactly that and the code is all there.

5 Answers 5

I haven’t done this before, so my answer is all theoretical.

I think what you need to do is declare one device the server and start its hotspot manually with a known name.

Start / stop built-in Wi-Fi / USB tethering from code? (According to this question, you can’t start hotspot programatically).

Once you have the hotspot set up, you start up the server app and wait for incoming connections. The server app can show you the ip address or hostname.

On the clients, you can do a simple check and see if the hotspot name is around and automatically connect to it if you find it. See this link for connecting to a network:

As for your second question, how to communicate — you need to establish a connection between the devices. For this, you need the ip address of the server. The simplest thing to do would be to show the ip address on the server UI and then manually enter it on the clients and press connect. It would then establish a connection to the server on a known port and you can send messages between client and server.

For reference, I found NanoHttpd, which is a webserver for Android. It uses ServerSocket to listen for incoming connections.

Источник

Setting up a wireless network in Windows

A wireless network at home lets you get online from more places in your house. This article describes the basic steps for setting up a wireless network and starting to use it.

Читайте также:  Показать пароль моего вай фай

Get the right equipment

Before you can set up your wireless network, here’s what you’ll need:

Broadband Internet connection and modem. A broadband Internet connection is a high-speed Internet connection. Digital Subscriber Line (DSL) and cable are two of the most common broadband connections. You can get a broadband connection by contacting an Internet service provider (ISP). Typically, ISPs that provide DSL are telephone companies and ISPs that provide cable are cable TV companies. ISPs frequently offer broadband modems. Some ISPs also offer combination modem/wireless routers. You can also find these at computer or electronics stores, and online.

Wireless router. A router sends info between your network and the Internet. With a wireless router, you can connect PCs to your network using radio signals instead of wires. There are several different kinds of wireless network technologies, which include 802.11a, 802.11b, 802.11g, 802.11n, 802.11ac, and 802.11ax.

Wireless network adapter. A wireless network adapter is a device that connects your PC to a wireless network. To connect your portable or desktop PC to your wireless network, the PC must have a wireless network adapter. Most laptops and tablets—and some desktop PCs—come with a wireless network adapter already installed.

To check whether your PC has a wireless network adapter:

  1. Select Start , type device manager in the search box, and then select Device Manager.
  2. Expand Network adapters.
  3. Look for a network adapter that might have wireless in the name.

Setting up the modem and Internet connection

After you have all the equipment, you’ll need to set up your modem and Internet connection. If your modem wasn’t set up for you by your Internet service provider (ISP), follow the instructions that came with your modem to connect it to your PC and the Internet. If you’re using Digital Subscriber Line (DSL), connect your modem to a phone jack. If you’re using cable, connect your modem to a cable jack.

Positioning the wireless router

Put your wireless router somewhere where it will receive the strongest signal with the least amount of interference. For better results, follow these tips:

Place your wireless router in a central location. Place the router as close to the center of your home as possible to increase the strength of the wireless signal throughout your home.

Position the wireless router off the floor and away from walls and metal objects, such as metal file cabinets. The fewer physical obstructions between your PC and the router’s signal, the more likely that you’ll be using the router’s full signal strength.

Reduce interference. Some networking equipment uses a 2.4 gigahertz (GHz) radio frequency. This is the same frequency as most microwaves and many cordless phones. If you turn on the microwave or get a call on a cordless phone, your wireless signal might be temporarily interrupted. You can avoid most of these issues by using a cordless phone with a higher frequency, such as 5.8 GHz.

Читайте также:  Dlna wi fi android

Securing your wireless network

Security is always important; with a wireless network, it’s even more important because your network’s signal could be broadcast outside your home. If you don’t help secure your network, people with PCs nearby could access info stored on your network PCs and use your Internet connection.

To help make your network more secure:

Change the default user name and password. This helps protect your router. Most router manufacturers have a default user name and password on the router and a default network name (also known as the SSID). Someone could use this info to access your router without you knowing it. To help avoid that, change the default user name and password for your router. See the documentation for your device for instructions.

Set up a security key (password) for your network. Wireless networks have a network security key to help protect them from unauthorized access. We recommend using Wi-Fi Protected Access 3 (WPA3) security if your router and PC support it. See the documentation for your router for more detailed info, including what type of security is supported and how to set it up.

Some routers support Wi-Fi Protected Setup (WPS). If your router supports WPS and it’s connected to the network, follow these steps to set up a network security key:

  1. Do one of the following, depending on which version of Windows is running on your PC:
    • In Windows 7 or Windows 8.1, select Start, start typing Network and Sharing Center, and then choose it in the list.
    • In Windows 10, select Start , then select Settings >Network & Internet >Status >Network and Sharing Center.
    • In Windows 11, select Start, type control panel, then select Control Panel >Network and Internet >Network and Sharing Center.
  2. Select Set up a new connection or network.
  3. Select Set up a new network, then choose Next.

The wizard will walk you through creating a network name and a security key. If your router supports it, the wizard will default to Wi‑Fi Protected Access (WPA2 or WPA3) security. We recommend that you use WPA3 if you can, because it offers better security than WPA2, WPA, or Wired Equivalent Privacy (WEP) security. With WPA3, WPA2 or WPA you can also use a passphrase, so you don’t have to remember a cryptic sequence of letters and numbers.

Write down your security key and keep it in a safe place. You can also save your security key on a USB flash drive by following the instructions in the wizard. (Saving your security key to a USB flash drive is available in Windows 8 and Windows 7, but not in Windows 10 or Windows 11.)

Use a firewall. A firewall is hardware or software that can help protect your PC from unauthorized users or malicious software (malware). Running a firewall on each PC on your network can help control the spread of malicious software on your network, and help protect your PCs when you’re accessing the Internet. Windows Firewall is included with this version of Windows.

Читайте также:  Usb точка раздачи wi fi

Connect a PC to your wireless network

  1. Select the Network or Wifi icon in the notification area.
  2. In the list of networks, choose the network that you want to connect to, and then select Connect.
  3. Type the security key (often called the password).
  4. Follow additional instructions if there are any.

If you have problems with your Wi-Fi network when using Windows 10, see Fix Wi-Fi problems in Windows for advanced troubleshooting info.

  1. Select the Network icon in the notification area, then select the > icon next to the Wi-Fi quick setting to see a list of available networks.
  2. Choose the network that you want to connect to, and then select Connect.
  3. Type the security key (often called the password).
  4. Follow additional instructions if there are any.

If you have problems with your Wi-Fi network when using Windows 11, see Fix Wi-Fi problems in Windows for advanced troubleshooting info.

Источник

How to connect the ESP 8266 to local area network?

enter image description here

I am working on an ESP8266 ESP-12E WiFi Module to turn an LED on and off. Yes, I was able to turn on/turn off the LED with the help of Wifiserver and NodeMCU. The problem is I want to connect the NodeMCU with my local area network on the PC. My PC does not connect with Wi-Fi, only an Ethernet connection is present. How can I connect the NodeMCU with my local area network connection, not with the mobile hotspot? This is my code:

#include /*Put your SSID & Password*/ const char* ssid = "ssid"; // Enter SSID here const char* password = "password"; //Enter Password here ESP8266WebServer server(80); uint8_t LEDpin = D2; bool LEDstatus = LOW; void setup() < Serial.begin(9600); delay(100); pinMode(LEDpin, OUTPUT); Serial.println("Connecting to "); Serial.println("ssid"); //connect to your local wi-fi network WiFi.begin( "ssid", "password"); //check wi-fi is connected to wi-fi network while (WiFi.status() != WL_CONNECTED) < delay(1000); Serial.print ("."); >Serial.println(""); Serial.println("WiFi connected. "); Serial.print("Got IP: "); Serial.println(WiFi.localIP()); server.on("/", handle_OnConnect); server.on("/ledon", handle_ledon); server.on("/ledoff", handle_ledoff); server.onNotFound(handle_NotFound); server.begin(); Serial.println("HTTP server started"); > void loop() < server.handleClient(); if(LEDstatus) digitalWrite(LEDpin, HIGH); else digitalWrite(LEDpin, LOW); >void handle_OnConnect() < LEDstatus = LOW; server.send(200, "text/html", SendHTML(false)); >void handle_ledon() < LEDstatus = HIGH; server.send(200, "text/html", SendHTML(true)); >void handle_ledoff() < LEDstatus = LOW; server.send(200, "text/html", SendHTML(false)); >void handle_NotFound() < server.send(404, "text/plain", "Not found"); >String SendHTML(uint8_t led)< String ptr = "\n"; ptr +="\n"; ptr +="\n"; ptr +="\n"; ptr +="\n"; ptr +="\n"; ptr +="

LED

\n"; ptr +="

Click to switch LED on and off.

\n"; ptr +="
\n"; if(led) ptr +="\n"; else ptr +="\n"; ptr +="
\n"; ptr +="\n"; ptr +="\n"; return ptr; >

Источник

Оцените статью
Adblock
detector