1 #include "usb_manager.hpp" 2 3 #include <CLI/CLI.hpp> 4 #include <phosphor-logging/lg2.hpp> 5 #include <sdeventplus/event.hpp> 6 7 int main(int argc, char** argv) 8 { 9 namespace fs = std::filesystem; 10 // Dbus constructs 11 auto bus = sdbusplus::bus::new_default(); 12 13 // Get a default event loop 14 auto event = sdeventplus::Event::get_default(); 15 16 std::string fileName{}; 17 18 CLI::App app{"Update the firmware of OpenBMC via USB app"}; 19 app.add_option("-f,--fileName", fileName, 20 "Get the name of the USB mount folder, eg: sda1, sdb1"); 21 22 CLI11_PARSE(app, argc, argv); 23 24 if (fileName.empty()) 25 { 26 lg2::error("The file name passed in is empty."); 27 return -1; 28 } 29 30 fs::path usbPath = fs::path{"/run/media/usb"} / fileName; 31 phosphor::usb::USBManager manager(bus, event, usbPath); 32 33 // Attach the bus to sd_event to service user requests 34 bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL); 35 event.loop(); 36 37 return 0; 38 } 39