/******************************************************************************** Main ********************************************************************************/ int main(void) { // initialize code usart_init(); // enable interrupts //sei(); _delay_ms(2000); printf("Start NRF24L01P test..."); radio.begin(); radio.setRetries(15,15); radio.setPayloadSize(8); radio.setPALevel(RF24_PA_MAX); radio.setChannel(120); radio.openWritingPipe(pipes[1]); radio.openReadingPipe(1,pipes[0]); radio.startListening(); radio.printDetails(); loop(); // main loop while (true) { _delay_ms(1000); printf("Elapsed: %u \n", TCNT1); } }
void setup(void) { wiringPiSetupGpio(); // // Refer to RF24.h or nRF24L01 DS for settings radio.begin(WPI_MODE_GPIO); radio.enableDynamicPayloads(); radio.setAutoAck(1); radio.setRetries(15,15); radio.setDataRate(RF24_1MBPS); radio.setPALevel(RF24_PA_MAX); radio.setChannel(76); radio.setCRCLength(RF24_CRC_16); // Open 6 pipes for readings ( 5 plus pipe0, also can be used for reading ) radio.openWritingPipe(pipes[0]); radio.openReadingPipe(1,pipes[1]); radio.openReadingPipe(2,pipes[2]); radio.openReadingPipe(3,pipes[3]); radio.openReadingPipe(4,pipes[4]); radio.openReadingPipe(5,pipes[5]); // // Dump the configuration of the rf unit for debugging // // Start Listening radio.startListening(); radio.printDetails(); printf("\n\rOutput below : \n\r"); usleep(1000); }
void setup(void) { // // Refer to RF24.h or nRF24L01 DS for settings radio.begin(); radio.enableDynamicPayloads(); radio.setAutoAck(1); radio.setRetries(15,15); radio.setDataRate(RF24_250KBPS); radio.setPALevel(RF24_PA_MAX); radio.setChannel(70); radio.setCRCLength(RF24_CRC_8); // Open 6 pipes for readings ( 5 plus pipe0, also can be used for reading ) radio.openWritingPipe(pipes[0]); radio.openReadingPipe(1,pipes[1]); radio.openReadingPipe(2,pipes[2]); radio.openReadingPipe(3,pipes[3]); radio.openReadingPipe(4,pipes[4]); radio.openReadingPipe(5,pipes[5]); // Start Listening radio.startListening(); radio.printDetails(); usleep(1000); }
void changeChannel(byte newC) { radio.stopListening(); radio.setChannel(newC); radio.startListening(); }
void loop(void) { // Clear measurement values memset(values,0,num_channels); // Scan all channels num_reps times int rep_counter = num_reps; while (rep_counter--) { int i = num_channels; while (i--) { // Select this channel radio.setChannel(i); // Listen for a little radio.startListening(); delayMicroseconds(128); radio.stopListening(); // Did we get a carrier? if ( radio.testCarrier() ) ++values[i]; } } // Print out channel measurements, clamped to a single hex digit int i = 0; while ( i < num_channels ) { printf("%x",min(0xf,values[i]&0xf)); ++i; } printf("\n\r"); }
void setup(void) { // setup interrupt gpio_export(int_gpio_num); gpio_set_edge(GPIO_STR, "rising", "1"); radio.begin(); // enable dynamic payloads radio.enableAckPayload(); radio.enableDynamicPayloads(); radio.setAutoAck(1); // optionally, increase the delay between retries & # of retries radio.setRetries(15, 15); radio.setDataRate(RF24_2MBPS); radio.setPALevel(RF24_PA_MIN); radio.setChannel(50); radio.setCRCLength(RF24_CRC_16); // Open pipes to other nodes for communication // Open pipe for reading radio.openReadingPipe(0, pipes[0]); radio.openReadingPipe(1, pipes[1]); // Start listening radio.startListening(); // Dump the configuration of the rf unit for debugging radio.printDetails(); }
void setup(void){ //Prepare the radio module printf("\nPreparing NRF24L01 interface\n"); radio.begin(); radio.setRetries( 15, 15); radio.setChannel(120); radio.enableAckPayload(); //radio.disableCRC(); radio.setAutoAck(true); radio.openWritingPipe(pipes[0]); radio.openReadingPipe(2,pipes[1]); radio.openReadingPipe(3,pipes[2]); radio.openReadingPipe(1,pipes[0]); radio.printDetails(); printf("\nPreparing MySQL interface.\n"); mysql_connect(); if ((mysql1 != NULL)) { sprintf(SQLstring,"CREATE TABLE IF NOT EXISTS CC_SENSOR_DYN (timestamp DATETIME, id INTEGER, temperature FLOAT, value INTEGER);"); if (!mysql_query(mysql1, SQLstring)) { printf("SQL CC_SENSOR_DYN Table is Ok: %s\n",SQLstring); } else { printf("SQL CC_SENSOR_DYN NOk: %s\n",SQLstring); printf("%s\n", mysql_error(mysql1)); } sprintf(SQLstring,"CREATE TABLE IF NOT EXISTS CC_SENSOR_HIST (timestamp DATETIME, id INTEGER, hist_type VARCHAR(1), hist_period INTEGER, value FLOAT);"); if (!mysql_query(mysql1, SQLstring)) { printf("SQL CC_SENSOR_HIST Table is Ok: %s\n",SQLstring); } else { printf("SQL CC_SENSOR_HIST NOk: %s\n",SQLstring); printf("%s\n", mysql_error(mysql1)); } } radio.startListening(); printf("\nNow Listening...\n"); }
boolean newBoardAvailable() { if((nBoards < MAX_N_BOARDS) && (nSenActs < MAX_N_SENACT)&&nFreeCH) { radio.stopListening(); radio.setChannel( APPLICATION_CH ); radio.startListening(); if(readPackage(newBoardPacked, 32)) { if(writePackage(newBoardPacked, 32))return true; else { Serial.println("\nError: writng back board"); return false; } } else { //Serial.println("\nError: no New Board"); return false; } } else { Serial.println("Error: no more buffer/channel space"); return false; } }
void setup(void) { printf("\n\rnRF24l01+ remotecmd\n\r"); // // Setup and configure rf radio // radio.begin(); // optionally, increase the delay between retries & # of retries radio.setRetries(15,15); // optionally, reduce the payload size. seems to // improve reliability // radio.setPayloadSize(PACKET_LENGTH); radio.setChannel(0x4c); radio.setPALevel(RF24_PA_MAX); // // Open pipes to other nodes for communication // // Open pipe for writing // Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading) radio.openWritingPipe(pipes[0]); radio.openReadingPipe(1,pipes[1]); }
void mapFreeCH() { radio.setAutoAck(false); radio.startListening(); radio.stopListening(); for( int i = 30; i< 127; i++) { radio.setChannel(i); radio.startListening(); delay(25); radio.stopListening(); if ( !radio.testCarrier() ) { freeCH[nFreeCH++] = i; } } radio.setAutoAck(true); radio.startListening(); //test printing for (int i =0; i<nFreeCH; i++) { //Serial.println(freeCH[i]); } //Serial.println(""); //Serial.print(freeCH[nextFreeCH]); //Serial.println(""); }
int main(int argc, char** argv){ // bool role_ping_out = true, role_pong_back = false; // bool role = role_pong_back; printf("RF24/examples/GettingStarted/\n"); // Setup and configure rf radio radio.begin(); radio.setChannel(2); radio.setDataRate(RF24_2MBPS); radio.setPayloadSize(8); // optionally, increase the delay between retries & # of retries // radio.setRetries(15,15); // Dump the configuration of the rf unit for debugging radio.printDetails(); /***********************************/ radio.startListening(); // forever loop while (1) { // if there is data ready if ( radio.available() ) { // Dump the payloads until we've gotten everything unsigned long got_time; // Fetch the payload, and see if this was the last one. while(radio.available()){ radio.read( &got_time, sizeof(unsigned long) ); } // radio.stopListening(); // radio.write( &got_time, sizeof(unsigned long) ); // Now, resume listening so we catch the next packets. // radio.startListening(); // Spew it printf("Got payload(%d) %lu...\n",sizeof(unsigned long), got_time); } delay(925); //Delay after payload responded to, minimize RPi CPU time printf("."); fflush(stdout); // radio.printDetails(); } // forever loop return 0; }
void pcmRF::begin(){ radi.begin(); radi.setChannel(1); // Set RF channel to 1 radi.setAutoAck(0); // Disable ACKnowledgement packets radi.setDataRate(RF24_1MBPS); // Set data rate as specified in user options radi.setCRCLength(RF24_CRC_8); radi.openWritingPipe(addresses[1]); radi.openReadingPipe(1,addresses[0]); }
void setup(void){ radio.begin(); radio.setPALevel(RF_24_PA_MAX); radio.setChannel(0x75); radio.openWritingPipe(0xF0F0F0F0E1LL); radio.enableDynamicPayloads(); radio.powerUp(); }
/******************************************************************************** Main ********************************************************************************/ int main(void) { // initialize usart module usart_init(); // enable interrupts sei(); // Init GPIO initGPIO(); // Init Timer 1 initTimer(); // Init Timer 0 & 2 initTimers(); OCR0A = 255; OCR0B = 255; OCR2A = 255; OCR2B = 255; _delay_ms(1000); OCR0A = 0; OCR0B = 0; OCR2A = 0; OCR2B = 0; fixZeroValueOCR(); // Console friendly output printf("Start..."); printf(CONSOLE_PREFIX); // Init NRF24L01+ radio.begin(); radio.setRetries(15,15); radio.setPayloadSize(8); radio.setPALevel(RF24_PA_MAX); radio.setChannel(115); radio.openWritingPipe(pipes[0]); radio.openReadingPipe(1,pipes[1]); radio.startListening(); // Some RF module diagnostics logs radio.printDetails(); // main loop while (1) { // main usart loop for console usart_check_loop(); } }
void radioSetup() { radio.begin(); radio.setRetries(15, 15); radio.setChannel(0x4c); //76 radio.setPALevel(RF24_PA_MAX); radio.setPALevel(RF24_PA_MAX); radio.openWritingPipe(pipes[0]); radio.openReadingPipe(1, pipes[1]); radio.startListening(); radio.printDetails(); printf("Radio setup is complete!\n"); }
void setup(void) { // init radio for reading radio.begin(); radio.enableDynamicPayloads(); radio.setAutoAck(1); radio.setRetries(15,15); radio.setDataRate(RF24_1MBPS); radio.setPALevel(RF24_PA_MAX); radio.setChannel(76); radio.setCRCLength(RF24_CRC_16); radio.openReadingPipe(1,0xF0F0F0F0E1LL); radio.startListening(); }
//Initial setup of GPIO Pins and pipe modes (read/write). void setup(void) { radio.begin(); radio.setRetries(15,15); radio.setChannel(0x4c); radio.setPALevel(RF24_PA_MAX); radio.openWritingPipe(pipes[0]); radio.openReadingPipe(1,pipes[1]); radio.openReadingPipe(2,pipes[2]); radio.openReadingPipe(3,pipes[3]); radio.startListening(); radio.printDetails(); }
void setup(void){ //Prepare the radio module printf("\nPreparing interface\n"); radio.begin(); radio.setRetries( 15, 15); radio.setChannel(0x4c); radio.setPALevel(RF24_PA_MAX); radio.setPALevel(RF24_PA_MAX); radio.openWritingPipe(pipes[0]); radio.openReadingPipe(1,pipes[1]); radio.startListening(); radio.printDetails(); }
boolean readAllSonBoard(Board * theBoard) { radio.stopListening(); radio.setChannel(theBoard->channel); //Serial.println((char*)theBoard->name); //Serial.println(theBoard->channel); radio.startListening(); for(int i =0; i < theBoard->nSenAct; i++) { if((theBoard->arraySenAct+i)->sOrA == SENSOR) if( readSensorB(theBoard->arraySenAct+i) == 0 ) return 0; } return 1; }
void setup(void){ //Prepare the radio module printf("\nPreparing interface\n"); radio.begin(); radio.enableDynamicPayloads(); radio.setAutoAck(1); radio.setRetries( 15, 15); radio.setDataRate(RF24_1MBPS); radio.setPALevel(RF24_PA_MAX); radio.setChannel(76); radio.setCRCLength(RF24_CRC_16); radio.openWritingPipe(pipes[0]); radio.openReadingPipe(1,pipes[1]); radio.startListening(); radio.printDetails(); }
boolean newBoardConnect() { byte k =1; radio.stopListening(); radio.setChannel( DEFINITION_CH ); radio.startListening(); if(readPackageAck(package,1,&k,1)) { unpackBoard(&Boards[nBoards],newBoardPacked); Boards[nBoards].arraySenAct = &SenActs[nSenActs]; return true; } else { Serial.println("\nError: Board not connected"); return false; } }
void setup(void) { time_t now = time(0); char* dt = ctime(&now); cout << "The local time is: " << dt << endl; tm * gmtm = gmtime(&now); dt = asctime(gmtm);; cout << "The UTC date and time is: " << dt << endl; // // Refer to RF24.h or nRF24L01 DS for settings radio.begin(); radio.enableDynamicPayloads(); radio.setAutoAck(1); radio.setRetries(15,15); radio.setDataRate(RF24_1MBPS); radio.setPALevel(RF24_PA_MAX); radio.setChannel(76); radio.setCRCLength(RF24_CRC_16); // Open 6 pipes for readings ( 5 plus pipe0, also can be used for reading ) radio.openWritingPipe(pipes[0]); radio.openReadingPipe(1,pipes[1]); radio.openReadingPipe(2,pipes[2]); radio.openReadingPipe(3,pipes[3]); radio.openReadingPipe(4,pipes[4]); radio.openReadingPipe(5,pipes[5]); // // Dump the configuration of the rf unit for debugging // // Start Listening radio.startListening(); radio.printDetails(); printf("\n\rOutput below : \n\r"); usleep(1000); }
void setup(void) { radio.begin(); radio.setPayloadSize(PAYLOAD_SIZE); radio.setAutoAck(1); radio.setRetries(15,15); radio.setDataRate(RF24_1MBPS); radio.setPALevel(RF24_PA_MAX); radio.setChannel(10); radio.setCRCLength(RF24_CRC_16); //open the pipe radio.openReadingPipe(1,0xF0F0F0F0E1LL); // Start Listening radio.startListening(); //print output radio.printDetails(); printf("\n\rOutput below : \n\r"); usleep(1000); }
void setup(void) { radio.begin(); // enable dynamic payloads radio.enableDynamicPayloads(); // optionally, increase the delay between retries & # of retries radio.setRetries(15, 15); radio.setDataRate(RF24_2MBPS); radio.setPALevel(RF24_PA_HIGH); radio.setChannel(50); // Open pipes to other nodes for communication // Open 'our' pipe for writing // Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading) radio.openWritingPipe(pipes[0]); radio.openReadingPipe(1, pipes[1]); radio.setCRCLength(RF24_CRC_16); radio.setAutoAck( true ) ; // Start listening radio.startListening(); // Dump the configuration of the rf unit for debugging radio.printDetails(); }
void setup(void) { // // Setup and configure rf radio // radio.begin(); // optionally, increase the delay between retries & # of retries radio.setRetries(20, 20); radio.setPayloadSize(PAYLOAD); // TODO: set other crap (data rate, spi rate, etc) radio.setDataRate(RF24_2MBPS); radio.setChannel(0x4c); radio.setPALevel(RF24_PA_MAX); // // Open pipes to other nodes for communication // // TODO: configure this to match correctly on the Arduino radio.openWritingPipe(pipes[0]); radio.openReadingPipe(1, pipes[1]); // // Start listening // radio.startListening(); // // Dump the configuration of the rf unit for debugging // //radio.printDetails(); std::cerr << "OK Listening for commands" << std::endl; }
bool COM_24g::initiate(RF24 _radioCom) { bool status = false; int i; //RF24 _radioCom(_ce,_csn); _radioCom.begin(); // optionally, increase the delay between retries & # of retries _radioCom.setRetries(15,_maxRetry); _radioCom.setChannel(_channel); // optionally, reduce the payload size. seems to improve reliability //_radioCom.setPayloadSize(8); // Open pipes to other nodes for communication //seen if this is an issue _radioCom.openWritingPipe(_writingPipe); for (i=1;i<5;i++) { if (_readingPipe[i] != NULL) { _radioCom.openReadingPipe(i,_readingPipe[i]); printf("Now listening pipe %d at adress %x \n",i,_readingPipe[i]); status = true; } } if (status == true) { printf("INITIALIZATION : We are listening \n"); _radioCom.startListening(); _radioCom.powerUp(); } else { printf("We are doing a f*****g power down"); _radioCom.powerDown(); } return status; }
void setup(void) { // // Role // // set up the role pin // pinMode(role_pin, INPUT); //digitalWrite(role_pin,HIGH); // delay(20); // Just to get a solid reading on the role pin // read the address pin, establish our role //if ( ! digitalRead(role_pin) ) // role = role_ping_out; //else role = role_pong_back; // // Print preamble: // //Serial.begin(115200); //printf_begin(); printf("\n\rRF24/examples/pingpair/\n\r"); printf("ROLE: %s\n\r",role_friendly_name[role]); // // Setup and configure rf radio // radio.begin(); radio.enableDynamicPayloads(); radio.setAutoAck(1); radio.setRetries(15,15); radio.setDataRate(RF24_250KBPS); radio.setPALevel(RF24_PA_MAX); radio.setChannel(125); radio.setCRCLength(RF24_CRC_16); // // Open pipes to other nodes for communication // // This simple sketch opens two pipes for these two nodes to communicate // back and forth. // Open 'our' pipe for writing // Open the 'other' pipe for reading, in position #1 (we can have up to 5 pipes open for reading) radio.openWritingPipe(pipes[0]); radio.openReadingPipe(1,pipes[1]); // // Start listening // radio.startListening(); // // Dump the configuration of the rf unit for debugging // cout << "Mark" << endl; radio.printDetails(); //lamp[1] = 0; //lamp[2] = 0; //cout << "Lamp 1: " << lamp[1] << endl; //cout << "Lamp 2: " << lamp[2] << endl; }
int main (){ HardwareInit(); RF24 radio = RF24(); // Radio pipe addresses for the 2 nodes to communicate. const uint64_t pipes[2] = { 0xF0F0F0F0BELL, 0xF0F0F0F0EFLL }; setup_watchdog(wdt_64ms); // // Setup and configure rf radio // radio.begin(); radio.setChannel(100); // optionally, increase the delay between retries & # of retries radio.setRetries(15,15); // optionally, reduce the payload size. seems to // improve reliability radio.setPayloadSize(sizeof(report_t)); radio.setDataRate(RF24_250KBPS); radio.openWritingPipe(pipes[0]); radio.openReadingPipe(1,pipes[1]); radio.startListening(); radio.stopListening(); //unsigned long pa = 0; uint8_t counter = 0; //check eeprom if (eeprom_read_byte(0)==EEPROM_MAGIC_NUMBER){ minx=(char)eeprom_read_byte((uint8_t*)1); maxx=(char)eeprom_read_byte((uint8_t*)2); miny=(char)eeprom_read_byte((uint8_t*)3); maxy=(char)eeprom_read_byte((uint8_t*)4); minrx=(char)eeprom_read_byte((uint8_t*)5); maxrx=(char)eeprom_read_byte((uint8_t*)6); minry=(char)eeprom_read_byte((uint8_t*)7); maxry=(char)eeprom_read_byte((uint8_t*)8); calibrated=true; #ifdef DEBUG print_string("read eeprom magic number"); char temp[100]; sprintf(temp,"minx:%d maxx:%d minry:%d maxry:%d \n",minx,maxx,minry,maxry); print_string(temp); _delay_ms(2000); #endif } while(1){ ReadController(); #ifdef DEBUG char temp[100]; print_string("before convert\n"); sprintf(temp,"hat:%u x:%d y:%d rx:%d ry:%d b1:%u b2:%u\n",reportBuffer.hat,(int8_t)reportBuffer.x,(int8_t)reportBuffer.y,(int8_t)reportBuffer.rx,(int8_t)reportBuffer.ry,reportBuffer.b1,reportBuffer.b2); print_string(temp); #endif convertAxes(); #ifdef DEBUG sprintf(temp,"hat:%u x:%d y:%d rx:%d ry:%d b1:%u b2:%u\n",reportBuffer.hat,(int8_t)reportBuffer.x,(int8_t)reportBuffer.y,(int8_t)reportBuffer.rx,(int8_t)reportBuffer.ry,reportBuffer.b1,reportBuffer.b2); print_string(temp); #endif //Calibration if(A_PRESSED && B_PRESSED && Z_PRESSED && L_PRESSED && R_PRESSED){ calibrate(); } counter=(counter+1)%20; sendData(counter==0,radio); do_sleep(); } //never reached return 0; }
int main(int argc, char** argv) { int fr = atoi(argv[1]); int to = atoi(argv[2]); int ac = atoi(argv[3]); printf("vendor/TMRh20/RF24_RPi/Task\n"); // Refer to RF24.h or nRF24L01 DS for settings radio.begin(); delay(5); radio.setPayloadSize(10); radio.setRetries(15,15); // optionally, increase the delay between retries & # of retries //radio.setAutoAck(1); // Ensure autoACK is enabled radio.setAutoAck(0); // Ensure autoACK is disabled radio.setPALevel(RF24_PA_HIGH); radio.setDataRate(RF24_250KBPS); //radio.setCRCLength(RF24_CRC_8); radio.setChannel(114); radio.openWritingPipe(pipes[(to-1)]); // atoi() change a char to a int radio.openReadingPipe(1,pipes[(fr-1)]); radio.startListening(); radio.printDetails(); // First, stop listening so we can talk. radio.stopListening(); radio.powerUp(); // Take the time, and send it. This will block until complete char payload_send[10] = ""; snprintf(payload_send, 10, "to:%d,ac:%d", to, ac); char payload_send_size[10] = ""; snprintf(payload_send_size, 10, "%d", sizeof(payload_send)); printf("Sending ..\n"); printf("Payload size: "); printf(payload_send_size); printf("\n"); printf("Payload: "); printf(payload_send); printf("\n"); //bool ok = radio.write( &payload_send, 10 ); radio.write( &payload_send, 10 ); /*if (!ok){ printf("failed.\n"); exit(1); }*/ //radio.powerDown(); // Now, continue listening radio.startListening(); // Wait here until we get a response, or timeout (250ms) unsigned long started_waiting_at = millis(); bool timeout = false; // Reading temperature or humidity takes about 250 milliseconds! // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) while ( ! radio.available() && ! timeout ) { if (millis() - started_waiting_at > 3000 ) { timeout = true; } } // Describe the results if ( timeout ) { printf("err: response timed out.\n"); exit(1); } else { // Grab the response, compare, and send to debugging spew char payload_receive[10] = ""; radio.read( &payload_receive, 10 ); char payload_receive_size[10] = ""; snprintf(payload_receive_size, 32, "%d", 10); // Spew it printf("Received ..\n"); printf("Payload size: "); printf(payload_receive_size); printf("\n"); printf("Payload: "); printf(payload_receive); printf("\n"); printf(payload_receive); exit(0); } exit(1); }