Subversion Repositories tpanel

Rev

Rev 400 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 400 Rev 406
Line 1... Line 1...
1
/*
1
/*
2
 * Copyright (C) 2018 to 2022 by Andreas Theofilu <andreas@theosys.at>
2
 * Copyright (C) 2018 to 2023 by Andreas Theofilu <andreas@theosys.at>
3
 *
3
 *
4
 * This program is free software; you can redistribute it and/or modify
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
7
 * (at your option) any later version.
Line 355... Line 355...
355
 
355
 
356
        if (__CommValid && TConfig::getController() == "0.0.0.0")
356
        if (__CommValid && TConfig::getController() == "0.0.0.0")
357
        {
357
        {
358
            string controller = TConfig::getController();
358
            string controller = TConfig::getController();
359
            MSG_INFO("Refusing to connect to invalid controller " << controller);
359
            MSG_INFO("Refusing to connect to invalid controller " << controller);
360
            sendAllFuncNetwork(NSTATE_OFFLINE);
360
            sendAllFuncNetwork(mLastOnlineState == NSTATE_OFFLINE ? NSTATE_OFFLINE1 : NSTATE_OFFLINE);
361
            std::this_thread::sleep_for(std::chrono::seconds(10));  // Wait 10 seconds before next try
361
            std::this_thread::sleep_for(std::chrono::seconds(10));  // Wait 10 seconds before next try
362
            continue;
362
            continue;
363
        }
363
        }
364
 
364
 
365
        if (__CommValid && mSocket && !mSocket->connect(TConfig::getController(), TConfig::getPort()))
365
        if (__CommValid && mSocket && !mSocket->connect(TConfig::getController(), TConfig::getPort()))
Line 1145... Line 1145...
1145
                    memset(comm.data.blinkMessage.dateTime, 0, sizeof(comm.data.blinkMessage.dateTime));
1145
                    memset(comm.data.blinkMessage.dateTime, 0, sizeof(comm.data.blinkMessage.dateTime));
1146
                    memcpy(comm.data.blinkMessage.dateTime, &buff_[12], comm.hlen - 0x0015 - 11);
1146
                    memcpy(comm.data.blinkMessage.dateTime, &buff_[12], comm.hlen - 0x0015 - 11);
1147
                    comm.checksum = buff_[comm.hlen + 3];
1147
                    comm.checksum = buff_[comm.hlen + 3];
1148
 
1148
 
1149
                    sendAllFuncTimer(comm.data.blinkMessage);
1149
                    sendAllFuncTimer(comm.data.blinkMessage);
1150
/*                        if (callback)
-
 
1151
                        callback(comm);
-
 
1152
                    else
-
 
1153
                        MSG_WARNING("Missing callback function!"); */
1150
                    sendAllFuncNetwork(mLastOnlineState == NSTATE_ONLINE ? NSTATE_ONLINE1 : NSTATE_ONLINE);
1154
                break;
1151
                break;
1155
            }
1152
            }
1156
        break;
1153
        break;
1157
 
1154
 
1158
        default:        // Every unknown or unsupported command/request should be ignored.
1155
        default:        // Every unknown or unsupported command/request should be ignored.
Line 2722... Line 2719...
2722
 
2719
 
2723
void TAmxNet::sendAllFuncNetwork(int state)
2720
void TAmxNet::sendAllFuncNetwork(int state)
2724
{
2721
{
2725
    DECL_TRACER("TAmxNet::sendAllFuncNetwork(int state)");
2722
    DECL_TRACER("TAmxNet::sendAllFuncNetwork(int state)");
2726
 
2723
 
-
 
2724
    mLastOnlineState = state;
-
 
2725
 
2727
    if (mFuncsNetwork.empty())
2726
    if (mFuncsNetwork.empty())
2728
        return;
2727
        return;
2729
 
2728
 
2730
    MSG_DEBUG("Setting network state to " << state);
2729
    MSG_DEBUG("Setting network state to " << state);
2731
    map<ulong, FUNC_NETWORK_t>::iterator iter;
2730
    map<ulong, FUNC_NETWORK_t>::iterator iter;