@@ -1463,25 +1463,51 @@ void handle_received_Messages(Controller_Model *Model){
14631463 }
14641464
14651465 case SET_SC_XBEE_MASK :
1466+ ;
1467+ uint16_t SC_mask = (frameBuffer [reply_Id ].data [0 ]<<8 ) + frameBuffer [reply_Id ].data [1 ];
14661468
1467- LVM .options -> SC_mask = (frameBuffer [reply_Id ].data [0 ]<<8 ) + frameBuffer [reply_Id ].data [1 ];
1468- LVM .options -> SC_mask_alerady_received = SC_already_received_Pattern ;
1469-
1470- // write new sc mask to eeprom
1471- eeprom_update_word (& LVM .eeprom -> eeOptions .SC_mask ,LVM .options -> SC_mask );
1472- eeprom_update_byte (& LVM .eeprom -> eeOptions .SC_mask_alerady_received ,LVM .options -> SC_mask_alerady_received );
1473-
1474- //refresh xbee parameters
1475- xbee_init (& paint_info_line ,LVM .vars -> Device_ID_Str ,DEV_ID_CHARS_MAX ,LVM .options -> SC_mask );
1476- xbee_Set_Scan_Channels (xbee .ScanChannels );
1477- xbee_WR ();
1478-
1479- //Send Status Ack
1480- LVM .temp -> buffer [0 ] = 0 ;
1481- xbee_send_message (SET_SC_XBEE_MASK ,LVM .temp -> buffer ,1 );
1469+ // check if received Mask is valid:
1470+ if (!(SC_mask & 0xE001 )){
1471+ LVM .options -> SC_mask = SC_mask ;
1472+ LVM .options -> SC_mask_alerady_received = SC_already_received_Pattern ;
1473+
1474+ // write new sc mask to eeprom
1475+ eeprom_update_word (& LVM .eeprom -> eeOptions .SC_mask ,LVM .options -> SC_mask );
1476+ eeprom_update_byte (& LVM .eeprom -> eeOptions .SC_mask_alerady_received ,LVM .options -> SC_mask_alerady_received );
1477+
1478+ //refresh xbee parameters
1479+ xbee_init (& paint_info_line ,LVM .vars -> Device_ID_Str ,DEV_ID_CHARS_MAX ,LVM .options -> SC_mask );
1480+ xbee_Set_Scan_Channels (xbee .ScanChannels );
1481+ xbee_WR ();
1482+
1483+ //Send Status Ack
1484+ LVM .temp -> buffer [0 ] = 0 ;
1485+ xbee_send_message (SET_SC_XBEE_MASK ,LVM .temp -> buffer ,1 );
1486+ }
1487+ else {
1488+ //Send Status Ack
1489+ LVM .temp -> buffer [0 ] = 1 ;
1490+ xbee_send_message (SET_SC_XBEE_MASK ,LVM .temp -> buffer ,1 );
1491+
1492+ }
14821493 break ;
1483-
14841494
1495+ case GET_SC_XBEE_MASK :
1496+ ;
1497+ index = 0 ;
1498+ LVM .temp -> buffer [index ++ ] = LVM .options -> SC_mask >> 8 ;
1499+ LVM .temp -> buffer [index ++ ] = LVM .options -> SC_mask ;
1500+ LVM .temp -> buffer [index ++ ] = get_status_byte_levelmeter ();
1501+
1502+ // Pack full frame with 64-bit address (neither acknowledgment nor response frame), then send to the database server
1503+ if (xbee_send_message (GET_SC_XBEE_MASK , LVM .temp -> buffer , index ))
1504+ {
1505+ CLEAR_ALL (); // Clear all errors
1506+ }
1507+
1508+
1509+ break ;
1510+
14851511 case DEPRECATED_ILM_BROADCAST : // ILM messages are sent in broadcast mode and are ignored by other devices
14861512 break ;
14871513
0 commit comments