bool HidnSeek::send(const void* data, uint8_t len) { uint8_t* bytes = (uint8_t*)data; /* if(!isReady()) { return false; } */ // See comment in isReady() _lastSend = millis(); _serial.write((uint8_t)'\0'); _command(PSTR("SFM")); _serial.write(len); for(uint8_t i = 0; i < len; ++i) { _serial.write(bytes[i]); } _serial.write(';'); uint8_t ok = _nextReturn(); if(ok == OK) { _nextReturn(); //SENT return true; } return false; }
bool Akeru_::send(const void* data, uint8_t len) { uint8_t* bytes = (uint8_t*)data; if(!isReady()) { return false; } // See comment in isReady() _lastSend = millis(); _serial.write((uint8_t)'\0'); _serial.write((uint8_t)'S'); _serial.write((uint8_t)'F'); _serial.write((uint8_t)'M'); _serial.write(len); for(uint8_t i = 0; i < len; ++i) { _serial.write(bytes[i]); } _serial.write(';'); uint8_t ok = _nextReturn(); if(ok == OK) { _nextReturn(); //SENT return true; } return false; }
bool HidnSeek::isReady() { // IMPORTANT WARNING. PLEASE READ BEFORE MODIFYING THE CODE // // The Sigfox network operates on public frequencies. To comply with // radio regulation, it can send radio data a maximum of 1% of the time // to leave room to other devices using the same frequencies. // // Sending a message takes about 6 seconds (it's sent 3 times for // redundancy purposes), meaning the interval between messages should // be 10 minutes. // // Also make sure your send rate complies with the restrictions set // by the particular subscription contract you have with your Sigfox // network operator. // // FAILING TO COMPLY WITH THESE CONSTRAINTS MAY CAUSE YOUR MODEM // TO BE BLOCKED BY YOUR SIFGOX NETWORK OPERATOR. // // You've been warned! unsigned long currentTime = millis(); if(currentTime >= _lastSend && ((unsigned long)(currentTime - _lastSend) <= 60000UL)) { return false; } // Time is ok, ask the modem's status _serial.write((uint8_t)'\0'); _serial.write((uint8_t)'S'); _serial.write((uint8_t)'F'); _serial.write((uint8_t)'P'); _serial.write((uint8_t)';'); return _nextReturn() == OK; }
//Power value: //0 -25 -30 dBm //1 0dBm //2 14dBm //3 16dBm //4 18dBm //5 Max (18-19dBm) bool Akeru_::setPower(uint8_t power) { power = power % 6; //It's 0-5 _serial.write((uint8_t)'\0'); _serial.write((uint8_t)'S'); _serial.write((uint8_t)'F'); _serial.write((uint8_t)'G'); _serial.write(power); _serial.write((uint8_t)';'); return _nextReturn() == OK; }