示例#1
0
def Close(conn):
    try:
        conn.close()
        arcLog.create("Connection {} Closed on: {} {}".format(
            conn, Networking.ip, Networking.port))
    except:
        arcLog.create("Issue Closing Connection {} on : {} {}".format(
            conn, Networking.ip, Networking.port))
示例#2
0
def LocTrackClient():
    arcLog.create("LocTrack_Client: Started")
    port = 33334
    for node in arcConfig.GetLanClients():
        i = 0
        arcLog.create("LocTrack_Client: Found {} in Client List".format(node))
        thread.start_new_thread(LocTrackClientThreaded, (node, port))
        i = i + 1
示例#3
0
def SustainmentServer():
    arcLog.create("Sustainment Server: Started")
    #connectedNodes = []
    while True:
        connection, address = sustainment.accept()
        arcLog.create("Sustainment Server: Accessed from: {}".format(address))
        #if address in arcConfig.GetLanClients(): #and address not in connectedNodes:
        #connectedNodes.append(address)
        #arcLog.create("Sustainment Server: Appended New Node: {}".format(address))
        thread.start_new_thread(LocTrackServerThreaded, (connection, address))
示例#4
0
def SustainmentClient():
    arcLog.create("Sustainment Client: Started")
    #threading.Timer(60.0, SustainmentClient()).start()
    #arcLog.create("Sustainment Client Scheduler: Started")
    for address in arcConfig.GetLanClients():
        arcLog.create(
            "Sustainment: Checking {} From Client List".format(address))
        thread.start_new_thread(
            SustainmentClientThreaded,
            (sustainment, address, int(Networking.susPort)))
示例#5
0
def SustainmentClientThreaded(sustainment, address, port):
    arcLog.create(
        "Sustainment Client: Spinning Thread for: {} ".format(address))
    try:
        sustainment.connect((address, Networking.susPort))
        sustainment.send("OK")
        data = sustainment.recv(1024)
        if "OK" in data:
            arcLog.create("Sustainment: Check OK for node")
        if "OK" not in data:
            arcLog.create("Sustainment: Check FAILED for node")
        if not data:
            arcLog.create("Sustainment: No Data Returned")
    except:
        arcLog.create("Sustainment: Check Failed")
示例#6
0
def LocTrackClientThreaded(node, port):
    arcLog.create("LocTrack_Client: Spinning Thread for: {}".format(node))
    try:
        tracking.connect(
            (node, int(Networking.locTrackPort)))  # setup sockets to server
        arcLog.create("LocTrack_Client: Connecting to: {} {}".format(
            node, Networking.locTrackPort))
        soundValue = "57.3db"  # we will get this value from arcHW through function parameter
        finalSoundValue = str.encode(soundValue)
        arcLog.create(
            "LocTrack_Client: Sending Sound Value of {} to: {} {}".format(
                soundValue, node, Networking.locTrackPort))
        tracking.send(finalSoundValue
                      )  # send key for verification								# receive response
        arcLog.create("LocTrack_Client: Sound Value {} Sent: {} {}".format(
            soundValue, node, tracking.locTrackPort))
        thread.exit()
    except:
        arcLog.create("LocTrack_Client: Issue Connecting to: {}".format(node))
        thread.exit()
示例#7
0
def ProvisionServer():
    arcLog.create("Provision Server: Started")
    while True:
        connection, address = provision.accept()
        arcLog.create("Provision Server: Accessed from: {}".format(address))
        arcLog.create("Provision Server: Spinning Thread: {}".format(address))
        thread.start_new_thread(ProvisionServerThreaded, (connection, address))
示例#8
0
def ProvisionServerThreaded(connection, address):
    while True:
        data = connection.recv(1024)  # receive data when connected
        arcLog.create(
            "Provision Thread: Server Received Data: {}".format(address))
        if arcConfig.GetKey()[0] in str(data):
            arcLog.create(
                "Provision Thread: Key Valid from: {}".format(address))
            replyKey = "{}".format(
                arcConfig.GetKey())  # friendNode will verify key
            finalReplyKey = str.encode(replyKey)
            connection.send(finalReplyKey)  # send ack with key
            arcLog.create(
                "Provision Thread: Sending Reciprocative Key to: {}".format(
                    address))
            LanAddClients(address)  # add client to local db
            arcLog.create(
                "Provision Thread: Completed Provision with {}".format(
                    address))
            break
    arcLog.create("Provision Thread: Closing for: {}".format(address))
    connection.close()  # close connection
    thread.exit()  # exit thread
示例#9
0
def LocTrackServerThreaded(connection, address):
    while True:
        arcLog.create(
            "LocTrack Server: Spinning Thread for: {}".format(address))
        soundData = connection.recv(1024)  # receive data when connected
        arcLog.create("Received Sound Data {} from: {}, Value: {}".format(
            soundData, address, soundData))
        StoreValue(address, soundData)
        arcRDB.SendTrackData()
    arcLog.create("LocTrack Thread: Closing for: {}".format(address))
    connection.close()
    thread.exit()
示例#10
0
def FindProvision(node):
    try:
        provision.sockOBJ.connect((node))  # setup sockets to server
    except:
        arcLog.create("No Provision Connection from {}".format(node))

    provision.sockOBJ.send(arcConfig.GetKey()[0])  # send key for verification
    data = Provision.sockOBJ.recv(1024)  # receive response
    if arcConfig.GetKey()[0] in str(data):  # if key in response
        arcConfig.LanAddClients(TestClient.ip)  # add server as friend
        arcLog.create("Added {} to Client's list".format(TestClient.ip))
    provision.sockOBJ.close()  # close connection
    arcLog.create("Socket Closed for: {}".format(node))
示例#11
0
def LanSetup(totalConn):

    # LanSetup inits networking variables for various tasks:
    # Provisioning, Location Tracking, and Sustainment.
    # The IP's and ports are managed through the ARC Console / database,
    # the values are verified and set within arcConfig.py

    # provisioning sockets:
    try:
        global provision
        provision = Networking.sockOBJ
        try:
            provision.bind((Networking.ip, int(Networking.port)))
            provision.listen(totalConn)
            arcLog.create("Provision: Sockets have been set up: {} {}".format(
                Networking.ip, Networking.port))
        except:
            arcLog.create("Provision: Port {} is already bound".format(
                Networking.port))
            #LanRebindPort(provision)
    except:
        arcLog.create("Tracking: Issue Setting up Sockets on: {} {}".format(
            Networking.ip, Networking.port))

# location tracking sockets:
    try:
        global tracking
        tracking = Networking.locOBJ
        try:
            tracking.bind((Networking.ip, int(Networking.locTrackPort)))
            tracking.listen(totalConn)
            arcLog.create("Tracking: Sockets have been set up: {} {}".format(
                Networking.ip, Networking.locTrackPort))
        except:
            arcLog.create("Tracking: Port {} is already bound".format(
                Networking.locTrackPort))
            #LanRebindPort(tracking)
    except:
        arcLog.create("Tracking: Issue Setting up Sockets on: {} {}".format(
            Networking.ip, Networking.locTrackPort))


# sustainment sockets:
    try:
        global sustainment
        sustainment = Networking.susOBJ
        try:
            sustainment.bind((Networking.ip, int(Networking.susPort)))
            sustainment.listen(totalConn)
            arcLog.create(
                "Sustainment: Sockets have been set up: {} {}".format(
                    Networking.ip, Networking.susPort))
        except:
            arcLog.create("Sustainment: Port {} is already bound".format(
                Networking.susPort))
            #LanRebindPort(tracking)
    except:
        arcLog.create("Sustainment: Issue Setting up Sockets on: {} {}".format(
            Networking.ip, Networking.susPort))
示例#12
0
def SustainmentServerThreaded(connection, address):
    arcLog.create(
        "Sustainment Server: Spinning Thread for: {} ".format(address))
    while True:
        arcLog.create(
            "Sustainment Server: Spinning Thread for: {}".format(address))
        data = connection.recv(1024)  # receive data when connected
        arcLog.create(
            "Sustainment Server: Received ACK Check from: {}".format(address))
        if "OK" in data:
            arcLog.create("Sustainment: Check OK for node")
        if "OK" not in data:
            arcLog.create("Sustainment: Check FAILED for node")
        if not data:
            arcLog.create("Sustainment: No Data Returned")
        sustainment.send("OK")
    arcLog.create("Sustainment Server: Thread Closing for: {}".format(address))
    connection.close()
    thread.exit()
示例#13
0
def LanAddClients(ip):
    arcConfig.LanAddClients(
        ip)  # send to shelf when found through expected data
    arcLog.create("Added Client: {}".format(ip))