티스토리 뷰
BilientSevices/MeasurementSystem[BMS]
[BMS] Command Process for Repeater
bizmaker 2020. 6. 12. 23:48bool h_TreatLoRaCommand(){
if(!(RxString_LoRa.startsWith("LR"))){
IsCommand2VIC = true;
Command2VIC = 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);
int CommandValue = RxString_LoRa.substring(Index2+1).toInt();
if(deviceName.equals(String(DEVICENAME))){
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;
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;
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;
}
반응형
'BilientSevices > MeasurementSystem[BMS]' 카테고리의 다른 글
[BMS] Firmware Sources for BMS Devices (0) | 2020.06.14 |
---|---|
[BMS] Data Display for Measured Data (0) | 2020.06.13 |
Data Display Test - Completed (0) | 2020.06.12 |
[BMS] Command Processor for Instrument (0) | 2020.06.11 |
[BMS] Command Process for Actuator (0) | 2020.06.10 |
반응형
250x250
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 빌리언트
- 배프
- Innovations&Hurdles
- image
- 허들
- 둎
- Innovations
- ServantClock
- Video
- BSC
- Innovation&Hurdles
- 오블완
- Decorator
- DYOV
- Hurdles
- 전압전류모니터링
- badp
- 전압
- 치매방지
- 전류
- 심심풀이치매방지기
- 심심풀이
- 혁신과허들
- bilient
- 혁신
- 아두이노
- arduino
- 절연형
- 티스토리챌린지
- 치매
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함