more return type change from err_t to bool
This commit is contained in:
1 parent
4d5a0e3587
commit
dada11452e
10 files changed
+62
-68
No files matched your search
@@ -23,6 +23,9 @@
|
||||
- rename BLEBas .update() to .write()
|
||||
- change Bluefruit setConnInterval()/setConnIntervalMS() return type from `err_t` to `bool`
|
||||
- change BLECentral startScanning()/stopScanning()/connect() return type from `err_t` to `bool`
|
||||
- change BLECharacteristic notify() return type from `err_t` to `bool`
|
||||
- change BLEHid report function return type from `err_t` to `bool`
|
||||
- change BLEMid send/sendSplit
|
||||
- New BLE Serivce
|
||||
- Apple Notification Center Service (ANCS)
|
||||
- Central BLE UART
|
||||
|
||||
@@ -454,9 +454,9 @@ bool BLECharacteristic::notifyEnabled(void)
|
||||
return (cccd & BLE_GATT_HVX_NOTIFICATION);
|
||||
}
|
||||
|
||||
err_t BLECharacteristic::notify(const void* data, int len)
|
||||
bool BLECharacteristic::notify(const void* data, int len)
|
||||
{
|
||||
VERIFY( _properties.notify, NRF_ERROR_INVALID_PARAM);
|
||||
VERIFY( _properties.notify );
|
||||
|
||||
// could not exceed max len
|
||||
uint16_t actual_len = min16(len, _max_len);
|
||||
@@ -485,7 +485,7 @@ err_t BLECharacteristic::notify(const void* data, int len)
|
||||
.p_data = (uint8_t*) u8data,
|
||||
};
|
||||
|
||||
VERIFY_STATUS( sd_ble_gatts_hvx(Bluefruit.connHandle(), &hvx_params) );
|
||||
VERIFY_STATUS( sd_ble_gatts_hvx(Bluefruit.connHandle(), &hvx_params), false );
|
||||
|
||||
actual_len -= packet_len;
|
||||
u8data += packet_len;
|
||||
@@ -494,33 +494,33 @@ err_t BLECharacteristic::notify(const void* data, int len)
|
||||
else
|
||||
{
|
||||
write(data, actual_len);
|
||||
return NRF_ERROR_INVALID_STATE;
|
||||
return false;
|
||||
}
|
||||
|
||||
return ERROR_NONE;
|
||||
return true;
|
||||
}
|
||||
|
||||
err_t BLECharacteristic::notify(const char * str)
|
||||
bool BLECharacteristic::notify(const char * str)
|
||||
{
|
||||
return notify( (const uint8_t*) str, strlen(str) );
|
||||
}
|
||||
|
||||
err_t BLECharacteristic::notify(int num)
|
||||
bool BLECharacteristic::notify(int num)
|
||||
{
|
||||
return notify( (uint8_t*) &num, sizeof(num));
|
||||
}
|
||||
|
||||
err_t BLECharacteristic::notify(uint32_t num)
|
||||
bool BLECharacteristic::notify(uint32_t num)
|
||||
{
|
||||
return notify( (uint8_t*) &num, sizeof(num));
|
||||
}
|
||||
|
||||
err_t BLECharacteristic::notify(uint16_t num)
|
||||
bool BLECharacteristic::notify(uint16_t num)
|
||||
{
|
||||
return notify( (uint8_t*) &num, sizeof(num));
|
||||
}
|
||||
|
||||
err_t BLECharacteristic::notify(uint8_t num)
|
||||
bool BLECharacteristic::notify(uint8_t num)
|
||||
{
|
||||
return notify( (uint8_t*) &num, sizeof(num));
|
||||
}
|
||||
@@ -155,13 +155,13 @@ class BLECharacteristic
|
||||
uint16_t read(uint8_t* num);
|
||||
|
||||
/*------------- Notify -------------*/
|
||||
bool notifyEnabled(void);
|
||||
err_t notify(const void* data, int len);
|
||||
err_t notify(const char * str);
|
||||
err_t notify(int num);
|
||||
err_t notify(uint32_t num);
|
||||
err_t notify(uint16_t num);
|
||||
err_t notify(uint8_t num);
|
||||
bool notifyEnabled(void);
|
||||
bool notify(const void* data, int len);
|
||||
bool notify(const char * str);
|
||||
bool notify(int num);
|
||||
bool notify(uint32_t num);
|
||||
bool notify(uint16_t num);
|
||||
bool notify(uint8_t num);
|
||||
|
||||
friend class BLEGatt;
|
||||
};
|
||||
|
||||
@@ -187,11 +187,6 @@ uint8_t const hid_report_descriptor[] =
|
||||
HID_LOGICAL_MIN ( 0 ),
|
||||
HID_LOGICAL_MAX ( 1 ),
|
||||
HID_REPORT_COUNT ( 8 ), // Keyboard
|
||||
err_t keyboardReport(uint8_t modifier, uint8_t keycode[6]);
|
||||
err_t keyboardReport(hid_keyboard_report_t* report);
|
||||
err_t keyPress(char ch);
|
||||
err_t keyRelease(void);
|
||||
err_t keySequence(const char* str, int ms=5);
|
||||
HID_REPORT_SIZE ( 1 ),
|
||||
HID_INPUT ( HID_DATA | HID_VARIABLE | HID_ABSOLUTE),
|
||||
HID_COLLECTION_END
|
||||
@@ -224,12 +219,12 @@ err_t BLEHidAdafruit::begin(void)
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Keyboard
|
||||
*------------------------------------------------------------------*/
|
||||
err_t BLEHidAdafruit::keyboardReport(hid_keyboard_report_t* report)
|
||||
bool BLEHidAdafruit::keyboardReport(hid_keyboard_report_t* report)
|
||||
{
|
||||
return inputReport( REPORT_ID_KEYBOARD, report, sizeof(hid_keyboard_report_t));
|
||||
}
|
||||
|
||||
err_t BLEHidAdafruit::keyboardReport(uint8_t modifier, uint8_t keycode[6])
|
||||
bool BLEHidAdafruit::keyboardReport(uint8_t modifier, uint8_t keycode[6])
|
||||
{
|
||||
hid_keyboard_report_t report =
|
||||
{
|
||||
@@ -240,7 +235,7 @@ err_t BLEHidAdafruit::keyboardReport(uint8_t modifier, uint8_t keycode[6])
|
||||
return keyboardReport(&report);
|
||||
}
|
||||
|
||||
err_t BLEHidAdafruit::keyboardReport(uint8_t modifier, uint8_t keycode0, uint8_t keycode1, uint8_t keycode2, uint8_t keycode3, uint8_t keycode4, uint8_t keycode5)
|
||||
bool BLEHidAdafruit::keyboardReport(uint8_t modifier, uint8_t keycode0, uint8_t keycode1, uint8_t keycode2, uint8_t keycode3, uint8_t keycode4, uint8_t keycode5)
|
||||
{
|
||||
hid_keyboard_report_t report =
|
||||
{
|
||||
@@ -252,7 +247,7 @@ err_t BLEHidAdafruit::keyboardReport(uint8_t modifier, uint8_t keycode0, uint8_t
|
||||
return keyboardReport(&report);
|
||||
}
|
||||
|
||||
err_t BLEHidAdafruit::keyPress(char ch)
|
||||
bool BLEHidAdafruit::keyPress(char ch)
|
||||
{
|
||||
hid_keyboard_report_t report;
|
||||
varclr(&report);
|
||||
@@ -263,7 +258,7 @@ err_t BLEHidAdafruit::keyPress(char ch)
|
||||
return keyboardReport(&report);
|
||||
}
|
||||
|
||||
err_t BLEHidAdafruit::keyRelease(void)
|
||||
bool BLEHidAdafruit::keyRelease(void)
|
||||
{
|
||||
hid_keyboard_report_t report;
|
||||
varclr(&report);
|
||||
@@ -271,7 +266,7 @@ err_t BLEHidAdafruit::keyRelease(void)
|
||||
return keyboardReport(&report);
|
||||
}
|
||||
|
||||
err_t BLEHidAdafruit::keySequence(const char* str, int interal)
|
||||
bool BLEHidAdafruit::keySequence(const char* str, int interal)
|
||||
{
|
||||
// Send each key in sequence
|
||||
char ch;
|
||||
@@ -291,23 +286,23 @@ err_t BLEHidAdafruit::keySequence(const char* str, int interal)
|
||||
}
|
||||
}
|
||||
|
||||
return ERROR_NONE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Consumer Media Key
|
||||
*------------------------------------------------------------------*/
|
||||
err_t BLEHidAdafruit::consumerReport(uint16_t usage_code)
|
||||
bool BLEHidAdafruit::consumerReport(uint16_t usage_code)
|
||||
{
|
||||
return inputReport( REPORT_ID_CONSUMER_CONTROL, &usage_code, sizeof(usage_code));
|
||||
}
|
||||
|
||||
err_t BLEHidAdafruit::consumerKeyPress(uint16_t usage_code)
|
||||
bool BLEHidAdafruit::consumerKeyPress(uint16_t usage_code)
|
||||
{
|
||||
return consumerReport(usage_code);
|
||||
}
|
||||
|
||||
err_t BLEHidAdafruit::consumerKeyRelease(void)
|
||||
bool BLEHidAdafruit::consumerKeyRelease(void)
|
||||
{
|
||||
uint16_t usage = 0;
|
||||
return consumerReport(usage);
|
||||
@@ -316,12 +311,12 @@ err_t BLEHidAdafruit::consumerKeyRelease(void)
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Mouse
|
||||
*------------------------------------------------------------------*/
|
||||
err_t BLEHidAdafruit::mouseReport(hid_mouse_report_t* report)
|
||||
bool BLEHidAdafruit::mouseReport(hid_mouse_report_t* report)
|
||||
{
|
||||
return inputReport( REPORT_ID_MOUSE, report, sizeof(hid_mouse_report_t));
|
||||
}
|
||||
|
||||
err_t BLEHidAdafruit::mouseReport(uint8_t buttons, int8_t x, int8_t y, int8_t wheel, int8_t pan)
|
||||
bool BLEHidAdafruit::mouseReport(uint8_t buttons, int8_t x, int8_t y, int8_t wheel, int8_t pan)
|
||||
{
|
||||
hid_mouse_report_t report =
|
||||
{
|
||||
@@ -337,28 +332,28 @@ err_t BLEHidAdafruit::mouseReport(uint8_t buttons, int8_t x, int8_t y, int8_t wh
|
||||
return mouseReport(&report);
|
||||
}
|
||||
|
||||
err_t BLEHidAdafruit::mouseButtonPress(uint8_t buttons)
|
||||
bool BLEHidAdafruit::mouseButtonPress(uint8_t buttons)
|
||||
{
|
||||
_mse_buttons = buttons;
|
||||
return mouseReport(buttons, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
err_t BLEHidAdafruit::mouseButtonRelease(void)
|
||||
bool BLEHidAdafruit::mouseButtonRelease(void)
|
||||
{
|
||||
return mouseReport(0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
err_t BLEHidAdafruit::mouseMove(int8_t x, int8_t y)
|
||||
bool BLEHidAdafruit::mouseMove(int8_t x, int8_t y)
|
||||
{
|
||||
return mouseReport(_mse_buttons, x, y, 0, 0);
|
||||
}
|
||||
|
||||
err_t BLEHidAdafruit::mouseScroll(int8_t scroll)
|
||||
bool BLEHidAdafruit::mouseScroll(int8_t scroll)
|
||||
{
|
||||
return mouseReport(_mse_buttons, 0, 0, scroll, 0);
|
||||
}
|
||||
|
||||
err_t BLEHidAdafruit::mousePan(int8_t pan)
|
||||
bool BLEHidAdafruit::mousePan(int8_t pan)
|
||||
{
|
||||
return mouseReport(_mse_buttons, 0, 0, 0, pan);
|
||||
}
|
||||
@@ -55,29 +55,29 @@ class BLEHidAdafruit : public BLEHidGeneric
|
||||
virtual err_t begin(void);
|
||||
|
||||
// Keyboard
|
||||
err_t keyboardReport(hid_keyboard_report_t* report);
|
||||
err_t keyboardReport(uint8_t modifier, uint8_t keycode[6]);
|
||||
err_t keyboardReport(uint8_t modifier, uint8_t keycode0, uint8_t keycode1=0, uint8_t keycode2=0, uint8_t keycode3=0, uint8_t keycode4=0, uint8_t keycode5=0);
|
||||
bool keyboardReport(hid_keyboard_report_t* report);
|
||||
bool keyboardReport(uint8_t modifier, uint8_t keycode[6]);
|
||||
bool keyboardReport(uint8_t modifier, uint8_t keycode0, uint8_t keycode1=0, uint8_t keycode2=0, uint8_t keycode3=0, uint8_t keycode4=0, uint8_t keycode5=0);
|
||||
|
||||
err_t keyPress(char ch);
|
||||
err_t keyRelease(void);
|
||||
err_t keySequence(const char* str, int interal=5);
|
||||
bool keyPress(char ch);
|
||||
bool keyRelease(void);
|
||||
bool keySequence(const char* str, int interal=5);
|
||||
|
||||
// Consumer Media Keys
|
||||
err_t consumerReport(uint16_t usage_code);
|
||||
err_t consumerKeyPress(uint16_t usage_code);
|
||||
err_t consumerKeyRelease(void);
|
||||
bool consumerReport(uint16_t usage_code);
|
||||
bool consumerKeyPress(uint16_t usage_code);
|
||||
bool consumerKeyRelease(void);
|
||||
|
||||
// Mouse
|
||||
err_t mouseReport(hid_mouse_report_t* report);
|
||||
err_t mouseReport(uint8_t buttons, int8_t x, int8_t y, int8_t wheel=0, int8_t pan=0);
|
||||
bool mouseReport(hid_mouse_report_t* report);
|
||||
bool mouseReport(uint8_t buttons, int8_t x, int8_t y, int8_t wheel=0, int8_t pan=0);
|
||||
|
||||
err_t mouseButtonPress(uint8_t buttons);
|
||||
err_t mouseButtonRelease(void);
|
||||
bool mouseButtonPress(uint8_t buttons);
|
||||
bool mouseButtonRelease(void);
|
||||
|
||||
err_t mouseMove(int8_t x, int8_t y);
|
||||
err_t mouseScroll(int8_t scroll);
|
||||
err_t mousePan(int8_t pan);
|
||||
bool mouseMove(int8_t x, int8_t y);
|
||||
bool mouseScroll(int8_t scroll);
|
||||
bool mousePan(int8_t pan);
|
||||
};
|
||||
|
||||
#endif /* BLEHIDADAFRUIT_H_ */
|
||||
@@ -236,7 +236,7 @@ err_t BLEHidGeneric::begin(void)
|
||||
return ERROR_NONE;
|
||||
}
|
||||
|
||||
err_t BLEHidGeneric::inputReport(uint8_t reportID, void const* data, int len)
|
||||
bool BLEHidGeneric::inputReport(uint8_t reportID, void const* data, int len)
|
||||
{
|
||||
// 0 will treated as report ID = 1
|
||||
if ( reportID == 0 ) reportID++;
|
||||
|
||||
@@ -102,7 +102,7 @@ class BLEHidGeneric : public BLEService
|
||||
|
||||
virtual err_t begin(void);
|
||||
|
||||
err_t inputReport(uint8_t reportID, void const* data, int len);
|
||||
bool inputReport(uint8_t reportID, void const* data, int len);
|
||||
|
||||
protected:
|
||||
uint8_t _num_input;
|
||||
|
||||
@@ -349,7 +349,7 @@ bool BLEMidi::threeByteMessage( uint8_t status )
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Send Event (notify)
|
||||
*------------------------------------------------------------------*/
|
||||
err_t BLEMidi::send(uint8_t data[], uint8_t len)
|
||||
bool BLEMidi::send(uint8_t data[], uint8_t len)
|
||||
{
|
||||
uint32_t tstamp = millis();
|
||||
|
||||
@@ -369,12 +369,10 @@ err_t BLEMidi::send(uint8_t data[], uint8_t len)
|
||||
memcpy(event.data, data, len);
|
||||
|
||||
// send data length + 1 byte for header + 1 byte for timestamp
|
||||
VERIFY_STATUS( _io.notify(&event, len + 2) );
|
||||
|
||||
return ERROR_NONE;
|
||||
return _io.notify(&event, len + 2);
|
||||
}
|
||||
|
||||
err_t BLEMidi::sendSplit(uint8_t data[], uint8_t len)
|
||||
bool BLEMidi::sendSplit(uint8_t data[], uint8_t len)
|
||||
{
|
||||
uint32_t tstamp = millis();
|
||||
|
||||
@@ -390,7 +388,5 @@ err_t BLEMidi::sendSplit(uint8_t data[], uint8_t len)
|
||||
|
||||
// send data length + 1 byte for header
|
||||
// don't include the second timestamp byte
|
||||
VERIFY_STATUS( _io.notify(&event, len + 1) );
|
||||
|
||||
return ERROR_NONE;
|
||||
return _io.notify(&event, len + 1);
|
||||
}
|
||||
@@ -60,8 +60,8 @@ class BLEMidi: public BLEService, public Stream
|
||||
void begin(int baudrate); // MidiInterface
|
||||
bool notifyEnabled(void);
|
||||
|
||||
err_t send(uint8_t data[], uint8_t len);
|
||||
err_t sendSplit(uint8_t data[], uint8_t len);
|
||||
bool send(uint8_t data[], uint8_t len);
|
||||
bool sendSplit(uint8_t data[], uint8_t len);
|
||||
|
||||
// message type helpers
|
||||
bool isStatusByte(uint8_t b);
|
||||
|
||||
@@ -136,7 +136,7 @@ size_t BLEUart::write (uint8_t b)
|
||||
|
||||
size_t BLEUart::write (const uint8_t *content, size_t len)
|
||||
{
|
||||
return (_txd.notify(content, len) == ERROR_NONE) ? len : 0;
|
||||
return _txd.notify(content, len) ? len : 0;
|
||||
}
|
||||
|
||||
int BLEUart::available (void)
|
||||
|
||||
Reference in new issue
Block a user