Skip to content

Commit e11db72

Browse files
committed
Hide sendBit and use it internally
1 parent 9ba098f commit e11db72

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/SigFox.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ int SIGFOXClass::begin(SPIClass& spi, int reset, int poweron, int interrupt, int
122122
int SIGFOXClass::send(unsigned char mess[], int len, bool rx)
123123
{
124124
if (len == 0) return -1;
125+
126+
if (rx == false && len == 1 && mess[0] < 2) {
127+
//we can use send_bit command
128+
return sendBit(mess[0]);
129+
}
130+
125131
status();
126132

127133
digitalWrite(chip_select_pin, LOW);
@@ -203,6 +209,7 @@ int SIGFOXClass::send(unsigned char mess[], int len, bool rx)
203209

204210
return sig;
205211
}
212+
206213
int SIGFOXClass::sendBit(bool value){
207214
int ret;
208215
int i = 0;
@@ -245,6 +252,7 @@ int SIGFOXClass::sendBit(bool value){
245252
}
246253
return 99; //default
247254
}
255+
248256
int SIGFOXClass::beginPacket() {
249257
bool ret = (tx_buffer_index == -1);
250258
tx_buffer_index = 0;
@@ -629,4 +637,4 @@ void SIGFOXClass::end()
629637
delay(1);
630638
}
631639

632-
SIGFOXClass SigFox; //singleton
640+
SIGFOXClass SigFox; //singleton

src/SigFox.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,6 @@ class SIGFOXClass : public Stream
8282
template <typename T> inline size_t write(T val) {return write((uint8_t*)&val, sizeof(T));};
8383
using Print::write;
8484

85-
/*
86-
* Send a single bit (0 | 1) over the Sigfox network
87-
* Returns the status code from the Atmel Sigfox chipset
88-
**/
89-
int sendBit(bool value);
90-
9185
//makes no sense in Sigfox world
9286
void flush() {};
9387

@@ -150,6 +144,12 @@ class SIGFOXClass : public Stream
150144
*/
151145
int send(unsigned char mess[], int len = 12, bool rx = false);
152146

147+
/*
148+
* Send a single bit (0 | 1) over the Sigfox network
149+
* Returns the status code from the Atmel Sigfox chipset
150+
**/
151+
int sendBit(bool value);
152+
153153
/*
154154
* Return atm status message
155155
*/

0 commit comments

Comments
 (0)