-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.h
122 lines (102 loc) · 4.85 KB
/
config.h
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
config.h - Modem persistent configuration
Copyright (C) 2018 Costin STROIE <[email protected]>
This program 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.
This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONFIG_H
#define CONFIG_H
#include <Arduino.h>
#include <EEPROM.h>
// Include local configuration
#include "local.h"
// Sampling frequency
#define F_SAMPLE 9600
// Software name and vesion
const char DEVNAME[] PROGMEM = "Arabell300";
const char VERSION[] PROGMEM = "v3.58";
const char AUTHOR[] PROGMEM = "Costin Stroie <[email protected]>";
const char DESCRP[] PROGMEM = "Arduino based Bell 103 and ITU V.21 AFSK modem";
const char FTRS[] PROGMEM = "a0020400080004000\r\nb000008\r\nr1001000000000000";
const char DATE[] PROGMEM = __DATE__;
// Modem configuration
const uint16_t eeAddress = 0x0080; // EEPROM start address for configuration store
const uint8_t eeProfNums = 4; // Number of configuration profiles to store
const uint8_t eeProfLen = 32; // Reserved profile lenght
const uint8_t eePhoneNums = 8; // Number of phone numbers to store
const uint8_t eePhoneLen = 32; // Reserved phone number lenght
struct CFG_t {
union {
struct {
uint8_t crc8 : 8; // CRC8 of the following data
uint8_t compro: 5; // ATB Select communication protocol
uint8_t txcarr: 1; // ATC Keep a carrier going when transmitting
uint8_t cmecho: 1; // ATE Local command mode echo
uint8_t dtecho: 1; // ATF Half/Full duplex and local data mode echo
uint8_t spklvl: 2; // ATL Speaker volume level
uint8_t spkmod: 2; // ATM Speaker mode
uint8_t quiet : 2; // ATQ Quiet mode
uint8_t verbal: 1; // ATV Verbose mode
uint8_t selcpm: 1; // ATX Select call progress method
uint8_t dialpt: 1; // ATP/T Select pulse/tone dialing
uint8_t revans: 1; // AT&A Reverse answering frequencies
uint8_t dcdopt: 1; // AT&C DCD option selection
uint8_t dtropt: 2; // AT&D DTR option selection
uint8_t jcksel: 1; // AT&J Jack type selection
uint8_t flwctr: 3; // AT&K Flow control selection
uint8_t lnetpe: 1; // AT&L Line type slection
uint8_t plsrto: 2; // AT&P Make/Break ratio for pulse dialing
uint8_t rtsopt: 1; // AT&R RTS/CTS option selection
uint8_t dsropt: 2; // AT&S DSR option selection
uint8_t sregs[16]; // The S registers
};
uint8_t data[eeProfLen];
};
};
// The S registers
const uint8_t sRegs[16] PROGMEM = {0, // 0 Rings to Auto-Answer
0, // 1 Ring Counter
'+', // 2 Escape Character
'\r', // 3 Carriage Return Character
'\n', // 4 Line Feed Character
'\b', // 5 Backspace Character
2, // 6 Wait Time for Dial Tone
50, // 7 Wait Time for Carrier
2, // 8 Pause Time for Dial Delay Modifier
6, // 9 Carrier Detect Response Time (tenths of a second)
14, // 10 Carrier Loss Disconnect Time (tenths of a second)
95, // 11 DTMF Tone Duration
50, // 12 Escape Prompt Delay
0, // 13 Reserved
0, // 14 General Bit Mapped Options Status
0 // 15 Reserved
};
class Profile {
public:
Profile();
~Profile();
// Init, read, write and reset profile
void init (CFG_t *cfg, uint8_t slot = 0);
bool read (CFG_t *cfg, uint8_t slot = 0, bool useDefaults = false);
bool write(CFG_t *cfg, uint8_t slot = 0);
bool factory(CFG_t *cfg);
// S registers data and functions
uint8_t sregGet(CFG_t *cfg, uint8_t reg);
void sregSet(CFG_t *cfg, uint8_t reg, uint8_t value);
// Phone numbers storage
uint8_t pbGet(char *phone, uint8_t slot);
void pbSet(char *phone, uint8_t slot);
private:
uint8_t crc(CFG_t *cfg);
uint8_t CRC8(uint8_t inCrc, uint8_t inData);
bool equal(CFG_t *cfg1, CFG_t *cfg2);
};
#endif /* CONFIG_H */