티스토리 뷰
bool h_TreatLoRaCommand(){
if(!(RxString_LoRa.startsWith("LR"))){
// RxString_LoRa : "CD1.01/P4:0"
IsCommand2Subdevice = true;
Command2Subdevice = RxString_LoRa;
return false;
}
int Index1 = RxString_LoRa.indexOf('/');
if(Index1 < 1) return false;
int Index2 = RxString_LoRa.indexOf(':');
if(Index2 < Index1) return false;
char DataType0 = RxString_LoRa.charAt(Index1+1);
char DataType1 = RxString_LoRa.charAt(Index1+2);
String deviceName = RxString_LoRa.substring(0, Index1);
String ValueString = RxString_LoRa.substring(Index2+1);
int CommandValue = -1;
if(deviceName.equals(String(DEVICENAME))){
StartTime_LastRequest = millis();
CommandValue = ValueString.toInt();
switch(DataType0){
case 'C':
if(DataType1 == 'P') h_ClearDeviceParameters();
if(DataType1 == 'A') h_ClearDeviceAddress();
break;
case 'A':
if(DataType1 == '?') h_RespondDeviceAddress(deviceName, CommandValue);
if(DataType1 == 'D') h_ReceiveACK(deviceName, CommandValue);
break;
case 'D':
if(IsRegistered){
if(DataType1 == '?') h_SendVICData(deviceName);
}
break;
case 'P':
{
int PortNo = -1;
if(DataType1 == 'R'){ // RELAY
PortNo = PIN_RELAY;
if(CommandValue == 1) IsPowerON = true;
if(CommandValue == 0) IsPowerON = false;
}else if(DataType1 == 'O'){
PortNo = PIN_BUZZER;
}else{
PortNo = (int)(String(DataType1).toInt());
if(PortNo == 0) return false;
}
if(CommandValue == 1) digitalWrite(PortNo, HIGH);
if(CommandValue == 0) digitalWrite(PortNo, LOW);
}
break;
case 'L': // list of device
if(DataType1 != 'D') break;
b_SendVICList();
break;
default:
return false;
}
}else if(deviceName.equals(String(ALLLORADEVICES))){
if(IsRegistered) return false;
CommandValue = ValueString.toInt();
StartTime_LastRequest = millis();
switch(DataType0){
case 'C':
if(DataType1 == 'P') h_ClearDeviceParameters();
if(DataType1 == 'A') h_ClearDeviceAddress();
break;
case 'A':
if(DataType1 == '?') h_RespondDeviceAddress(deviceName, CommandValue);
if(DataType1 == 'D') h_ReceiveACK(deviceName, CommandValue);
break;
default:
return false;
}
}
return true;
}
반응형
'SWDesk > Firmware' 카테고리의 다른 글
[BMS] Command Process for VIC Instrument (0) | 2020.07.19 |
---|---|
[BMS] Command Process for CD Devices (0) | 2020.07.19 |
[BMS] Command Process for Master (0) | 2020.07.19 |
[BPM] Firmware Source for Master (0) | 2020.06.15 |
IFTTT with Arduino (0) | 2020.05.10 |
반응형
250x250
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- DYOV
- 전압
- 허들
- 전압전류모니터링
- image
- bilient
- 오블완
- Innovations&Hurdles
- 아두이노
- 치매
- 혁신과허들
- 배프
- badp
- Innovations
- 치매방지
- 심심풀이치매방지기
- 혁신
- Hurdles
- Decorator
- BSC
- 티스토리챌린지
- ServantClock
- arduino
- 심심풀이
- Video
- 절연형
- 둎
- 빌리언트
- 전류
- Innovation&Hurdles
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함