Skip to content

Commit

Permalink
mcu sensor p1
Browse files Browse the repository at this point in the history
  • Loading branch information
openshwprojects committed Aug 13, 2022
1 parent 83bc016 commit be6f6c3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/driver/drv_local.h
Expand Up @@ -28,5 +28,4 @@ void BL09XX_AppendInformationToHTTPIndexPage(http_request_t *request);
bool DRV_IsRunning(const char *name);




void TuyaMCU_Sensor_RunFrame();
1 change: 1 addition & 0 deletions src/driver/drv_main.c
Expand Up @@ -36,6 +36,7 @@ static driver_t g_drivers[] = {
#endif
{ "SM2135", SM2135_Init, SM2135_RunFrame, NULL, NULL, NULL, SM2135_OnChannelChanged, false },
{ "BP5758D", BP5758D_Init, BP5758D_RunFrame, NULL, NULL, NULL, BP5758D_OnChannelChanged, false },
{ "tmSensor", NULL, TuyaMCU_Sensor_RunFrame, NULL, NULL, NULL, NULL, false },
};

static int g_numDrivers = sizeof(g_drivers)/sizeof(g_drivers[0]);
Expand Down
8 changes: 8 additions & 0 deletions src/driver/drv_tuyaMCU.c
Expand Up @@ -457,6 +457,13 @@ int TuyaMCU_Fake_Hex(const void *context, const char *cmd, const char *args, int
}
return 1;
}
void TuyaMCU_Send_RawBuffer(byte *data, int len) {
int i;

for(i = 0; i < len; i++) {
UART_SendByte(data[i]);
}
}
int TuyaMCU_Send_Hex(const void *context, const char *cmd, const char *args, int cmdFlags) {
//const char *args = CMD_GetArg(1);
if(!(*args)) {
Expand All @@ -481,6 +488,7 @@ int TuyaMCU_LinkTuyaMCUOutputToChannel(const void *context, const char *cmd, con
int channelID;

// linkTuyaMCUOutputToChannel dpId varType channelID
// linkTuyaMCUOutputToChannel 1 val 1
Tokenizer_TokenizeString(args);

if(Tokenizer_GetArgsCount() < 3) {
Expand Down
1 change: 1 addition & 0 deletions src/driver/drv_tuyaMCU.h
Expand Up @@ -4,3 +4,4 @@ void TuyaMCU_Init();
void TuyaMCU_RunFrame();
void TuyaMCU_Send(byte *data, int size);
void TuyaMCU_OnChannelChanged(int channel,int iVal);
void TuyaMCU_Send_RawBuffer(byte *data, int len);
25 changes: 25 additions & 0 deletions src/driver/drv_tuyaMCUSensor.c
@@ -0,0 +1,25 @@

#include "../new_common.h"
#include "../new_pins.h"
#include "../new_cfg.h"
// Commands register, execution API and cmd tokenizer
#include "../cmnds/cmd_public.h"
#include "../logging/logging.h"
#include "drv_tuyaMCU.h"
#include "drv_uart.h"
#include <time.h>
#include "drv_ntp.h"

static int g_elapsedTime = 0;

static byte g_hello[] = { 0x55, 0xAA, 0x00, 0x01, 0x00, 0x00, 0x00 };
void TuyaMCU_Sensor_RunFrame() {

g_elapsedTime++;

if(g_elapsedTime == 5) {
TuyaMCU_Send_RawBuffer(g_hello,sizeof(g_hello));
}
}


0 comments on commit be6f6c3

Please sign in to comment.