@@ -586,9 +586,10 @@ struct AdvertisingStartEvent {
586
586
/* * Create an advertising start event.
587
587
*
588
588
* @param advHandle Advertising set handle.
589
+ * @param status Advertising set start command status.
589
590
*/
590
- AdvertisingStartEvent (advertising_handle_t advHandle) :
591
- advHandle(advHandle)
591
+ AdvertisingStartEvent (advertising_handle_t advHandle, ble_error_t status = BLE_ERROR_NONE ) :
592
+ advHandle(advHandle), status(status)
592
593
{
593
594
}
594
595
@@ -600,8 +601,15 @@ struct AdvertisingStartEvent {
600
601
return advHandle;
601
602
}
602
603
604
+ /* * Get status of operation. */
605
+ ble_error_t getStatus () const
606
+ {
607
+ return status;
608
+ }
609
+
603
610
private:
604
611
advertising_handle_t advHandle;
612
+ ble_error_t status;
605
613
};
606
614
607
615
/* *
@@ -610,29 +618,38 @@ struct AdvertisingStartEvent {
610
618
* @see ble::Gap::EventHandler::onAdvertisingEnd().
611
619
*
612
620
* @note The connection handle, connected flag and completed_event fields are
613
- * valid if the flag legacy is not set to true.
621
+ * valid if the flag legacy is not set to true. If status is different from BLE_ERROR_NONE
622
+ * the completed_events field is not valid and the set may still be active.
614
623
*/
615
624
struct AdvertisingEndEvent {
616
625
#if !defined(DOXYGEN_ONLY)
617
626
618
627
/* * Create an extended advertising end event.
619
628
*
620
629
* @param advHandle Advertising set handle.
621
- * @param connection Connection handle.
622
- * @param completed_events Number of events created during before advertising end.
630
+ * @param connection Connection handle - only valid if connected is True.
631
+ * @param completed_events Number of events created during before advertising end - only valid
632
+ * if advertising end has been caused by BLE_ERROR_LIMIT_REACHED, not the local user.
633
+ * Check getStatus().
623
634
* @param connected True if connection has been established.
635
+ * @param status Error code showing the reason for event. BLE_ERROR_LIMIT_REACHED if set number
636
+ * of events have been reached. BLE_ERROR_TIMEOUT if set time has elapsed.
637
+ * BLE_ERROR_SUCCESS if connection occurred or user ended the set. Check isConnected()
638
+ * to determine which.
624
639
*/
625
640
AdvertisingEndEvent (
626
641
advertising_handle_t advHandle,
627
642
connection_handle_t connection,
628
643
uint8_t completed_events,
629
- bool connected
644
+ bool connected,
645
+ ble_error_t status = BLE_ERROR_NONE
630
646
) :
631
647
advHandle(advHandle),
632
648
connection(connection),
633
649
completed_events(completed_events),
634
650
connected(connected),
635
- legacy(false )
651
+ legacy(false ),
652
+ status(status)
636
653
{
637
654
}
638
655
@@ -643,7 +660,8 @@ struct AdvertisingEndEvent {
643
660
connection(),
644
661
completed_events(0 ),
645
662
connected(false ),
646
- legacy(true )
663
+ legacy(true ),
664
+ status(BLE_ERROR_NONE)
647
665
{
648
666
}
649
667
@@ -683,12 +701,20 @@ struct AdvertisingEndEvent {
683
701
return legacy;
684
702
}
685
703
704
+ /* * Get the result of the stop advertising event. If the status is not BLE_ERROR_NONE the set
705
+ * may still be active. */
706
+ ble_error_t getStatus () const
707
+ {
708
+ return status;
709
+ }
710
+
686
711
private:
687
712
advertising_handle_t advHandle;
688
713
connection_handle_t connection;
689
714
uint8_t completed_events;
690
715
bool connected;
691
716
bool legacy;
717
+ ble_error_t status;
692
718
};
693
719
694
720
/* *
0 commit comments