sigfox
Fork of Sigfox by
Sigfox.cpp
- Committer:
- Raffaello
- Date:
- 2017-04-19
- Revision:
- 2:d07e3b39ff74
- Parent:
- 1:93450d8b2540
- Child:
- 3:279bed56f354
File content as of revision 2:d07e3b39ff74:
#include "Sigfox.h"
bool Sigfox::ready() {
_at->send("AT");
return _at->recv("OK");
}
bool Sigfox::send(const char *data) {
_at->send("AT$SF=%s", data);
return _at->recv("OK");
}
bool Sigfox::setPower(uint8_t power) {
_at->send("ATS302=%d", power);
return _at->recv("OK");
}
bool Sigfox::setPowerMode(uint8_t power) {
_at->send("AT$P=%d", power);
return _at->recv("OK");
}
void Sigfox::wakeup(DigitalInOut sig_rst, float time) {
// Wake up sigfox
sig_rst.output();
sig_rst = 0;
wait(time);
// Set high impendance the sigfox reset pin
sig_rst.input();
wait(time);
}
char *Sigfox::getID() {
char buff[8+2];
_at->send("AT$I=10");
_at->read(buff, 8+2);
memcpy(&ID[0],&buff[2],8);
return &ID[0];
}
char *Sigfox::getPAC() {
char buff[16+2];
_at->send("AT$I=11");
_at->read(buff, 16+2);
memcpy(&PAC[0],&buff[2],16);
return &PAC[0];
}
