id This module defines the NRF24L01 interface for libnrf24l01
{
public:
virtual void run()
{
if (_com != NULL)
std::cout << "Reciever :: " << *((uint32_t*) &(_com->m_rxBuffer[0])) << std::endl;
else
std::cout << "Example callback!" << std::endl;
}
private:
};
int
main(int argc, char** argv)
{
mycb cb(&comm);
comm.setSourceAddress((uint8_t*) local_address);
comm.setDestinationAddress((uint8_t*) broadcast_address);
comm.setPayload(MAX_BUFFER);
comm.configure();
comm.setSpeedRate(upm::NRF_250KBPS);
comm.setChannel(99);
comm.setDataReceivedHandler(&cb);
signal(SIGINT, sig_handler);
while (!running) {
comm.pollListener();
}
std::cout << "exiting application" << std::endl;
return 0;
}
uint32_t dummyData = 0;
mycb cb(&comm);
comm.setSourceAddress((uint8_t*) srcAddress);
comm.setDestinationAddress((uint8_t*) destAddress);
comm.setPayload(MAX_BUFFER);
comm.setChannel(99);
comm.configure();
comm.setDataReceivedHandler(&cb);
signal(SIGINT, sig_handler);
while (!running) {
memcpy(comm.m_txBuffer, &dummyData, sizeof(dummyData));
comm.send();
std::cout << "devi2 :: sending data ...." << dummyData << std::endl;
upm_delay_us(3000000);
dummyData += 3000;
}
std::cout << "exiting application" << std::endl;
sensor.setBeaconingMode();
std::vector<std::string> msgs;
msgs.push_back("Hello World 1!!!");
msgs.push_back("Hello World 2!!!");
msgs.push_back("Hello World 3!!!");
msgs.push_back("Hello World 4!!!");
msgs.push_back("Hello World 5!!!");
signal(SIGINT, sig_handler);
while (!running) {
for (std::vector<std::string>::iterator item = msgs.begin(); item != msgs.end(); ++item) {
std::cout << "BROADCASTING " << (*item).c_str() << std::endl;
for (int i = 0; i < 3; i++) {
sensor.sendBeaconingMsg((uint8_t*) (*item).c_str());
upm_delay_us(1000000);
}
}
}
std::cout << "exiting application" << std::endl;
msgs.clear();