Exemple #1
0
    def set_parameters(self, wlan=None, inet=None, ip=None, netmask=None, ssid=None, password=None):
        """The high-level method to set access point parameters.

        Args:
            wlan:       	        wi-fi interface that will be used to create hotSpot
            inet:       	        forwarding interface
            ip:       	            ip address of this machine in new network
            netmask:       	        Netmask address.
            ssid:       	        Preferred access point name.
            password:       	    Password of the access point.
        """

        if wlan:
            self.wlan = wlan
        if inet:
            self.inet = inet
        if ip:
            self.ip = ip
        if netmask:
            self.netmask = netmask
        if ssid:
            self.ssid = ssid
        if password:
            self.password = password

        self.access_point = pyaccesspoint.AccessPoint(wlan=self.wlan, inet=self.inet, ip=self.ip, netmask=self.netmask, ssid=self.ssid, password=self.password)
Exemple #2
0
def createAP(interface,
             channel,
             ssid='Hotspot',
             ip='192.168.45.1',
             netmask='255.255.255.0'):
    access_point = pyaccesspoint.AccessPoint(interface, ethernet_name, ip,
                                             netmask, ssid, channel)
    access_point.start()
    time.sleep(2)
Exemple #3
0
def linux_hotspot():
    try:
        from PyAccessPoint import pyaccesspoint
    except ImportError:
        pip.main(['install', 'pyaccesspoint'])
    ap = pyaccesspoint.AccessPoint(wlan='wlp3s0',
                                   ssid='File_Transfer',
                                   password='******')
    if (not ap.is_running()):
        ap.start()
Exemple #4
0
 def __init__(self):
     self.command_socket = None
     self.host_address = '192.168.123.101'
     self.android_address = None
     self.port = 9999
     self.buffer_size = 128
     self.access_point = ap.AccessPoint(wlan='wlan0',
                                        inet='lo0',
                                        ssid='jetson',
                                        password='******')
Exemple #5
0
    def create_network(self):
        logger.info('Configurando o ponto de acesso...')

        wifi = pa.AccessPoint(ssid=self.config['wifi']['ssid'], password=self.config['wifi']['password'])

        logger.info('Iniciando o ponto de acesso...')

        wifi.stop()
        wifi.start()

        logger.success('Processo concluído.')
 def __init__(self):
     self.access_point = pyaccesspoint.AccessPoint(ssid='KooReminder',
                                                   inet=None,
                                                   wlan='wlan0',
                                                   ip='10.0.0.1',
                                                   netmask='255.0.0.0')
     self.password = None
     self.password_length = 12
     self.characters = [x for x in ascii_letters + digits]
     self.access_point.stop()
     atexit.register(self.toggle_access_point, False)
Exemple #7
0
    def __init__(self, args):
        """Initialization method of :class:`t_system.accession.AccessPoint` class.

        Args:
            args:                   Command-line arguments.
        """

        self.wlan = args["ap_wlan"]
        self.inet = args["ap_inet"]
        self.ip = args["ap_ip"]
        self.netmask = args["ap_netmask"]
        self.ssid = args["ssid"]
        self.password = args["password"]

        self.access_point = pyaccesspoint.AccessPoint(wlan=self.wlan, inet=self.inet, ip=self.ip, netmask=self.netmask, ssid=self.ssid, password=self.password)
Exemple #8
0
 def __init__(self, access_point, flask_app, connected):
     if connected != None:
         self.connected = connected
         self.connected.value = 0
     self.host = flask_app["host"]
     self.port = flask_app["port"]
     self.wlan = access_point["wlan"]
     global wlan
     wlan = self.wlan
     self.access_point = pyaccesspoint.AccessPoint(
         wlan=access_point["wlan"],
         ip=access_point["ip"],
         inet=access_point["inet"],
         ssid=access_point["ssid"],
         netmask=access_point["netmask"],
         password=access_point["password"])
Exemple #9
0
    def __init__(self):
        self.servSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
        self.session = EegSession()
        self.game_settings = GameSettings()
        self.srv_running = False
        self.clientSock = None
        #self.dataHandler = None
        self.dataSource = None
        self.state = MP_CTX.Value('i', NSV_STATE_IDLE)
        self.data_pipe_ctl, self.data_pipe_src = MP_CTX.Pipe()
        self.choosen_music = ""
        self.user = self.get_users()[0]
        self.access_point = pyaccesspoint.AccessPoint()

        self.timer = None

        signal.signal(signal.SIGINT, self.server_stop)
Exemple #10
0
    def __init__(self, event):
        super().__init__()

        self.stopped = event
        self.count = 0
        self.wlan_count_found = 0
        self.wireless_module = Wireless()

        self.wlan_name_found_to_connect = ""
        self.wlan_name_found_to_connect_time = 999999999999

        # defines a hotspot object with the ssid "Test Wlan" and the password from the constants,
        # ssid will be changed later. Because of a known bug, the hotspot is stopped once before the start.
        self.access_point = pyaccesspoint.AccessPoint(
            ssid="Test Wlan", password=const.Connection.WLAN_PASSWORD)
        self.access_point.stop()

        self.hotspot_status = False
        self.own_wlan_name_from_hotspot = "parknet"
        self.own_wlan_time_from_hotspot = 9999999999999

        self.last_wlan_connected = "unset"
        self.block_list = []
Exemple #11
0
        while not expected_result.IsInitialized():
            expected_result = doc_ref.set(cam_document_template)

    parser.set("APP_CONFIG", "CameraURL",
               "rtsp://" + current_ip + ":8554/video")
    with open("config.ini", "w") as file:
        parser.write(file)

    print("Starting smart camera")
    os.system("python3 smart_camera.py")

elif len(result) == 1 and parser["APP_CONFIG"].get("AppConnected") == "False":
    # Start wifi hotspot
    access_point = pyaccesspoint.AccessPoint(
        ssid=parser["APP_CONFIG"].get("H_SSID"),
        password=parser["APP_CONFIG"].get("H_PSK"),
    )
    access_point.start()
    print(
        "Please connect to the hotspot : \nSSID : Smart Camera\nPassword : 1234567890"
    )
    # Starting http server
    server_address = ("", port_number)
    server = HTTPServer(server_address, Handler)
    server.serve_forever()
    # Get the form data
    os.system("python3 camera_setup.py")

else:
    print("Device Corrupted")
    exit()
Exemple #12
0
 def __init__(self, port):
     self.api = dict()
     handler = CustomHTTPRequestHandlerClass(self.api)
     self.srv: TCPServer = TCPServer(("", port), handler)
     self.ap = pyaccesspoint.AccessPoint(ssid="ambiPi", password="******")
Exemple #13
0
# This script opens up a standalone wifi network with user determined network information.
#
# version: 1.0 (31.12.2019)

import time
import threading
import time
import logging
from PyAccessPoint import pyaccesspoint

logging.basicConfig(format="%(asctime)s ::%(levelname)s:: %(message)s",
                    level=logging.DEBUG)

access_point = pyaccesspoint.AccessPoint(ssid="Test123", password="******")
access_point.start()

print(access_point.is_running())
print("Creating access point ssid: Test123 and passwort: Hallo123")
print(
    "In order to connect to your picar via SSH use network information and standard user information for login."
)

time.sleep(30)
print("3")
time.sleep(1)
print("2")
time.sleep(1)
print("1")
time.sleep(1)

print("Shutting down!")
Exemple #14
0
def create(networkName):
    access_point = pyaccesspoint.AccessPoint(ssid=networkName,
                                             ip="192.168.0.10")
    access_point.start()
def run():
    # start time variable 
    start = time.time()

    # provide the name of your ssid
    ssid = 'YALEFox_Guest_WiFi'  # yale fox; the person to whom idea is inspired and all credited goes to him

    # give the wifi protocol segment to be implemented    
    Wifi_Protocol = 'WPA/WPA2'

    # wpa_passphrase generation using builtin "urandom" linux program and save it
    # or you can enter it as for any length from 8 to 64 characters through "wpa_passphrase" variable
    # like wpa_passphrase = 'ajkdsbdjasdbasjkflfdkalshdaskdhasldkasld78'
    wpa_passphrase = subprocess.getoutput('< /dev/urandom tr -cd "[:print:]" | head -c 63;')

    # creating the accesspoint object "ap" from the class of pyaccesspoint module
    ap = pyaccesspoint.AccessPoint()

    # provide your desired ssid and assign it to access point object "ap"
    ap.ssid = ssid

    # creating passphrase (password) and assiging it to access point object "ap"
    ap.password = wpa_passphrase

    # provide the network ip which needs to be implemented for WiFi LAN (default ip = 192.168.45.1)
    ap.ip = "192.168.4.1"

    # ipv4 forwarding and bridging internet access when eth0 is accessing internet for raspberry pi
    # "eth0" is used as internet packet forwarding and making accesspoint as internet accessible
    ap.inet = "eth0"

    # run the "ap" object so that the access point is created on the RPI with desired above mentioned info 
    ap.start()

    # supplemnetary printing of object location
    print(ap)

    # providing true value gives "ap" successfully created and implemented and useful
    # while on False check the manual and procedure accordingly
    print(ap.is_running())

    # time value for how much long to be "ap" should be created and maintained (in secs)
    time_value = 86400   # 2 min = 120 secs  | 24 hrs = 86400 secs | 7 days = 604800 secs

    # Generate QR code picture for Android
    aqrcode = pyqrcode.create(F'WIFI:S:{ssid};T:{Wifi_Protocol};P:{wpa_passphrase};;')

    # save the qrcode in png format
    aqrcode.png(r'/home/pi/QRcode-Guest-WiFi/qrcode/aqrcode.png', scale=2)

    # IOS requires a hosted webpage which I do not want to host
    # Use the copy to clipboard function for the password and manually connect instead.
    iqrcode = pyqrcode.create(F'${wpa_passphrase}')

    # save the qrcode in png format
    iqrcode.png(r'/home/pi/QRcode-Guest-WiFi/qrcode/iqrcode.png', scale=2)

    # create a black image on which qrcodes will lie on (it must of resolution as of LCD-screen)
    black = np.zeros((320, 480, 3), 'uint8')

    # locate and load the qrcode-image of android to "qr-android" variable
    qr_android = cv2.imread(r'/home/pi/QRcode-Guest-WiFi/qrcode/aqrcode.png')

    # locate and load the qrcode-image of iphone to "qr-iphone" variable    
    qr_iphone = cv2.imread(r'/home/pi/QRcode-Guest-WiFi/qrcode/iqrcode.png')    

    # shape of black image (320x480)
    x1 = black.shape[0]
    y1 = black.shape[1]

    # shape of android qr-code 
    x2 = qr_android.shape[0]
    y2 = qr_android.shape[1]

    # shape of iphone qr-code
    x3 = qr_iphone.shape[0]
    y3 = qr_iphone.shape[1]

    # finding center of black image
    a = int((x1-x2)/2)
    b = int((y1-y2)/2)

    # make a copy of black image from "black" to "res"
    res = black.copy()

    # pasting images of qr-code of android and iphone to the black-image for display
    res[a:a+x2, b-50:b+y2-50] = qr_android
    res[a:a+x3, b+100:b+y3+100] = qr_iphone

    # providing font-text style
    font = cv2.FONT_HERSHEY_SIMPLEX

    # ssid and wpa_passphrase texts to be put on the top of the black image for display 
    cv2.putText(res, f'WLAN-SSID = {ssid}', (b-20,a-50), font, 0.4, (255,255,255), 1)
    cv2.putText(res, f'WLAN-Paraphrase = {wpa_passphrase}', (b-130,a-20), font, 0.4, (255,255,255), 1)

    # label texts to be put on bottom each of the qr-codes according to their types
    txt1 = 'Android'
    txt2 = 'Iphone'
    cv2.putText(res, f'{txt1}', (b-30,a+140), font, 0.4, (255,255,255), 1)
    cv2.putText(res, f'{txt2}', (b+125,a+120), font, 0.4, (255,255,255), 1)

    # save the output for making it as a screen saver for displaying it over touch LCD-screen
    cv2.imwrite(r'/home/pi/QRcode-Guest-WiFi/output/output.png', res)

    # screen saver program running it through "feh module"
    os.popen("feh -Z -z -x -F --hide-pointer /home/pi/QRcode-Guest-WiFi/output/")
        
    # looping for timing the "ap" for a certain schedule
    while(True):
        # elasped time is the variable after accesspoint is created and maintain for that much long
        elasped = time.time() - start
        # conditional statement for "ap" time up scheduling
        if(elasped > time_value):
            print('time up.!')
            # this command stop the access point "ap" and close the connection of WiFi LAN
            ap.stop()
            # break and goes off the program, to terminate it as whole 
            # and run it again as recursively
            run()
from PyAccessPoint import pyaccesspoint

accessPoint = pyaccesspoint.AccessPoint(
)  #here you can set the values of the parameters such as name of the network and password etc
accessPoint.start()

if accessPoint.is_running():
    print("it is working")
else:
    print("it is not working")
# This was found working in Ubuntu 19.04 but I do not really know whether it works on the Respberry pi :)
Exemple #17
0
            # After initialised , the configuration is not updated to the server
            elif logged_url not in cam_dict.keys():
                document = db.document(parser["CLOUD_CONFIG"].get("CAM") +
                                       "/" + parser["CLOUD_CONFIG"].get("UID"))
                cam_dict.update({logged_url: logged_name})
                print("Camera has been initialised")
            else:
                print("No changes !!!")
            # update ip to cloud and config file
            document.set(cam_dict)
            print("Starting smart camera")
            os.system("python3 smart_camera.py")
        except:
            print("Cannot connect to cloud .. logging disabled")

else:
    # Start wifi hotspot
    access_point = pyaccesspoint.AccessPoint(ssid="Smart Camera",
                                             password="******")
    access_point.start()
    print(
        "Please connect to the hotspot : \nSSID : Smart Camera\nPassword : 1234567890"
    )
    # Starting http server
    server = httpserver.HTTPServer((current_ip, port_number), Handler)
    server.serve_forever()
    # Get the form data
    os.system("python3 camera_setup.py")

# execute smart_camera.py
#!/usr/bin/python3

from PyAccessPoint import pyaccesspoint

accessPoint = pyaccesspoint.AccessPoint(wlan='wlan0',
                                        inet=None,
                                        ip='192.168.30.1',
                                        netmask='255.255.255.0',
                                        ssid='RaymondPi',
                                        password='******')
if accessPoint.is_running():
    accessPoint.stop()
result = accessPoint.start()
print(result)
Exemple #19
0
from PyAccessPoint import pyaccesspoint
import socket
import json
import time
from .dbconn import trust_user_pass, get_filter_word
print('hot spot status is {}'.format(
    not pyaccesspoint.AccessPoint().is_running()))
access_point = None
host = None
access_point = pyaccesspoint.AccessPoint()
access_point.wlan = 'wlp2s0'
if access_point.is_running():
    access_point.stop()
try:
    access_point.wlan = 'wlp2s0'
    access_point.ip = '192.168.43.1'
    access_point.netmask = '255.255.255.0'
    access_point.ssid = 'chat test'
    access_point.password = '******'
    access_point.start()
    host = access_point.ip
    print("accessPoint Starting...")
    if access_point.is_running():
        print('hotspot start in ' + str(access_point.ip) + ' with pass' +
              str(access_point.password))
except Exception as e:
    access_point.stop()
    print('cant run accessPoint')

ipId = {}
addr = None