Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Sigfox by
Sigfox.cpp
- Committer:
- Raffaello
- Date:
- 2017-05-27
- Revision:
- 5:66e05787ad5c
- Parent:
- 4:c77d5019b264
- Child:
- 6:799a482a7024
File content as of revision 5:66e05787ad5c:
#include "Sigfox.h" bool Sigfox::ready() { _at->send("AT"); return _at->recv("OK"); } bool Sigfox::send(const char *data, char* response) { // If require a response add plus in message if(response != NULL) { // Add request response data _at->send("AT$SF=%s,1", data); // Wait response from sigfox after send if(_at->recv("OK")) { char message[20]; // Wait return // TODO add loop to load data if(_at->recv("+RX%s", &message)) { // Check if message received is equal to " OK" if(strcmp(message, " OK") == 0) { return true; } } } return false; } else { _at->send("AT$SF=%s", data); return _at->recv("OK"); } } bool Sigfox::setKey(bool type) { _at->send("ATS410=%d", type); 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"); } bool Sigfox::saveConfig() { _at->send("AT$WR"); 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]; }