mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 11:46:31 +00:00
Merge pull request #8272 from joerg555/development
Nimble no warnig, optimise CommandHandler()
This commit is contained in:
commit
c0bc7abeee
@ -39,7 +39,7 @@ static const char* LOG_TAG = "NimBLEDevice";
|
|||||||
/**
|
/**
|
||||||
* Singletons for the NimBLEDevice.
|
* Singletons for the NimBLEDevice.
|
||||||
*/
|
*/
|
||||||
bool initialized = false;
|
bool NimBLEDevice_initialized = false;
|
||||||
NimBLEScan* NimBLEDevice::m_pScan = nullptr;
|
NimBLEScan* NimBLEDevice::m_pScan = nullptr;
|
||||||
NimBLEServer* NimBLEDevice::m_pServer = nullptr;
|
NimBLEServer* NimBLEDevice::m_pServer = nullptr;
|
||||||
uint32_t NimBLEDevice::m_passkey = 123456;
|
uint32_t NimBLEDevice::m_passkey = 123456;
|
||||||
@ -409,8 +409,8 @@ void NimBLEDevice::stopAdvertising() {
|
|||||||
* @param deviceName The device name of the device.
|
* @param deviceName The device name of the device.
|
||||||
*/
|
*/
|
||||||
/* STATIC */ void NimBLEDevice::init(std::string deviceName) {
|
/* STATIC */ void NimBLEDevice::init(std::string deviceName) {
|
||||||
if(!initialized){
|
if(!NimBLEDevice_initialized){
|
||||||
initialized = true; // Set the initialization flag to ensure we are only initialized once.
|
NimBLEDevice_initialized = true; // Set the initialization flag to ensure we are only initialized once.
|
||||||
|
|
||||||
int rc=0;
|
int rc=0;
|
||||||
esp_err_t errRc = ESP_OK;
|
esp_err_t errRc = ESP_OK;
|
||||||
@ -476,7 +476,7 @@ void NimBLEDevice::stopAdvertising() {
|
|||||||
NIMBLE_LOGE(LOG_TAG, "esp_nimble_hci_and_controller_deinit() failed with error: %d", ret);
|
NIMBLE_LOGE(LOG_TAG, "esp_nimble_hci_and_controller_deinit() failed with error: %d", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
initialized = false;
|
NimBLEDevice_initialized = false;
|
||||||
}
|
}
|
||||||
} // deinit
|
} // deinit
|
||||||
|
|
||||||
@ -485,7 +485,7 @@ void NimBLEDevice::stopAdvertising() {
|
|||||||
* @brief Check if the initialization is complete.
|
* @brief Check if the initialization is complete.
|
||||||
*/
|
*/
|
||||||
bool NimBLEDevice::getInitialized() {
|
bool NimBLEDevice::getInitialized() {
|
||||||
return initialized;
|
return NimBLEDevice_initialized;
|
||||||
} // getInitialized
|
} // getInitialized
|
||||||
|
|
||||||
|
|
||||||
|
@ -330,8 +330,11 @@ static inline void net_buf_simple_restore(struct os_mbuf *buf,
|
|||||||
buf->om_len = state->len;
|
buf->om_len = state->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void sys_memcpy_swap(void *dst, const void *src, size_t length)
|
static inline void sys_memcpy_swap(void *destination, const void *source, size_t length)
|
||||||
{
|
{
|
||||||
|
u8_t *dst = destination;
|
||||||
|
const u8_t *src = source;
|
||||||
|
|
||||||
__ASSERT(((src < dst && (src + length) <= dst) ||
|
__ASSERT(((src < dst && (src + length) <= dst) ||
|
||||||
(src > dst && (dst + length) <= src)),
|
(src > dst && (dst + length) <= src)),
|
||||||
"Source and destination buffers must not overlap");
|
"Source and destination buffers must not overlap");
|
||||||
@ -339,7 +342,7 @@ static inline void sys_memcpy_swap(void *dst, const void *src, size_t length)
|
|||||||
src += length - 1;
|
src += length - 1;
|
||||||
|
|
||||||
for (; length > 0; length--) {
|
for (; length > 0; length--) {
|
||||||
*((u8_t *)dst++) = *((u8_t *)src--);
|
*dst++ = *src--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,14 +204,19 @@ void CommandHandler(char* topicBuf, char* dataBuf, uint32_t data_len)
|
|||||||
if (type != nullptr) {
|
if (type != nullptr) {
|
||||||
type++;
|
type++;
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
for (i = 0; i < strlen(type); i++) {
|
int nLen; // strlen(type)
|
||||||
type[i] = toupper(type[i]);
|
char *s = type;
|
||||||
|
for (nLen = 0; *s; s++, nLen++) {
|
||||||
|
*s=toupper(*s);
|
||||||
}
|
}
|
||||||
while (isdigit(type[i-1])) {
|
i = nLen;
|
||||||
i--;
|
if (i > 0) { // may be 0
|
||||||
|
while (isdigit(type[i-1])) {
|
||||||
|
i--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (i < strlen(type)) {
|
if (i < nLen) {
|
||||||
index = atoi(type +i);
|
index = atoi(type + i);
|
||||||
user_index = true;
|
user_index = true;
|
||||||
}
|
}
|
||||||
type[i] = '\0';
|
type[i] = '\0';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user