Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add packet metamodel and first version of packet catalog file. Genera…
…te headers and use them in temp sensor.
- Loading branch information
Showing
11 changed files
with
786 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* This file is part of smarthomatic, http://www.smarthomatic.org. | ||
* Copyright (c) 2013 Uwe Freese | ||
* | ||
* smarthomatic is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. | ||
* | ||
* smarthomatic is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with smarthomatic. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
* ! WARNING: This file is generated by the SHC EEPROM editor and should ! | ||
* ! never be modified manually. ! | ||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
*/ | ||
|
||
#include "packet_header.h" | ||
#include "e2p_access.h" | ||
|
||
// Message Group "generic" | ||
// ======================= | ||
// MessageGroupID: 0 | ||
// Description: This group contains messages useful for different devices. | ||
|
||
|
||
// Message "generic_genericack" | ||
// ---------------------------- | ||
// MessageGroupID: 0 | ||
// MessageID: 0 | ||
// MessageType: 0 | ||
// Data fields: SenderID, PacketCounter | ||
// length: 116 bits (needs 15 bytes) | ||
|
||
// Function to initialize header for the message. | ||
static inline void pkg_header_init_generic_genericack(void) | ||
{ | ||
memset(&bufx[0], 0, sizeof(bufx)); | ||
pkg_header_set_messagegroupid(0); | ||
pkg_header_set_messageid(0); | ||
pkg_header_set_messagetype(0); | ||
} | ||
|
||
// Function to set CRC value after all data fields are set. | ||
static inline void pkg_header_crc32_generic_genericack(void) | ||
{ | ||
pkg_header_set_crc32(crc32(bufx + 4, 12)); | ||
} | ||
|
||
// Set SenderID (UIntValue) | ||
// byte 10, bit 0, length bits 12, min val 0, max val 4095 | ||
static inline void msg_generic_genericack_set_senderid(uint32_t val) | ||
{ | ||
array_write_UIntValue(10, 0, 12, val, bufx); | ||
} | ||
|
||
// Set PacketCounter (UIntValue) | ||
// byte 11, bit 4, length bits 24, min val 0, max val 16777215 | ||
static inline void msg_generic_genericack_set_packetcounter(uint32_t val) | ||
{ | ||
array_write_UIntValue(11, 4, 24, val, bufx); | ||
} | ||
|
||
|
||
// Message "generic_batterystatus" | ||
// ------------------------------- | ||
// MessageGroupID: 0 | ||
// MessageID: 5 | ||
// MessageType: 0 | ||
// Data fields: Percentage | ||
// length: 87 bits (needs 11 bytes) | ||
|
||
// Function to initialize header for the message. | ||
static inline void pkg_header_init_generic_batterystatus(void) | ||
{ | ||
memset(&bufx[0], 0, sizeof(bufx)); | ||
pkg_header_set_messagegroupid(0); | ||
pkg_header_set_messageid(5); | ||
pkg_header_set_messagetype(0); | ||
} | ||
|
||
// Function to set CRC value after all data fields are set. | ||
static inline void pkg_header_crc32_generic_batterystatus(void) | ||
{ | ||
pkg_header_set_crc32(crc32(bufx + 4, 12)); | ||
} | ||
|
||
// Set Percentage (UIntValue) | ||
// byte 10, bit 0, length bits 7, min val 0, max val 100 | ||
static inline void msg_generic_batterystatus_set_percentage(uint32_t val) | ||
{ | ||
array_write_UIntValue(10, 0, 7, val, bufx); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* This file is part of smarthomatic, http://www.smarthomatic.org. | ||
* Copyright (c) 2013 Uwe Freese | ||
* | ||
* smarthomatic is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. | ||
* | ||
* smarthomatic is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with smarthomatic. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
* ! WARNING: This file is generated by the SHC EEPROM editor and should ! | ||
* ! never be modified manually. ! | ||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
*/ | ||
|
||
#include "packet_header.h" | ||
#include "e2p_access.h" | ||
|
||
// Message Group "tempsensor" | ||
// ========================== | ||
// MessageGroupID: 10 | ||
|
||
|
||
// Message "tempsensor_tempstatus" | ||
// ------------------------------- | ||
// MessageGroupID: 10 | ||
// MessageID: 1 | ||
// MessageType: 0 | ||
// Data fields: Temperature, Humidity, Brightness | ||
// length: 113 bits (needs 15 bytes) | ||
|
||
// Function to initialize header for the message. | ||
static inline void pkg_header_init_tempsensor_tempstatus(void) | ||
{ | ||
memset(&bufx[0], 0, sizeof(bufx)); | ||
pkg_header_set_messagegroupid(10); | ||
pkg_header_set_messageid(1); | ||
pkg_header_set_messagetype(0); | ||
} | ||
|
||
// Function to set CRC value after all data fields are set. | ||
static inline void pkg_header_crc32_tempsensor_tempstatus(void) | ||
{ | ||
pkg_header_set_crc32(crc32(bufx + 4, 12)); | ||
} | ||
|
||
// Set Temperature (IntValue) | ||
// byte 10, bit 0, length bits 16, min val -32768, max val 32767 | ||
static inline void msg_tempsensor_tempstatus_set_temperature(int32_t val) | ||
{ | ||
array_write_IntValue(10, 0, 16, val, bufx); | ||
} | ||
|
||
// Set Humidity (UIntValue) | ||
// byte 12, bit 0, length bits 10, min val 0, max val 1000 | ||
static inline void msg_tempsensor_tempstatus_set_humidity(uint32_t val) | ||
{ | ||
array_write_UIntValue(12, 0, 10, val, bufx); | ||
} | ||
|
||
// Set Brightness (UIntValue) | ||
// byte 13, bit 2, length bits 7, min val 0, max val 100 | ||
static inline void msg_tempsensor_tempstatus_set_brightness(uint32_t val) | ||
{ | ||
array_write_UIntValue(13, 2, 7, val, bufx); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* This file is part of smarthomatic, http://www.smarthomatic.org. | ||
* Copyright (c) 2013 Uwe Freese | ||
* | ||
* smarthomatic is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation, either version 3 of the License, or (at your | ||
* option) any later version. | ||
* | ||
* smarthomatic is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along | ||
* with smarthomatic. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
* ! WARNING: This file is generated by the SHC EEPROM editor and should ! | ||
* ! never be modified manually. ! | ||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | ||
*/ | ||
|
||
#ifndef _PACKET_HEADER_H | ||
#define _PACKET_HEADER_H | ||
|
||
#include "util.h" | ||
#include "e2p_access.h" | ||
|
||
// Set CRC32 (UIntValue) | ||
// byte 0, bit 0, length bits 32, min val 0, max val 4294967295 | ||
static inline void pkg_header_set_crc32(uint32_t val) | ||
{ | ||
array_write_UIntValue(0, 0, 32, val, bufx); | ||
} | ||
|
||
// Set SenderID (UIntValue) | ||
// byte 4, bit 0, length bits 12, min val 0, max val 4095 | ||
static inline void pkg_header_set_senderid(uint32_t val) | ||
{ | ||
array_write_UIntValue(4, 0, 12, val, bufx); | ||
} | ||
|
||
// Set PacketCounter (UIntValue) | ||
// byte 5, bit 4, length bits 24, min val 0, max val 16777215 | ||
static inline void pkg_header_set_packetcounter(uint32_t val) | ||
{ | ||
array_write_UIntValue(5, 4, 24, val, bufx); | ||
} | ||
|
||
// Set MessageGroupID (UIntValue) | ||
// byte 8, bit 4, length bits 4, min val 0, max val 15 | ||
static inline void pkg_header_set_messagegroupid(uint32_t val) | ||
{ | ||
array_write_UIntValue(8, 4, 4, val, bufx); | ||
} | ||
|
||
// Set MessageID (UIntValue) | ||
// byte 9, bit 0, length bits 7, min val 0, max val 127 | ||
static inline void pkg_header_set_messageid(uint32_t val) | ||
{ | ||
array_write_UIntValue(9, 0, 7, val, bufx); | ||
} | ||
|
||
// Set MessageType (EnumValue) | ||
// byte 9, bit 7, length bits 1 | ||
|
||
typedef enum { | ||
MESSAGETYPE_STATUS = 0, | ||
MESSAGETYPE_REQUEST = 1 | ||
} MessageTypeEnum; | ||
static inline void pkg_header_set_messagetype(MessageTypeEnum val) | ||
{ | ||
array_write_UIntValue(9, 7, 1, val, bufx); | ||
} | ||
|
||
|
||
// overall length: 80 bits | ||
|
||
#endif /* _PACKET_HEADER_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<Project name="src_common"><File path="uart.c"></File><File path="uart.h"></File><File path="util.c"></File><File path="util.h"></File><File path="aes256.c"></File><File path="aes256.h"></File><File path="e2p_access.c"></File><File path="e2p_access.h"></File></Project> | ||
<Project name="src_common"><File path="uart.c"></File><File path="uart.h"></File><File path="util.h"></File><File path="aes256.c"></File><File path="aes256.h"></File><File path="e2p_access.c"></File><File path="e2p_access.h"></File><File path="util.c"></File><File path="msggrp_tempsensor.h"></File><File path="msggrp_generic.h"></File><File path="packet_header.h"></File></Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.