Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Android/tools/tools/rootcanal/model/setup/   (Android Betriebssystem Version 17©)  Datei vom 26.5.2026 mit Größe 2 kB image not shown  

Quelle  phy_layer.cc

  Sprache: C
 

/*
 * Copyright 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


#include "phy_layer.h"

#include <sstream>

namespace rootcanal {

PhyLayer::PhyLayer(Identifier id, Phy::Type type) : id(id), type(type) {}

void PhyLayer::Register(std::shared_ptr<PhyDevice> device) {
  device->Register(this);
  phy_devices_.push_back(device);
}

void PhyLayer::Unregister(PhyDevice::Identifier id) {
  for (auto& device : phy_devices_) {
    if (device->id == id) {
      device->Unregister(this);
      phy_devices_.remove(device);
      return;
    }
  }
}

void PhyLayer::UnregisterAll() {
  for (auto& device : phy_devices_) {
    device->Unregister(this);
  }
  phy_devices_.clear();
}

int8_t PhyLayer::ComputeRssi(PhyDevice::Identifier /*sender_id*/,
                             PhyDevice::Identifier /*receiver_id*/, int8_t /*tx_power*/) {
  // Perform no RSSI computation by default.
  // Clients overriding this function should use the TX power and
  // positional information to derive correct device-to-device RSSI.
  static uint8_t rssi = 0;
  rssi = (rssi + 5) % 128;
  return static_cast<int8_t>(-rssi);
}

void PhyLayer::Send(std::vector<uint8_t> const& packet, int8_t tx_power,
                    PhyDevice::Identifier sender_id) {
  for (const auto& device : phy_devices_) {
    // Do not send the packet back to the sender.
    if (sender_id != device->id) {
      device->Receive(packet, type, ComputeRssi(sender_id, device->id, tx_power));
    }
  }
}

void PhyLayer::Tick() {
  for (auto& device : phy_devices_) {
    device->Tick();
  }
}

std::string PhyLayer::ToString() const {
  std::stringstream factory;
  switch (type) {
    case Phy::Type::LOW_ENERGY:
      factory << "LOW_ENERGY: ";
      break;
    case Phy::Type::BR_EDR:
      factory << "BR_EDR: ";
      break;
    default:
      factory << "Unknown: ";
  }
  for (auto& device : phy_devices_) {
    factory << device->id;
    factory << ",";
  }

  return factory.str();
}

}  // namespace rootcanal

Messung V0.5 in Prozent
C=99 H=88 G=93

¤ Dauer der Verarbeitung: 0.9 Sekunden  (vorverarbeitet am  2026-06-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.