-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMBusExamples.cs
58 lines (50 loc) · 4.36 KB
/
MBusExamples.cs
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#region License
// Copyright (c) 2019 smart-me AG https://www.smart-me.com/
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#endregion
using SmartMeApiClient;
using SmartMeApiClient.Containers;
using System;
using System.Threading.Tasks;
namespace Example
{
public class MBusExamples
{
public static async Task SendMBusDataAsync(UserPassword credentials)
{
// Send MBus Data
{
Helpers.WriteConsoleTitle("Send MBus Data");
// Example 1: Heat Meter
var telegram = new byte[] { 0x68, 0x7A, 0x7A, 0x68, 0x08, 0x00, 0x72, 0x71, 0x76, 0x22, 0x15, 0xEE, 0x4D, 0x19, 0x04, 0x15, 0x00, 0x00, 0x00, 0x04, 0x06, 0x00, 0x00, 0x00, 0x00, 0x84, 0x0A, 0x06, 0x00, 0x00, 0x00, 0x00, 0x04, 0x14, 0x0B, 0x00, 0x00, 0x00, 0x84, 0x0A, 0x14, 0x00, 0x00, 0x00, 0x00, 0x0B, 0xFD, 0x0F, 0x00, 0x03, 0x01, 0x0A, 0xFD, 0x0D, 0x00, 0x11, 0x05, 0xFF, 0x01, 0xF2, 0x4E, 0x2E, 0x3C, 0x05, 0xFF, 0x02, 0x85, 0xDA, 0x50, 0x3F, 0x0C, 0x78, 0x71, 0x76, 0x22, 0x15, 0x04, 0x6D, 0x2F, 0x0B, 0xDB, 0x18, 0x82, 0x0A, 0x6C, 0xE1, 0xF1, 0x05, 0x5B, 0x00, 0x9A, 0xB8, 0x41, 0x05, 0x5F, 0x80, 0x00, 0xB2, 0x41, 0x05, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x05, 0x2B, 0x00, 0x00, 0x00, 0x00, 0x01, 0xFF, 0x2B, 0x00, 0x03, 0x22, 0x29, 0x02, 0x00, 0x02, 0xFF, 0x2C, 0x00, 0x00, 0x1F, 0x59, 0x16 };
await MBusApi.SendTelegramAsync(credentials, new MBusData
{
Date = DateTime.UtcNow,
Telegram = BitConverter.ToString(telegram).Replace("-", "")
});
// Example 2: Electricity Meter
telegram = new byte[] { 0x68, 0xF4, 0xF4, 0x68, 0x08, 0x0F, 0x72, 0x33, 0x33, 0x33, 0x33, 0xB5, 0x15, 0x10, 0x02, 0xDB, 0x00, 0x00, 0x00, 0x0C, 0x78, 0x00, 0x00, 0x15, 0x20, 0x84, 0x10, 0x03, 0xEE, 0x24, 0x00, 0x00, 0x84, 0x20, 0x03, 0x00, 0x00, 0x00, 0x00, 0x84, 0x90, 0x40, 0x03, 0xA1, 0x5F, 0x00, 0x00, 0x84, 0xA0, 0x40, 0x03, 0x00, 0x00, 0x00, 0x00, 0x04, 0xAB, 0xFF, 0x01, 0x01, 0x00, 0x00, 0x00, 0x04, 0xAB, 0xFF, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0xAB, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x04, 0x2B, 0x01, 0x00, 0x00, 0x00, 0x84, 0x80, 0x40, 0xAB, 0xFF, 0x01, 0x0B, 0x00, 0x00, 0x00, 0x84, 0x80, 0x40, 0xAB, 0xFF, 0x02, 0x00, 0x00, 0x00, 0x00, 0x84, 0x80, 0x40, 0xAB, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x00, 0x84, 0x80, 0x40, 0x2B, 0x0B, 0x00, 0x00, 0x00, 0x02, 0xFD, 0xC8, 0xFF, 0x01, 0x8D, 0x09, 0x02, 0xFD, 0xC8, 0xFF, 0x02, 0x00, 0x00, 0x02, 0xFD, 0xC8, 0xFF, 0x03, 0x00, 0x00, 0x22, 0xFD, 0xC8, 0xFF, 0x01, 0xCA, 0x08, 0x22, 0xFD, 0xC8, 0xFF, 0x02, 0x00, 0x00, 0x22, 0xFD, 0xC8, 0xFF, 0x03, 0x00, 0x00, 0x12, 0xFD, 0xC8, 0xFF, 0x01, 0x0B, 0x0A, 0x12, 0xFD, 0xC8, 0xFF, 0x02, 0x0D, 0x0A, 0x12, 0xFD, 0xC8, 0xFF, 0x03, 0x0D, 0x0A, 0x03, 0xFD, 0xD9, 0xFF, 0x01, 0x2E, 0x00, 0x00, 0x03, 0xFD, 0xD9, 0xFF, 0x02, 0x00, 0x00, 0x00, 0x03, 0xFD, 0xD9, 0xFF, 0x03, 0x00, 0x00, 0x00, 0x03, 0xFD, 0x59, 0x2E, 0x00, 0x00, 0x01, 0xFF, 0xE1, 0xFF, 0x01, 0x10, 0x01, 0xFF, 0xE1, 0xFF, 0x02, 0x00, 0x01, 0xFF, 0xE1, 0xFF, 0x03, 0x00, 0x02, 0xFF, 0x52, 0xF4, 0x01, 0x02, 0xFD, 0x60, 0x2C, 0x00, 0x01, 0xFD, 0x17, 0x00, 0x8D, 0x16 };
await MBusApi.SendTelegramAsync(credentials, new MBusData
{
Date = DateTime.UtcNow,
Telegram = BitConverter.ToString(telegram).Replace("-", "")
});
}
}
}
}