mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2025-10-29 11:33:20 +00:00
noread
This commit is contained in:
parent
e930bd2d75
commit
f46a74b843
@ -67,7 +67,8 @@ static byte g_tuyaMCUConfirmationsToSend_0x08 = 0;
|
||||
static byte g_tuyaMCUConfirmationsToSend_0x05 = 0;
|
||||
static byte g_resetWiFiEvents = 0;
|
||||
|
||||
|
||||
#define OBKTM_FLAG_DPCACHE 1
|
||||
#define OBKTM_FLAG_NOREAD 2
|
||||
|
||||
//=============================================================================
|
||||
//dp data point type
|
||||
@ -161,7 +162,7 @@ typedef struct tuyaMCUMapping_s {
|
||||
// data point type (one of the DP_TYPE_xxx defines)
|
||||
byte dpType;
|
||||
// true if it's supposed to be sent in dp cache
|
||||
byte bDPCache;
|
||||
byte obkFlags;
|
||||
// could be renamed to flags later?
|
||||
byte inv;
|
||||
// target channel
|
||||
@ -336,7 +337,7 @@ tuyaMCUMapping_t* TuyaMCU_FindDefForChannel(int channel) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
tuyaMCUMapping_t* TuyaMCU_MapIDToChannel(int dpId, int dpType, int channel, int bDPCache, float mul, int inv, float delta, float delta2, float delta3) {
|
||||
tuyaMCUMapping_t* TuyaMCU_MapIDToChannel(int dpId, int dpType, int channel, int obkFlags, float mul, int inv, float delta, float delta2, float delta3) {
|
||||
tuyaMCUMapping_t* cur;
|
||||
|
||||
cur = TuyaMCU_FindDefForID(dpId);
|
||||
@ -351,7 +352,7 @@ tuyaMCUMapping_t* TuyaMCU_MapIDToChannel(int dpId, int dpType, int channel, int
|
||||
}
|
||||
cur->dpId = dpId;
|
||||
cur->dpType = dpType;
|
||||
cur->bDPCache = bDPCache;
|
||||
cur->obkFlags = obkFlags;
|
||||
cur->mult = mul;
|
||||
cur->delta = delta;
|
||||
cur->delta2 = delta2;
|
||||
@ -873,11 +874,11 @@ commandResult_t TuyaMCU_LinkTuyaMCUOutputToChannel(const void* context, const ch
|
||||
byte dpType;
|
||||
int channelID;
|
||||
byte argsCount;
|
||||
byte bDPCache;
|
||||
byte obkFlags;
|
||||
float mult, delta, delta2, delta3;
|
||||
byte inv;
|
||||
|
||||
// linkTuyaMCUOutputToChannel [dpId] [varType] [channelID] [bDPCache] [mult] [inv] [delta]
|
||||
// linkTuyaMCUOutputToChannel [dpId] [varType] [channelID] [obkFlags] [mult] [inv] [delta]
|
||||
// linkTuyaMCUOutputToChannel 1 val 1
|
||||
Tokenizer_TokenizeString(args, 0);
|
||||
|
||||
@ -897,14 +898,14 @@ commandResult_t TuyaMCU_LinkTuyaMCUOutputToChannel(const void* context, const ch
|
||||
else {
|
||||
channelID = Tokenizer_GetArgInteger(2);
|
||||
}
|
||||
bDPCache = Tokenizer_GetArgInteger(3);
|
||||
obkFlags = Tokenizer_GetArgInteger(3);
|
||||
mult = Tokenizer_GetArgFloatDefault(4, 1.0f);
|
||||
inv = Tokenizer_GetArgInteger(5);
|
||||
delta = Tokenizer_GetArgFloatDefault(6, 0.0f);
|
||||
delta2 = Tokenizer_GetArgFloatDefault(7, 0.0f);
|
||||
delta3 = Tokenizer_GetArgFloatDefault(8, 0.0f);
|
||||
|
||||
TuyaMCU_MapIDToChannel(dpId, dpType, channelID, bDPCache, mult, inv, delta, delta2, delta3);
|
||||
TuyaMCU_MapIDToChannel(dpId, dpType, channelID, obkFlags, mult, inv, delta, delta2, delta3);
|
||||
|
||||
return CMD_RES_OK;
|
||||
}
|
||||
@ -1119,6 +1120,10 @@ void TuyaMCU_ForcePublishChannelValues() {
|
||||
void TuyaMCU_ApplyMapping(tuyaMCUMapping_t* mapping, int dpID, int value) {
|
||||
int mappedValue = value;
|
||||
|
||||
if (mapping->obkFlags & OBKTM_FLAG_NOREAD) {
|
||||
// ignore
|
||||
return;
|
||||
}
|
||||
// hardcoded values
|
||||
#if ENABLE_LED_BASIC
|
||||
if (dpID == g_tuyaMCUled_id_power) {
|
||||
@ -1206,7 +1211,7 @@ void TuyaMCU_OnChannelChanged(int channel, int iVal) {
|
||||
}
|
||||
|
||||
// dpCaches are sent when requested - TODO - is it correct?
|
||||
if (mapping->bDPCache) {
|
||||
if (mapping->obkFlags & OBKTM_FLAG_DPCACHE) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1854,7 +1859,7 @@ void TuyaMCU_V0_SendDPCacheReply() {
|
||||
// dpId = 18 Len = 0004 Val V = 1
|
||||
//
|
||||
while (map) {
|
||||
if (map->bDPCache) {
|
||||
if (map->obkFlags & OBKTM_FLAG_DPCACHE) {
|
||||
writtenCount++;
|
||||
// dpID
|
||||
*p = map->dpId;
|
||||
@ -2644,8 +2649,8 @@ void TuyaMCU_Init()
|
||||
//cmddetail:"fn":"TuyaMCU_Send_SetTime_Current","file":"driver/drv_tuyaMCU.c","requires":"",
|
||||
//cmddetail:"examples":""}
|
||||
CMD_RegisterCommand("tuyaMcu_sendCurTime", TuyaMCU_Send_SetTime_Current, NULL);
|
||||
//cmddetail:{"name":"linkTuyaMCUOutputToChannel","args":"[dpId][varType][channelID][bDPCache-Optional][mult-optional][bInverse-Optional][delta-Optional][delta2][delta3]",
|
||||
//cmddetail:"descr":"Used to map between TuyaMCU dpIDs and our internal channels. Mult, inverse and delta are for calibration, they are optional. bDPCache is also optional, you can set it to 1 for battery powered devices, so a variable is set with DPCache, for example a sampling interval for humidity/temperature sensor. Mapping works both ways. DpIDs are per-device, you can get them by sniffing UART communication. Vartypes can also be sniffed from Tuya. VarTypes can be following: 0-raw, 1-bool, 2-value, 3-string, 4-enum, 5-bitmap. Please see [Tuya Docs](https://developer.tuya.com/en/docs/iot/tuya-cloud-universal-serial-port-access-protocol?id=K9hhi0xxtn9cb) for info about TuyaMCU. You can also see our [TuyaMCU Analyzer Tool](https://www.elektroda.com/rtvforum/viewtopic.php?p=20528459#20528459)",
|
||||
//cmddetail:{"name":"linkTuyaMCUOutputToChannel","args":"[dpId][varType][channelID][obkFlags-Optional][mult-optional][bInverse-Optional][delta-Optional][delta2][delta3]",
|
||||
//cmddetail:"descr":"Used to map between TuyaMCU dpIDs and our internal channels. Mult, inverse and delta are for calibration, they are optional. obkFlags is also optional, you can set it to 1 for battery powered devices, so a variable is set with DPCache, for example a sampling interval for humidity/temperature sensor. Mapping works both ways. DpIDs are per-device, you can get them by sniffing UART communication. Vartypes can also be sniffed from Tuya. VarTypes can be following: 0-raw, 1-bool, 2-value, 3-string, 4-enum, 5-bitmap. Please see [Tuya Docs](https://developer.tuya.com/en/docs/iot/tuya-cloud-universal-serial-port-access-protocol?id=K9hhi0xxtn9cb) for info about TuyaMCU. You can also see our [TuyaMCU Analyzer Tool](https://www.elektroda.com/rtvforum/viewtopic.php?p=20528459#20528459)",
|
||||
//cmddetail:"fn":"TuyaMCU_LinkTuyaMCUOutputToChannel","file":"driver/drv_tuyaMCU.c","requires":"",
|
||||
//cmddetail:"examples":""}
|
||||
CMD_RegisterCommand("linkTuyaMCUOutputToChannel", TuyaMCU_LinkTuyaMCUOutputToChannel, NULL);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user