Exemplo n.º 1
0
/* Repeater mode, for use with a standalone dev board */
void repeater_mode() {
  CLKCON = (1<<7) | (0<<6) | (0<<3) | (0<<0); //26MHz crystal oscillator for cpu and timer
  while (CLKCON & CLKCON_OSC);  //wait for clock stability
  
  P1DIR=0x03;   //LEDs on P1.1 and P1.0

#define LEDR P1_1
#define LEDG P1_0
  clock_delayms(100);

  radio_init();
  
  clock_delayms(100);

//    clear();
  while (1) {
    LEDR = 1; LEDG = 0;
  //  print_message(" ",2,0);
  //  print_message(" ",3,0);
  //  print_message("* Listening...        ",0,0);
    radio_listen();
    while (!radio_receive_poll(buf)) {
      clock_delayms(100);
      LEDG ^= 1;
  //    SSN = LOW;
  //    setCursor(0, 15*5);
  //    printf("%d %d %d", rf_packet_ix, rf_packet_n, rf_packet[0]); 
  //    SSN = HIGH;
    }
    buf[21]='\0';
 //   print_message("                                       ",1,0);
 //   print_message(buf, 1, 0);

    LEDR = 0; LEDG = 0;

    RFST = RFST_SIDLE;
    clock_delayms(3000);

    LEDR = 0; LEDG = 1;
 //   print_message("* Sending...",2,0);

    radio_send_packet(buf, strlen(buf) + 1);
    while (radio_still_sending()) {          
      clock_delayms(100);
 //     SSN = LOW;
 //     setCursor(2, 15*5);
 //     printf("%d %d %d", rf_packet_ix, rf_packet_n, rf_packet[0]); 
 //     SSN = HIGH;
    }
 //   print_message("* SENT!", 3, 0);
    RFST = RFST_SIDLE;
    clock_delayms(100);

  }
}
Exemplo n.º 2
0
/* For debugging, a simple test of the radio. */
void run_test_radio() {
  uint8_t wait_col = 55;
  uint8_t num_rcvd;

  clear();
  display_print_message("SENDING MSG", 0, 0);

  radio_send_packet("CORN MUFFIN", 11);
  while (radio_still_sending()) {          
    clock_delayms(100);
    display_print_message(".", 0, wait_col);
    wait_col += 5;
  }

  display_print_message("SENT! WAITING..", 1, 0);
  
  num_rcvd = radio_recv_packet_block(buf);
  buf[21]='\0';
  display_print_message(buf, 2, 0);
    
  setDisplayStart(0);
  SSN = LOW;
  setCursor(3, 0);
  printf("%d bytes RSSI=%d LQI=%02X", num_rcvd, radio_last_rssi, radio_last_lqi);
  SSN = HIGH;

  RFST = RFST_SIDLE;
  clock_delayms(100);
  
  display_print_message("SENDING ANOTHER", 4, 0);

  radio_send_packet("POOP", 5);
  while (radio_still_sending()) {          
    clock_delayms(100);
    SSN = LOW;
    setCursor(5, 0);
    printf("%d %d %d", rf_packet_ix, rf_packet_n, rf_packet[0]); 
    SSN = HIGH;
  }

  display_print_message("SENT!", 5, 0);
}
Exemplo n.º 3
0
static void send_message() {

//  while(1) {

  SSN = LOW;
  setDisplayStart(0);
  setCursor(6, 0);
  printf("Transmitting!");

  radio_send_packet(compose_buffer_);
  setCursor(7, 0);
  putchar('8');
  SSN = HIGH;
  
  while (radio_still_sending()) {
    clock_delayms(400);
    SSN = LOW;
    putchar('=');
    SSN = HIGH;
  }
  radio_listen(); // go back into receive mode

  clock_delayms(500);
  SSN = LOW;
  putchar('D');
  SSN = HIGH;
  clock_delayms(500);

//  }

  /* Reset the compose view. */
  state_ = COMPOSE_STATE_WRITING;
  compose_new_message();


  /* Switch back to the inbox view. */
  switch_state(STATE_VIEW);
}