@@ -64,7 +64,8 @@ StatusManager::StatusManager(const ocpp::config::IChargePointConfig& sta
6464 m_msg_sender (msg_sender),
6565 m_registration_status (RegistrationStatus::Rejected),
6666 m_force_boot_notification (false ),
67- m_boot_notification_timer (timer_pool, " Boot notification" ),
67+ m_boot_notification_sent (false ),
68+ m_boot_notification_timer (timer_pool, " Boot notification" ),
6869 m_heartbeat_timer (timer_pool, " Heartbeat" )
6970{
7071 m_boot_notification_timer.setCallback ([this ] { m_worker_pool.run <void >(std::bind (&StatusManager::bootNotificationProcess, this )); });
@@ -400,58 +401,77 @@ bool StatusManager::handleMessage(const ocpp::messages::ChangeAvailabilityReq& r
400401
401402/* * @brief Boot notification process thread */
402403void StatusManager::bootNotificationProcess ()
403- {
404- // Fill boot notification request
405- BootNotificationReq boot_req;
406- boot_req. chargeBoxSerialNumber . value (). assign (m_stack_config. chargeBoxSerialNumber ());
407- boot_req. chargePointModel . assign (m_stack_config. chargePointModel ()) ;
408- boot_req.chargePointSerialNumber .value ().assign (m_stack_config.chargePointSerialNumber ());
409- boot_req.chargePointVendor .assign (m_stack_config.chargePointVendor ());
410- boot_req.firmwareVersion .value ().assign (m_stack_config.firmwareVersion ());
411- boot_req.iccid . value (). assign (m_stack_config.iccid ());
412- boot_req.imsi .value ().assign (m_stack_config.imsi ());
413- boot_req.meterSerialNumber .value ().assign (m_stack_config.meterSerialNumber ());
414-
415- m_registration_status = RegistrationStatus::Rejected ;
416- // Send BootNotificationRequest
417- BootNotificationConf boot_conf ;
418- CallResult result = m_msg_sender. call (BOOT_NOTIFICATION_ACTION, boot_req, boot_conf);
419- if (result == CallResult::Ok)
420- {
421- if (boot_conf. status == RegistrationStatus::Accepted )
404+ {
405+ if (m_boot_notification_sent == false )
406+ {
407+ // Fill boot notification request
408+ BootNotificationReq boot_req;
409+ boot_req.chargeBoxSerialNumber .value ().assign (m_stack_config.chargeBoxSerialNumber ());
410+ boot_req.chargePointModel .assign (m_stack_config.chargePointModel ());
411+ boot_req.chargePointSerialNumber .value ().assign (m_stack_config.chargePointSerialNumber ());
412+ boot_req.chargePointVendor . assign (m_stack_config.chargePointVendor ());
413+ boot_req.firmwareVersion .value ().assign (m_stack_config.firmwareVersion ());
414+ boot_req.iccid .value ().assign (m_stack_config.iccid ());
415+ boot_req. imsi . value (). assign (m_stack_config. imsi ());
416+ boot_req. meterSerialNumber . value (). assign (m_stack_config. meterSerialNumber ()) ;
417+
418+ m_registration_status = RegistrationStatus::Rejected ;
419+ // Send BootNotificationRequest
420+ BootNotificationConf boot_conf;
421+ CallResult result = m_msg_sender. call (BOOT_NOTIFICATION_ACTION, boot_req, boot_conf);
422+ if (result == CallResult::Ok )
422423 {
423- // Send first status notifications
424- for (unsigned int id = 0 ; id <= m_connectors.getCount (); id++)
424+ if (boot_conf.status == RegistrationStatus::Accepted)
425425 {
426- statusNotificationProcess (id);
426+ m_boot_notification_sent = true ;
427+ // Send first status notifications
428+ for (unsigned int id = 0 ; id <= m_connectors.getCount (); id++)
429+ {
430+ statusNotificationProcess (id);
431+ }
432+
433+ // Configure hearbeat
434+ std::chrono::seconds interval (boot_conf.interval );
435+ m_ocpp_config.heartbeatInterval (interval);
436+ m_heartbeat_timer.start (std::chrono::milliseconds (interval));
437+ }
438+ else
439+ {
440+ // Schedule next retry
441+ m_boot_notification_timer.start (std::chrono::seconds (boot_conf.interval ), true );
427442 }
428443
429- // Configure hearbeat
430- std::chrono::seconds interval (boot_conf.interval );
431- m_ocpp_config.heartbeatInterval (interval);
432- m_heartbeat_timer.start (std::chrono::milliseconds (interval));
444+ m_registration_status = boot_conf.status ;
445+ std::string registration_status = RegistrationStatusHelper.toString (m_registration_status);
446+ LOG_INFO << " Registration status : " << registration_status;
447+
448+ // Save registration status
449+ m_force_boot_notification = false ;
450+ m_internal_config.setKey (LAST_REGISTRATION_STATUS_KEY, registration_status);
451+
452+ // Notify boot
453+ m_events_handler.bootNotification (m_registration_status, boot_conf.currentTime );
433454 }
434455 else
435456 {
436457 // Schedule next retry
437- m_boot_notification_timer.start (std::chrono::seconds (boot_conf. interval ), true );
458+ m_boot_notification_timer.start (m_stack_config. retryInterval ( ), true );
438459 }
439-
440- m_registration_status = boot_conf.status ;
441- std::string registration_status = RegistrationStatusHelper.toString (m_registration_status);
442- LOG_INFO << " Registration status : " << registration_status;
443-
444- // Save registration status
445- m_force_boot_notification = false ;
446- m_internal_config.setKey (LAST_REGISTRATION_STATUS_KEY, registration_status);
447-
448- // Notify boot
449- m_events_handler.bootNotification (m_registration_status, boot_conf.currentTime );
450460 }
451461 else
452462 {
453- // Schedule next retry
454- m_boot_notification_timer.start (m_stack_config.retryInterval (), true );
463+ // If the status of a connector has changed since the last notification
464+ // to the central system, send the new connector status
465+ for (const Connector* connector : m_connectors.getConnectors ())
466+ {
467+ if (connector->status != connector->last_notified_status )
468+ {
469+ statusNotificationProcess (connector->id );
470+ }
471+ }
472+
473+ // Configure hearbeat
474+ m_heartbeat_timer.start (m_ocpp_config.heartbeatInterval ());
455475 }
456476}
457477
0 commit comments