void controller::handle_ctrl_char(cons::ctrl_char ch) { auto& window=view.get_selected_window(); const auto& buff=window.get_buffer(); auto first=begin(buffers), last=end(buffers); auto it=std::find_if(first, last, [&](const std::unique_ptr<buffer>& b) { return b.get()==&buff; } ); assert(it!=last); //is an actual existing buffer switch(ch) { default: break; case cons::ctrl_char::ctrl_arrow_left: if(it==first) it=last; --it; set_channel(**it); break; case cons::ctrl_char::ctrl_arrow_right: ++it; if(it==last) it=first; set_channel(**it); break; } }
int cmd_handler_mc1322x(const uint8_t *data, int len) { if(data[0] == '!') { if(data[1] == 'C') { printf("mc1322x_cmd: setting channel: %d\n", data[2]); set_channel(data[2]-11); return 1; } else if(data[1] == 'M') { printf("mc1322x_cmd: Got MAC\n"); memcpy(uip_lladdr.addr, data+2, sizeof(uip_lladdr.addr)); rimeaddr_set_node_addr((rimeaddr_t *) uip_lladdr.addr); return 1; } } else if(data[0] == '?') { if(data[1] == 'C') { uint8_t buf[4]; printf("mc1322x_cmd: getting channel: %d\n", data[2]); buf[0] = '!'; buf[1] = 'C'; //Not implemented in MACA driver buf[2] = 0; cmd_send(buf, 3); return 1; } } return 0; }
void do_chan(char * str_chan) { uint32_t channel; char * end; errno = 0; channel = strtoul(str_chan, &end, 0); if ((errno == ERANGE && (channel == LONG_MAX || channel == LONG_MIN)) || (errno != 0 && channel == 0)) { LOG("!!! please enter a valid channel number [0-9]\n"); return; } if (end == str_chan) { LOG("!!! please enter a valid channel number [0-9]\n"); return; } if (channel > 9) { LOG("!!! please enter a valid channel number [0-9]\n"); return; } cli.channel = channel; set_channel(cli.channel); }
void maca_init(void) { reset_maca(); radio_init(); flyback_init(); init_phy(); set_channel(0); /* things get weird if you never set a channel */ set_power(0); /* set the power too --- who knows what happens if you don't */ free_head = 0; tx_head = 0; rx_head = 0; rx_end = 0; tx_end = 0; dma_tx = 0; dma_rx = 0; free_all_packets(); #if DEBUG_MACA Print_Packets("maca_init"); #endif /* initial radio command */ /* nop, promiscuous, no cca */ *MACA_CONTROL = (prm_mode << PRM) | (NO_CCA << MACA_MODE); enable_irq(MACA); *INTFRC = (1 << INT_NUM_MACA); }
void do_ppscan(uint8_t * RFPI) { LOG("### trying to sync on %.2x %.2x %.2x %.2x %.2x\n", RFPI[0], RFPI[1], RFPI[2], RFPI[3], RFPI[4] ); /* set sync sniff mode */ uint16_t val; val = COA_MODE_SNIFF | COA_SUBMODE_SNIFF_SYNC; if (ioctl(cli.fd, COA_IOCTL_MODE, &val)) { LOG("!!! couldn't ioctl()\n"); exit(1); } /* set rfpi to sync with */ if(ioctl(cli.fd, COA_IOCTL_SETRFPI, RFPI)) { LOG("!!! couldn't ioctl()\n"); exit(1); } set_channel(cli.channel); memcpy(cli.RFPI, RFPI, 5); cli.mode = MODE_PPSCAN; cli.autorec_last_bfield = time(NULL); }
void sniffer_init_sniff_sync(struct coa_info *dev) { volatile uint16_t *sc14421_base = dev->sc14421_base; /* printk("loading sniff_sync firmware"); */ SC14421_switch_to_bank(sc14421_base, SC14421_DIPSTOPPED | SC14421_CODEBANK); switch(dev->radio_type) { case COA_RADIO_TYPE_II: /* printk(" for type II\n"); */ to_dip(sc14421_base, sc14421_II_sniff_sync_fw, ARRAY_SIZE(sc14421_II_sniff_sync_fw)); break; case COA_RADIO_TYPE_III: /* printk(" for type III\n"); */ to_dip(sc14421_base, sc14421_III_sniff_sync_fw, ARRAY_SIZE(sc14421_III_sniff_sync_fw)); break; default: printk("ERROR: this radio type is currently not " "supported. please update the driver\n"); } /* printk("clear interrupt\n"); */ SC14421_clear_interrupt(sc14421_base); set_channel(dev, dev->sniffer_config->channel, -1, -1, SC14421_DIPSTOPPED, SC14421_RAMBANK1); dev->sniffer_config->status = 0; sniffer_clear_slottable(dev->sniffer_config->slottable); /* printk("starting dip\n"); */ SC14421_switch_to_bank(sc14421_base, SC14421_RAMBANK0); }
bool phy_translate_and_set_settings(uint8_t spectrum_id, uint8_t sync_word_class) { if (previous_spectrum_id == spectrum_id && previous_sync_word_class == sync_word_class) return true; Strobe(RF_SIDLE); if(!phy_translate_settings(spectrum_id, sync_word_class, &fec, &channel_center_freq_index, &channel_bandwidth_index, &preamble_size, &sync_word)) { #ifdef LOG_PHY_ENABLED log_print_stack_string(LOG_PHY, "PHY Cannot translate settings"); #endif return false; } set_channel(channel_center_freq_index, channel_bandwidth_index); set_preamble_size(preamble_size); set_sync_word(sync_word); previous_spectrum_id = spectrum_id; previous_sync_word_class = sync_word_class; return true; }
int change_channel(int channel) { int skfd = 0, ret_val = 0; struct iwreq wrq; memset((void *) &wrq, 0, sizeof(struct iwreq)); /* Open NET socket */ if((skfd = iw_sockets_open()) < 0) { perror("iw_sockets_open"); } else if(get_iface()) { /* Convert channel to a frequency */ iw_float2freq((double) channel, &(wrq.u.freq)); /* Fixed frequency */ wrq.u.freq.flags = IW_FREQ_FIXED; cprintf(VERBOSE, "[+] Switching %s to channel %d\n", get_iface(), channel); /* Set frequency */ if(iw_set_ext(skfd, get_iface(), SIOCSIWFREQ, &wrq) >= 0) { set_channel(channel); ret_val = 1; } iw_sockets_close(skfd); } return ret_val; }
/* * Waits for a beacon packet from the target AP and populates the globule->ap_capabilities field. * This is used for obtaining the capabilities field and AP SSID. */ void read_ap_beacon() { struct pcap_pkthdr header; const unsigned char *packet = NULL; struct radio_tap_header *rt_header = NULL; struct dot11_frame_header *frame_header = NULL; struct beacon_management_frame *beacon = NULL; int channel = 0; size_t tag_offset = 0; time_t start_time = 0; set_ap_capability(0); start_time = time(NULL); while(get_ap_capability() == 0) { packet = next_packet(&header); if(packet == NULL) { break; } if(header.len >= MIN_BEACON_SIZE) { rt_header = (struct radio_tap_header *) radio_header(packet, header.len); size_t rt_header_len = end_le16toh(rt_header->len); frame_header = (struct dot11_frame_header *) (packet + rt_header_len); if(is_target(frame_header)) { if((frame_header->fc & end_htole16(IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) == end_htole16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON)) { beacon = (struct beacon_management_frame *) (packet + rt_header_len + sizeof(struct dot11_frame_header)); set_ap_capability(end_le16toh(beacon->capability)); /* Obtain the SSID and channel number from the beacon packet */ tag_offset = rt_header_len + sizeof(struct dot11_frame_header) + sizeof(struct beacon_management_frame); channel = parse_beacon_tags(packet, header.len); /* If no channel was manually specified, switch to the AP's current channel */ if(!get_fixed_channel() && get_auto_channel_select() && channel > 0 && channel != get_channel()) { change_channel(channel); set_channel(channel); } break; } } } /* If we haven't seen any beacon packets from the target within BEACON_WAIT_TIME seconds, try another channel */ if((time(NULL) - start_time) >= BEACON_WAIT_TIME) { next_channel(); start_time = time(NULL); } } }
void main(void) { volatile packet_t *p; volatile uint8_t t=20; uint8_t chan; char c; gpio_data(0); gpio_pad_dir_set( 1ULL << LED ); /* read from the data register instead of the pad */ /* this is needed because the led clamps the voltage low */ gpio_data_sel( 1ULL << LED); /* trim the reference osc. to 24MHz */ trim_xtal(); uart_init(UART1, 115200); vreg_init(); maca_init(); /* sets up tx_on, should be a board specific item */ *GPIO_FUNC_SEL2 = (0x01 << ((44-16*2)*2)); gpio_pad_dir_set( 1ULL << 44 ); set_power(0x0f); /* 0dbm */ chan = 0; set_channel(chan); /* channel 11 */ *MACA_MACPANID = 0xaaaa; *MACA_MAC16ADDR = 0x1111; *MACA_TXACKDELAY = 68; /* 68 puts the tx ack at about the correct spot */ set_prm_mode(AUTOACK); print_welcome("rftest-rx"); while(1) { /* call check_maca() periodically --- this works around */ /* a few lockup conditions */ check_maca(); if((p = rx_packet())) { /* print and free the packet */ printf("autoack-rx --- "); print_packet(p); maca_free_packet(p); } if(uart1_can_get()) { c = uart1_getc(); if(c == 'z') t++; if(c == 'x') t--; *MACA_TXACKDELAY = t; printf("tx ack delay: %d\n\r", t); } } }
void platform_radio_init(void) { LOG6LBR_INFO("Setting channel %d\n", nvm_data.channel); set_channel(nvm_data.channel - 11); radio_ready = 1; radio_mac_addr_ready = 1; }
unsigned NRF24L01::read_power_detector(uint_fast8_t channel) { write_reg(R_CONFIG, R_CONFIG_PWR_UP | R_CONFIG_PRIM_RX); set_channel(channel); ce = 1; delay_us(200); //minimum = 170 ce = 0; return read_reg(R_RPD); }
/* * Waits for a beacon packet from the target AP and populates the globule->ap_capabilities field. * This is used for obtaining the capabilities field and AP SSID. */ void read_ap_beacon() { struct pcap_pkthdr header; const u_char *packet = NULL; struct radio_tap_header *rt_header = NULL; struct dot11_frame_header *frame_header = NULL; struct beacon_management_frame *beacon = NULL; int channel = 0; time_t start_time = 0; set_ap_capability(0); start_time = time(NULL); while(get_ap_capability() == 0) { packet = next_packet(&header); if(packet == NULL) { break; } if(header.len >= MIN_BEACON_SIZE) { rt_header = (struct radio_tap_header *) radio_header(packet, header.len); frame_header = (struct dot11_frame_header *) (packet + rt_header->len); if(is_target(frame_header)) { if(frame_header->fc.type == MANAGEMENT_FRAME && frame_header->fc.sub_type == SUBTYPE_BEACON) { beacon = (struct beacon_management_frame *) (packet + rt_header->len + sizeof(struct dot11_frame_header)); set_ap_capability(beacon->capability); /* Obtain the SSID and channel number from the beacon packet */ channel = parse_beacon_tags(packet, header.len); /* If no channel was manually specified, switch to the AP's current channel */ if(!get_fixed_channel() && get_auto_channel_select() && channel > 0 && channel != get_channel()) { change_channel(channel); set_channel(channel); } break; } } } /* If we haven't seen any beacon packets from the target within BEACON_WAIT_TIME seconds, try another channel */ if((time(NULL) - start_time) >= BEACON_WAIT_TIME) { next_channel(); start_time = time(NULL); } } }
void controller::handle_connection_connect( std::shared_ptr<irc::connection> connection, std::string nick, std::string username, std::string fullname) { assert(connection && "can not craete sesion with invalid connection"); sessions.push_back( util::make_unique<irc::session>( std::move(connection), std::move(nick), std::move(username), std::move(fullname)) ); auto& session=sessions.back(); auto sess_win=util::make_unique<session_buffer>(*session); buffers.push_back(std::move(sess_win)); set_channels(); //if auto change set_channel(*buffers.back()); //this will create a new buffer view session->connect_on_join_channel( std::bind( &controller::handle_session_join_channel, this, ph::_1 ) ); // ne need to register all users so we can hook // any priv_msgs session->connect_on_new_user( [&](irc::user& u) { u.connect_on_direct_message( [](irc::user& u, const std::string&) { //TODO implement privmsg here } ); /* Currently this functionality is in session buffer u.connect_on_notice( [&](irc::user& u, const std::string& msg) { auto& status_buf=get_status_buffer(); std::ostringstream oss; oss << "NOTICE: " << u.get_nick() << ": " << msg; status_buf.push_back_msg(oss.str()); } ); */ } ); #ifdef USING_PYTHON python_controller.accept_new_session(*session); #endif //USING_PYTHON }
/*---------------------------------------------------------------------------*/ static radio_result_t set_value(radio_param_t param, radio_value_t value) { switch(param) { case RADIO_PARAM_POWER_MODE: if(value == RADIO_POWER_MODE_ON) { on(); return RADIO_RESULT_OK; } if(value == RADIO_POWER_MODE_OFF) { off(); return RADIO_RESULT_OK; } return RADIO_RESULT_INVALID_VALUE; case RADIO_PARAM_CHANNEL: if(value < CC2538_RF_CHANNEL_MIN || value > CC2538_RF_CHANNEL_MAX) { return RADIO_RESULT_INVALID_VALUE; } if(set_channel(value) == CC2538_RF_CHANNEL_SET_ERROR) { return RADIO_RESULT_ERROR; } return RADIO_RESULT_OK; case RADIO_PARAM_PAN_ID: set_pan_id(value & 0xffff); return RADIO_RESULT_OK; case RADIO_PARAM_16BIT_ADDR: set_short_addr(value & 0xffff); return RADIO_RESULT_OK; case RADIO_PARAM_RX_MODE: if(value & ~(RADIO_RX_MODE_ADDRESS_FILTER | RADIO_RX_MODE_AUTOACK)) { return RADIO_RESULT_INVALID_VALUE; } set_frame_filtering((value & RADIO_RX_MODE_ADDRESS_FILTER) != 0); set_auto_ack((value & RADIO_RX_MODE_AUTOACK) != 0); return RADIO_RESULT_OK; case RADIO_PARAM_TXPOWER: if(value < OUTPUT_POWER_MIN || value > OUTPUT_POWER_MAX) { return RADIO_RESULT_INVALID_VALUE; } set_tx_power(value); return RADIO_RESULT_OK; case RADIO_PARAM_CCA_THRESHOLD: set_cca_threshold(value); return RADIO_RESULT_OK; default: return RADIO_RESULT_NOT_SUPPORTED; } }
void init_lowlevel(void) { /* button init */ /* set up kbi */ enable_irq_kbi(4); kbi_edge(4); enable_ext_wu(4); // kbi_pol_neg(7); // kbi_pol_pos(7); // gpio_sel0_pullup(29); // gpio_pu0_disable(29); trim_xtal(); /* uart init */ uart_init(BRINC, BRMOD, SAMP); default_vreg_init(); maca_init(); set_channel(RF_CHANNEL - 11); /* channel 11 */ set_power(0x12); /* 0x12 is the highest, not documented */ enable_irq(CRM); #if USE_32KHZ_XTAL enable_32khz_xtal(); #else cal_ring_osc(); #endif #if USE_32KHZ_XTAL *CRM_RTC_TIMEOUT = 32768 * 10; #else *CRM_RTC_TIMEOUT = cal_rtc_secs * 10; #endif #if (USE_WDT == 1) /* set the watchdog timer timeout to 1 sec */ cop_timeout_ms(WDT_TIMEOUT); /* enable the watchdog timer */ CRM->COP_CNTLbits.COP_EN = 1; #endif /* XXX debug */ /* trigger periodic rtc int */ // clear_rtc_wu_evt(); // enable_rtc_wu(); // enable_rtc_wu_irq(); }
void cycle_channel(struct vd_video *vd) { // increments channel static int cur_chan=0; struct video_channel l_chan; if (cur_chan == vd->grab_cap.channels) cur_chan=0; l_chan.channel=vd->channel=cur_chan; set_channel(vd); cur_chan++; }
void controller::handle_session_join_channel(irc::channel& chan) { chan.connect_on_channel_part( [&](irc::channel& chand) { auto it=std::find_if(begin(buffers), end(buffers), [&](const std::unique_ptr<buffer>& b) { assert(b); has_channel hc { *b }; return &hc.get_channel() == &chan; } ); if(it!=end(buffers)) { buffers.erase(it); set_channels(); set_channel(get_status_buffer()); } } ); buffers.push_back(util::make_unique<channel_buffer>(chan)); set_channels(); set_channel(*buffers.back()); }
void do_callscan(void) { LOG("### starting callscan\n"); uint16_t val; val = COA_MODE_SNIFF | COA_SUBMODE_SNIFF_SCANPP; if (ioctl(cli.fd, COA_IOCTL_MODE, &val)) { LOG("!!! couldn't ioctl()\n"); exit(1); } /* set start channel */ set_channel(cli.channel); cli.mode = MODE_CALLSCAN; }
/** \brief main loop to run tests. * * The tests being run are described in the documentation of this file. * * \return never returns, test loop runs ad infinitum. */ int main(void) { uint8_t switch_mask = 0x00; // Input switches. Read hi when pressed uint16_t result = 0; SR_t shift_reg; /* call all of the setup_* functions */ cli(); setup_clocks(); setup_LEDs(); setup_switches(switch_mask); setup_SR(&shift_reg, &SR_PORT, &SR_SPI_MODULE, false); setup_ADC(&ADC_PORT, &ADC_SPI_MODULE, ADC_CONVST_bm, ADC_EOC_bm, ADC_callback); setup_USART_BC(); sei(); set_channel(MPx, 15, &shift_reg); set_channel(MPy, 15, &shift_reg); /* signal debugging */ PORTD.DIRCLR |= PIN4_bm; PORTD.PIN4CTRL = PORT_OPC_PULLDOWN_gc; while (1) { if (ADC_ready(&adc)) { // get a new conversion result result = ADC_sample_once(&adc); } if (PORTD.IN & PIN4_bm) { LED_PORT.OUT = 0xFF; } else { LED_PORT.OUT = (uint8_t)(result >> 4); printf("%u ", result); } } }
void Syslink::update_params(bool force_set) { param_t _param_radio_channel = param_find("SLNK_RADIO_CHAN"); param_t _param_radio_rate = param_find("SLNK_RADIO_RATE"); param_t _param_radio_addr1 = param_find("SLNK_RADIO_ADDR1"); param_t _param_radio_addr2 = param_find("SLNK_RADIO_ADDR2"); // reading parameter values into temp variables int32_t channel, rate, addr1, addr2; uint64_t addr = 0; param_get(_param_radio_channel, &channel); param_get(_param_radio_rate, &rate); param_get(_param_radio_addr1, &addr1); param_get(_param_radio_addr2, &addr2); memcpy(&addr, &addr2, 4); memcpy(((char *)&addr) + 4, &addr1, 4); hrt_abstime t = hrt_absolute_time(); // request updates if needed if (channel != this->_channel || force_set) { this->_channel = channel; set_channel(channel); this->_params_update[0] = t; this->_params_ack[0] = 0; } if (rate != this->_rate || force_set) { this->_rate = rate; set_datarate(rate); this->_params_update[1] = t; this->_params_ack[1] = 0; } if (addr != this->_addr || force_set) { this->_addr = addr; set_address(addr); this->_params_update[2] = t; this->_params_ack[2] = 0; } }
void LoginRequest::MergeFrom(const LoginRequest& from) { GOOGLE_CHECK_NE(&from, this); if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { if (from.has_wb_uuid()) { set_wb_uuid(from.wb_uuid()); } if (from.has_channel()) { set_channel(from.channel()); } if (from.has_version()) { set_version(from.version()); } } }
void do_fpscan(void) { LOG("### starting fpscan\n"); uint16_t val; val = COA_MODE_SNIFF | COA_SUBMODE_SNIFF_SCANFP; if (ioctl(cli.fd, COA_IOCTL_MODE, &val)) { LOG("!!! couldn't ioctl()\n"); exit(1); } /* set start channel */ set_channel(cli.channel); cli.mode = MODE_FPSCAN; cli.autorec = 0; }
/*---------------------------------------------------------------------------*/ static radio_result_t set_value(radio_param_t param, radio_value_t value) { switch(param) { case RADIO_PARAM_POWER_MODE: if(value == RADIO_POWER_MODE_ON) { on(); return RADIO_RESULT_OK; } if(value == RADIO_POWER_MODE_OFF) { off(); return RADIO_RESULT_OK; } return RADIO_RESULT_INVALID_VALUE; case RADIO_PARAM_CHANNEL: if(value < 11 || value > 26) { return RADIO_RESULT_INVALID_VALUE; } set_channel(value); return RADIO_RESULT_OK; case RADIO_PARAM_RX_MODE: if(value & ~(RADIO_RX_MODE_ADDRESS_FILTER | RADIO_RX_MODE_AUTOACK | RADIO_RX_MODE_POLL_MODE)) { return RADIO_RESULT_INVALID_VALUE; } set_frame_filtering((value & RADIO_RX_MODE_ADDRESS_FILTER) != 0); set_autoack((value & RADIO_RX_MODE_AUTOACK) != 0); set_poll_mode((value & RADIO_RX_MODE_POLL_MODE) != 0); return RADIO_RESULT_OK; case RADIO_PARAM_TX_MODE: if(value & ~(RADIO_TX_MODE_SEND_ON_CCA)) { return RADIO_RESULT_INVALID_VALUE; } set_send_on_cca((value & RADIO_TX_MODE_SEND_ON_CCA) != 0); return RADIO_RESULT_OK; case RADIO_PARAM_TXPOWER: if(value < OUTPUT_POWER_MIN || value > OUTPUT_POWER_MAX) { return RADIO_RESULT_INVALID_VALUE; /* Find the closest higher PA_LEVEL for the desired output power */ } set_txpower(value); return RADIO_RESULT_OK; case RADIO_PARAM_CCA_THRESHOLD: cca_thershold = value; return RADIO_RESULT_OK; default: return RADIO_RESULT_NOT_SUPPORTED; } }
static void tx_thread(void) { SYS_LOG_DBG("Tx thread started"); while (1) { uint8_t cmd; struct net_buf *pkt, *buf; pkt = net_buf_get(&tx_queue, K_FOREVER); buf = net_buf_frag_last(pkt); cmd = net_buf_pull_u8(buf); hexdump(">", buf->data, buf->len); switch (cmd) { case RESET: SYS_LOG_DBG("Reset device"); break; case TX: tx(pkt); break; case START: start(); break; case STOP: stop(); break; case SET_CHANNEL: set_channel(buf->data, buf->len); break; case SET_IEEE_ADDR: set_ieee_addr(buf->data, buf->len); break; case SET_SHORT_ADDR: set_short_addr(buf->data, buf->len); break; case SET_PAN_ID: set_pan_id(buf->data, buf->len); break; default: SYS_LOG_ERR("%x: Not handled for now", cmd); break; } net_nbuf_unref(pkt); k_yield(); } }
int change_channel(int channel) { cprintf(VERBOSE, "[+] Switching %s to channel %d\n", get_iface(), channel); // Unfortunately, there is no API to change the channel pid_t pid = fork(); if (!pid) { char chan_arg[32]; sprintf(chan_arg, "-c%d", channel); char* argv[] = {"/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport", chan_arg, NULL}; execve("/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport", argv, NULL); } int status; waitpid(pid,&status,0); set_channel(channel); return 0; }
NRF24L01P::NRF24L01P(uint16_t net, uint8_t dev, Board::DigitalPin csn, Board::DigitalPin ce, Board::ExternalInterruptPin irq) : SPI::Driver(csn, SPI::ACTIVE_LOW, SPI::DIV4_CLOCK, 0, SPI::MSB_ORDER, &m_irq), Wireless::Driver(net, dev), m_ce(ce, 0), m_irq(irq, ExternalInterrupt::ON_FALLING_MODE, this), m_status(0), m_state(POWER_DOWN_STATE), m_trans(0), m_retrans(0), m_drops(0) { set_channel(64); }
static void process_config(struct net_pkt *pkt) { struct net_buf *buf = net_buf_frag_last(pkt->frags); u8_t cmd = net_buf_pull_u8(buf); SYS_LOG_DBG("Process config %c", cmd); switch (cmd) { case 'S': process_data(pkt); break; case 'C': set_channel(net_buf_pull_u8(buf)); break; default: SYS_LOG_ERR("Unhandled cmd %u", cmd); } }
bool update(const char * field, std::vector<uint8_t> data) { if (!strcmp(field, "dlpkt")) { return delete_packet(data); } else if (!strcmp(field, "dlcha")) { return delete_channel(data); } else if (!strcmp(field, "pnum")) { return set_pnumber(data); } else if (!strcmp(field, "chan")) { return set_channel(data); } else if (!strcmp(field, "pol")) { set_poll(data); } else if (!strcmp(field, "dir")) { const char * dirStr = byteVec2cstr(data); if (!strcmp(dirStr, "pos")) set_direction(DIR_POS); else if (!strcmp(dirStr, "neg")) set_direction(DIR_NEG); else return false; } else if (!strcmp(field, "data")) { return set_current(data); } else if (!strcmp(field, "wait")) { set_delay(data); } else if (!strcmp(field, "send")) { flag_return = true; send_packets(); } else if (!strcmp(field, "reset")) { send_global_reset(); } else if (!strcmp(field, "glob")) { set_global(); } else if (!strcmp(field, "conn")) { flag_return = true; return connect_serial(); } else if (!strcmp(field, "exit")) { return exit(); } else if (!strcmp(field, "clrpks")) { clear_packets(); } else if (!strcmp(field, "prev")) { if (debug_) preview_packets(); preview_packet_bytes(); flag_return = true; } else { return false; } return true; }
static int vnt_config(struct ieee80211_hw *hw, u32 changed) { struct vnt_private *priv = hw->priv; struct ieee80211_conf *conf = &hw->conf; u8 bb_type; if (changed & IEEE80211_CONF_CHANGE_PS) { if (conf->flags & IEEE80211_CONF_PS) PSvEnablePowerSaving(priv, conf->listen_interval); else PSvDisablePowerSaving(priv); } if ((changed & IEEE80211_CONF_CHANGE_CHANNEL) || (conf->flags & IEEE80211_CONF_OFFCHANNEL)) { set_channel(priv, conf->chandef.chan); if (conf->chandef.chan->band == IEEE80211_BAND_5GHZ) bb_type = BB_TYPE_11A; else bb_type = BB_TYPE_11G; if (priv->byBBType != bb_type) { priv->byBBType = bb_type; CARDbSetPhyParameter(priv, priv->byBBType); } } if (changed & IEEE80211_CONF_CHANGE_POWER) { if (priv->byBBType == BB_TYPE_11B) priv->wCurrentRate = RATE_1M; else priv->wCurrentRate = RATE_54M; RFbSetPower(priv, priv->wCurrentRate, conf->chandef.chan->hw_value); } return 0; }