These CPS devices in smart healthcare systems are promoting personalized, efficient, and patient-centric healthcare practices. A generic layout of the smart healthcare CPS is described in Figure 1.  
CPSs are open to such attacks because the attackers try to take advantage of the integrated environment. Unauthorized access to a CPS is a serious threat because it opens the door for malicious actors to penetrate the network and impair system performance [14]. Similarly, the injection of fake data can deceive the system's decision-making procedures and jeopardize its integrity [15]. Additionally, malware, viruses, or ransomware disrupt the regular operation of CPSs [16]. As a result, devastating outcomes, including physical harm, financial losses, and sometimes even fatalities, can result from such attacks. Smart healthcare CPSs are significantly at risk from attacks on CPSs, especially blackhole and greyhole attacks [17]. Organizations can monitor user behavior and establish regular activities by using trust-based protection [18]. By swiftly isolating attackers and taking action, decision makers in a smart healthcare CPS may lessen the impact of security breaches and protect their systems and data [19]. Integrating timely security strategies is crucial to ensuring integrity and confidentiality [20; 21; 22]. To ensure the security and resilience of a CPS, robust detection and mitigation techniques must be utilized to identify and respond to prospective attacks effectively. Diverse strategies and technologies have been developed to detect and mitigate attacks against CPSs in an effort to protect their essential functions and preserve system integrity [23; 24; 25; 26; 27]. CPS security researchers are investigating cutting-edge detection and mitigation strategies, such as deep learning (DL) and artificial intelligence (AI) [27; 28], in addition to conventional IDS methods [29]. However, it is crucial to remember that detection alone is insufficient; to respond to identified attacks and lessen their effects on CPSs, appropriate mitigation methods must be in place. AI-based solutions are resource-hungry, and they may drain the limited resources of RPL-based networks [30]. To resolve the above issues, this paper presents an efficient detection method called Gini-index and blockchain-based Blackhole/Greyhole RPL (GBG-RPL) for timely detection and mitigation of blackhole and greyhole attacker nodes while focusing on the characteristics of Low-power Lossy Networks (LLNs). The proposed framework utilizes the  
Figure 1: Smart healthcare cyber-physical systems. Gini index to analyze data distribution, enabling real-time detection of internal attacks. Additionally, blockchain technology ensures data integrity through immutability, smart contracts, and decentralized features, mitigating single points of failure (SPOF) and ensuring scalability. The integration of the Gini index and blockchain strengthens the system's capacity to identify and isolate malicious nodes, contributing to improved network resilience against potential blackhole and greyhole attacks. The framework ensures the integrity and reliability of healthcare data, building confidence among patients, healthcare professionals, and stakeholders. The GBG-RPL technique provides accurate detection and isolation of the attacker nodes by utilizing the Gini index to calculate the trust values of each node. Furthermore, all trust calculations, along with blockchain implementation, have been shifted to fog nodes at the fog layer, which further contributes to the efficiency of the smart healthcare system. Thus, the application of the proposed framework in smart healthcare systems would add to the security and efficacy of smart healthcare services. In part Abbreviation we defines the abbreviations used in this paper. The salient contributions of this research are as follows:  
1. A layered trust framework is proposed to mitigate SPOF and improve the overheads related to messages, energy, and computations in smart healthcare CPSs. 2.