Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 1 | /* |
| 2 | Copyright (C) 2018 Open Networking Foundation |
| 3 | |
| 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 |
| 6 | the Free Software Foundation, either version 3 of the License, or |
| 7 | (at your option) any later version. |
| 8 | |
| 9 | This program is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | #include <iostream> |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 18 | #include <unistd.h> |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 19 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 20 | #include "server.h" |
Shad Ansari | b7b0ced | 2018-05-11 21:53:32 +0000 | [diff] [blame] | 21 | #include "core.h" |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 22 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 23 | int main(int argc, char** argv) { |
| 24 | |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 25 | Status status = Enable_(argc, argv); |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 26 | if (!status.ok()) { |
| 27 | std::cout << "ERROR: Enable_ failed - " |
| 28 | << status.error_code() << ": " << status.error_message() |
| 29 | << std::endl; |
| 30 | return 1; |
| 31 | } |
| 32 | |
Craig Lutgen | 88a22ad | 2018-10-04 12:30:46 -0500 | [diff] [blame] | 33 | // Wait for successful activation before allowing VOLTHA to connect. |
| 34 | // This is necessary to allow the device topology to be dynamically |
| 35 | // queried from driver after initialization and activation is complete. |
| 36 | int maxTrials = 300; |
| 37 | while (!state.is_activated()) { |
| 38 | sleep(1); |
| 39 | if (--maxTrials == 0) { |
| 40 | std::cout << "ERROR: OLT/PON Activation failed" << std::endl; |
| 41 | return 1; |
| 42 | } |
| 43 | } |
| 44 | |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 45 | RunServer(); |
| 46 | |
Shad Ansari | 627b578 | 2018-08-13 22:49:32 +0000 | [diff] [blame] | 47 | return 0; |
Shad Ansari | 01b0e65 | 2018-04-05 21:02:53 +0000 | [diff] [blame] | 48 | } |