void timer_cycle(timer_t* timer, memory_bus_t* bus, interrupt_controller_t* ic) { //timer register manipulation here //FIXME: figure out what I want to do with the timer-specific //registers: should I decode them "by hand" or just stick everything in //a lookup table? if(CHECK_BIT_CLEAR(timer->control_bits, TIMER_ON_BIT)) return; uint32_t previous_timer_value = timer->timer_value; tick(timer); if(timer->timer_value < previous_timer_value) { beacon(); update_timer_overflow_status(timer); update_interrupt_status(timer, ic); } }
DiscoveryBeacon DiscoveryAgent::obtainBeacon() const { DiscoveryBeacon::Protocol version; switch (_config.version()) { case 2: version = DiscoveryBeacon::DISCO_VERSION_01; break; case 1: version = DiscoveryBeacon::DISCO_VERSION_00; break; case 0: IBRCOMMON_LOGGER_TAG("DiscoveryAgent", info) << "DTN2 compatibility mode" << IBRCOMMON_LOGGER_ENDL; version = DiscoveryBeacon::DTND_IPDISCOVERY; break; }; DiscoveryBeacon beacon(version, dtn::core::BundleCore::local); return beacon; }
bool BeaconLoader::sendBeacon(LocalFrame* frame, int allowance, const KURL& beaconURL, Blob* data, int& payloadLength) { BeaconData<decltype(data)> beacon(data); return Sender::send(frame, allowance, beaconURL, beacon, payloadLength); }
bool BeaconLoader::sendBeacon(LocalFrame* frame, int allowance, const KURL& beaconURL, PassRefPtr<DOMArrayBufferView> data, int& payloadLength) { BeaconData<decltype(data)> beacon(data); return Sender::send(frame, allowance, beaconURL, beacon, payloadLength); }
void init() { set_and_wait(ma.mode.enable); set_and_wait(bufman.mode.enable); cpmu.control.hide_pcie_function = 7; cpmu.megabit_policy.mac_clock_switch = 0; cpmu.link_aware_policy.mac_clock_switch = 0; cpmu.d0u_policy.mac_clock_switch = 0; cpmu.link_idle_policy.mac_clock_switch = 0; cpmu.no_link_or_10mb_policy.mac_clock_switch = 0; rxcpu.mode.icache_pref_en = 1; grc.rxcpu_event.word = 0xffffffff; grc.rxcpu_event.word = 0; grc.fastboot_pc.addr = 0x8008000; grc.fastboot_pc.enable = 1; grc.rxcpu_event_enable.word = 0; grc.rxcpu_event_enable.emac = 1; if (gencomm[0] == 0x4b657654) state.flags |= HANDSHAKE_MAGIC_SEEN; else state.flags &= ~HANDSHAKE_MAGIC_SEEN; grc.misc_config.timer_prescaler = 0x7f; grc.power_management_debug.perst_override = 1; if (config.flags & CLOAK_EN) cloak_engage(); if (config.flags & LOCAL_CTRL) { cfg_port.bar_ctrl.bar0_sz = 1; lgate_setup(); } else { cfg_port.bar_ctrl.bar0_sz = 0; } cfg_port.bar_ctrl.rom_bar_sz = 0x6; grc.exp_rom_addr.base = read_nvram(0x1c); if (config.flags & OPROM_EN) pci.state.rom_enable = 1; ftq.reset.word = 0xffffffff; ftq.reset.word = 0; while (ftq.reset.word); emac.mode.port_mode = 2; set_and_wait(emac.mode.en_fhde); set_and_wait(emac.mode.en_rde); set_and_wait(emac.mode.en_tde); emac.mode.magic_packet_detection = 1; emac.mode.keep_frame_in_wol = 1; emac.event_enable.link_state_changed = 1; emac.rx_mac_mode.promiscuous_mode = 1; emac.tx_mac_mode.enable_bad_txmbuf_lockup_fix = 1; emac.tx_mac_lengths.slot = 0x20; emac.tx_mac_lengths.ipg_crs = 0x2; emac.tx_mac_lengths.ipg = 0x6; emac.mii_mode.enable_constant_mdc_clock_speed = 1; emac.mii_mode.phy_address = 1; emac.mii_mode.mii_clock_count = 0xb; set_and_wait(emac.tx_mac_mode.enable); set_and_wait(emac.rx_mac_mode.enable); wdma.mode.write_dma_pci_target_abort_attention_enable = 1; wdma.mode.write_dma_pci_master_abort_attention_enable = 1; wdma.mode.write_dma_pci_parity_error_attention_enable = 1; wdma.mode.write_dma_pci_host_address_overflow_error_attention_enable = 1; wdma.mode.write_dma_pci_fifo_overrun_attention_enable = 1; wdma.mode.write_dma_pci_fifo_underrun_attention_enable = 1; wdma.mode.write_dma_pci_fifo_overwrite_attention_enable = 1; set_and_wait(wdma.mode.enable); rdma.mode.read_dma_pci_target_abort_attention_enable = 1; rdma.mode.read_dma_pci_master_abort_attention_enable = 1; rdma.mode.read_dma_pci_parity_error_attention_enable = 1; rdma.mode.read_dma_pci_host_address_overflow_error_attention_enable = 1; rdma.mode.read_dma_pci_fifo_overrun_attention_enable = 1; rdma.mode.read_dma_pci_fifo_underrun_attention_enable = 1; rdma.mode.read_dma_pci_fifo_overread_attention_enable = 1; rdma.mode.read_dma_local_memory_write_longer_than_dma_length_attention_enable = 1; rdma.mode.jumbo_2k_mmrr_mode = 1; rdma.mode.hardware_ipv6_post_dma_processing_enable = 0; rdma.mode.in_band_vtag_enable = 0; rdma.mode.post_dma_debug_enable = 1; set_and_wait(rdma.mode.enable); set_and_wait(hc.mode.enable); nv_load_mac(state.my_mac); mac_cpy(state.my_mac, (void *)0xc0000412); gencomm[0] = 0xb49a89ab; pci.command.bus_master = 1; if (config.flags & PEER_CTRL) rx_setup(); if (config.flags & BEACON_EN) beacon(); check_link(); main(); }
void DiscoveryAgent::onAdvertise() { // check if announcements are enabled if (!_enabled) return; IBRCOMMON_LOGGER_DEBUG_TAG("DiscoveryAgent", 55) << "advertise discovery beacon" << IBRCOMMON_LOGGER_ENDL; DiscoveryBeacon::Protocol version; switch (_config.version()) { case 2: version = DiscoveryBeacon::DISCO_VERSION_01; break; case 1: version = DiscoveryBeacon::DISCO_VERSION_00; break; case 0: IBRCOMMON_LOGGER_TAG("DiscoveryAgent", info) << "DTN2 compatibility mode" << IBRCOMMON_LOGGER_ENDL; version = DiscoveryBeacon::DTND_IPDISCOVERY; break; }; DiscoveryBeacon beacon(version, dtn::core::BundleCore::local); // set sequencenumber beacon.setSequencenumber(_sn); ibrcommon::MutexLock l(_provider_lock); // get list for ANY interface const handler_list &any_list = _providers[_any_iface]; for (handler_map::const_iterator it_p = _providers.begin(); it_p != _providers.end(); ++it_p) { const ibrcommon::vinterface &iface = (*it_p).first; const handler_list &plist = (*it_p).second; // clear all services beacon.clearServices(); // collect services from providers if (!_config.shortbeacon()) { for (handler_list::const_iterator iter = plist.begin(); iter != plist.end(); ++iter) { DiscoveryBeaconHandler &handler = (**iter); try { // update service information handler.onUpdateBeacon(iface, beacon); } catch (const dtn::net::DiscoveryBeaconHandler::NoServiceHereException&) { } } // add service information for ANY interface if (iface != _any_iface) { for (handler_list::const_iterator iter = any_list.begin(); iter != any_list.end(); ++iter) { DiscoveryBeaconHandler &handler = (**iter); try { // update service information handler.onUpdateBeacon(iface, beacon); } catch (const dtn::net::DiscoveryBeaconHandler::NoServiceHereException&) { } } } } // broadcast announcement for (handler_list::const_iterator iter = plist.begin(); iter != plist.end(); ++iter) { DiscoveryBeaconHandler &handler = (**iter); // broadcast beacon handler.onAdvertiseBeacon(iface, beacon); } } // save the time of the last sent announcement _last_announce_sent = dtn::utils::Clock::getTime(); // increment sequencenumber _sn++; }
// // Main Routine // int main(void) { #ifdef DEBUG CSerial ser; // declare a UART object ser.enable(); CDebug dbg(ser); // Debug stream use the UART object dbg.start(); #endif // // SoftDevice // bleDevice ble; ble.attachEvent(onBleEvent); ble.enable(); // enable BLE SoftDevice task // GAP ble.m_gap.settings(DEVICE_NAME); // set Device Name on GAP bleServiceUriBeacon beacon(ble); // add uri beacon service switch ( beacon.get().tx_power_mode ) { case TX_POWER_MODE_LOWSET: ble.m_gap.tx_power(BLE_TX_m8dBm); break; case TX_POWER_MODE_LOW: ble.m_gap.tx_power(BLE_TX_m4dBm); break; case TX_POWER_MODE_MEDIUM: ble.m_gap.tx_power(BLE_TX_0dBm); break; case TX_POWER_MODE_HIGH: ble.m_gap.tx_power(BLE_TX_4dBm); break; } bleConnParams conn(ble); advertising_init(beacon_mode); // // Optional: Enable tickless technology // #ifndef DEBUG CPowerSave::tickless(true); #endif // // // CPin led0(LED_PIN_0); led0.output(); CPin led1(LED_PIN_1); led1.output(); CPin btn(BUTTON_PIN_0); btn.input(); // // Enter main loop. // while (1) { // // check button // if ( btn==LOW ) { led1 = LED_ON; // stop advertising ble.m_advertising.stop(); // change beacon mode if ( beacon_mode==beacon_mode_config ) { beacon_mode = beacon_mode_normal; } else { beacon_mode = beacon_mode_config; } // update mode and re-start the advertising advertising_init(beacon_mode); // waiting for btn released while(btn==LOW); led1 = LED_OFF; } // // LED Status // if ( beacon_mode==beacon_mode_config ) { // // Negotiate the "connection parameters update" in main-loop // conn.negotiate(); led0 = LED_ON; sleep(50); led0 = LED_OFF; sleep(150); } else { led0 = LED_ON; sleep(5); led0 = LED_OFF; sleep(beacon.get().beacon_period-5); } } }