티스토리 뷰
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
- 치매
- 티스토리챌린지
- 허들
- 빌리칠드
- image
- DYOV
- 혁신과허들
- 아두이노
- 둎
- 전압
- arduino
- 절연형
- 치매방지
- Innovations
- 혁신
- bilient
- BiliChild
- Innovations&Hurdles
- 심심풀이치매방지기
- Decorator
- Innovation&Hurdles
- 오블완
- Video
- ServantClock
- BSC
- 배프
- 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 | 29 | 30 | 31 |
글 보관함

