Podłączam się do pytania -Czy komuś działa zapis w fram? Z zapisu z konsoli wynika że pamieć fram jest wykrywana , ale nie pamięta ustawień , jak można sprawdzić czy rzeczywiście jest tam coś zapisywane?Lesik pisze: ↑sob gru 01, 2018 9:44 am Miałem podgrzane złe biblioteki. Teraz po restarcie pokazuje te same komunikaty ale tylko do czasu połączenia z serwerem. Po połączeniu i podczas podnoszenia rolety pokazuje „value changed”. Wykonałem kalibrację ale wyłączeniu zasilania i włączeniu nie pamięta ustawień. Pokazuje żeby wykonać kalibrację. Czy to może być błąd na ios? Czy komuś to działa poprawnie?
14:14:43.005 -> Found SPI FRAM
14:14:43.005 -> Ethernet starts with MAC only
14:14:47.871 -> Ethernet configured
14:14:47.871 -> localIP: 192.168.2.2
14:14:47.918 -> subnetMask: 255.255.255.0
14:14:47.918 -> gatewayIP: 192.168.2.1
14:14:47.918 -> dnsServerIP: 192.168.2.1
14:14:47.972 -> SuplaDevice initialized
14:14:48.018 -> Not connected
14:14:48.072 -> Register in progress
14:15:18.100 -> Not connected
14:15:18.200 -> Register in progress
14:15:48.236 -> Not connected
14:15:48.336 -> Register in progress
14:15:48.336 -> Registered and ready.
Kod: Zaznacz cały
/*
Copyright (C) AC SOFTWARE SP. Z O.O.
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 2
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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <SPI.h>
#include <Ethernet.h>
#include <Adafruit_FRAM_SPI.h>
#include <SuplaDevice.h>
char tag[6] = {'S','U','P','L','A','1'};
typedef struct
{
char tag[6];
int position;
unsigned int full_opening_time;
unsigned int full_closing_time;
}RS_Settings;
RS_Settings settings;
bool FRAM_FOUND = false;
uint8_t FRAM_CS = 53;
uint8_t FRAM_SCK = 52;
uint8_t FRAM_MISO = 50;
uint8_t FRAM_MOSI = 51;
#if defined(ARDUINO_ARCH_SAMD)
// for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!
#define Serial SerialUSB
#endif
Adafruit_FRAM_SPI fram = Adafruit_FRAM_SPI(FRAM_SCK, FRAM_MISO, FRAM_MOSI, FRAM_CS);
void settings_init(RS_Settings *settings) {
memset(settings, 0, sizeof(RS_Settings));
memcpy(settings->tag, tag, 6);
}
bool fram_read(int channelNumber) {
memset(&settings, 0, sizeof(RS_Settings));
if ( FRAM_FOUND )
{
fram.read (sizeof(RS_Settings)*channelNumber, (uint8_t *)&settings, sizeof(RS_Settings));
if ( memcmp(&settings.tag, tag, 6) == 0 )
{
return true;
}
}
settings_init(&settings);
return false;
}
void fram_write(int channelNumber) {
if ( FRAM_FOUND )
{
fram.writeEnable(true);
fram.write (sizeof(RS_Settings)*channelNumber, (uint8_t *)&settings, sizeof(RS_Settings));
fram.writeEnable(false);
}
}
void supla_rs_SavePosition(int channelNumber, int position) {
fram_read(channelNumber);
settings.position = position;
fram_write(channelNumber);
}
void supla_rs_LoadPosition(int channelNumber, int *position) {
if ( fram_read(channelNumber) )
{
*position = settings.position;
}
}
void supla_rs_SaveSettings(int channelNumber, unsigned int full_opening_time, unsigned int full_closing_time) {
fram_read(channelNumber);
settings.full_opening_time = full_opening_time;
settings.full_closing_time = full_closing_time;
fram_write(channelNumber);
}
void supla_rs_LoadSettings(int channelNumber, unsigned int *full_opening_time, unsigned int *full_closing_time) {
if ( fram_read(channelNumber) )
{
*full_opening_time = settings.full_opening_time;
*full_closing_time = settings.full_closing_time;
}
}
void setup() {
Serial.begin(9600);
if (fram.begin()) {
Serial.println("Found SPI FRAM");
FRAM_FOUND = true;
} else {
Serial.println("No SPI FRAM found ... check your connections\r\n");
}
// Replace the falowing GUID
char GUID[SUPLA_GUID_SIZE] = {....................Guid...........................};
// with GUID that you can retrieve from https://www.supla.org/arduino/get-guid
// Ethernet MAC address
uint8_t mac[6] = {0x03, 0x01, 0x02, 0x03, 0x04, 0x05};
/*
* Having your device already registered at cloud.supla.org,
* you want to change CHANNEL sequence or remove any of them,
* then you must also remove the device itself from cloud.supla.org.
* Otherwise you will get "Channel conflict!" error.
*/
// CHANNEL0 - TWO RELAYS (Roller shutter operation)
SuplaDevice.addRollerShutterRelays(22,23);
SuplaDevice.setRollerShutterButtons(0,11,12);
SuplaDevice.addRollerShutterRelays(24,25);
SuplaDevice.setRollerShutterButtons(1,8,9);
SuplaDevice.addRollerShutterRelays(26,27);
SuplaDevice.setRollerShutterButtons(2,6,7);
SuplaDevice.addRollerShutterRelays(28,29);
SuplaDevice.setRollerShutterButtons(3,3,5);
SuplaDevice.addRollerShutterRelays(30,31);
SuplaDevice.setRollerShutterButtons(4,14,2);
SuplaDevice.addRollerShutterRelays(32,33);
SuplaDevice.setRollerShutterButtons(5,16,15);
SuplaDevice.addRollerShutterRelays(34,35);
SuplaDevice.setRollerShutterButtons(6,18,17);
SuplaDevice.addRollerShutterRelays(36,37);
SuplaDevice.setRollerShutterButtons(7,20,19);
SuplaDevice.addRollerShutterRelays(38,39);
SuplaDevice.setRollerShutterButtons(8,A15,A2);
SuplaDevice.addRollerShutterRelays(40,41);
SuplaDevice.setRollerShutterButtons(9,A13,A14);
SuplaDevice.addRollerShutterRelays(42,43);
SuplaDevice.setRollerShutterButtons(10,A11,A12);
SuplaDevice.addRollerShutterRelays(44,45);
SuplaDevice.setRollerShutterButtons(11,A9,A10);
SuplaDevice.addRollerShutterRelays(46,47);
SuplaDevice.setRollerShutterButtons(12,A7,A8);
SuplaDevice.addRollerShutterRelays(48,49);
SuplaDevice.setRollerShutterButtons(13,A5,A6);
SuplaDevice.addRollerShutterRelays(4,21);
SuplaDevice.setRollerShutterButtons(14,A3,A4);
SuplaDevice.setRollerShutterFuncImpl(&supla_rs_SavePosition, &supla_rs_LoadPosition, &supla_rs_SaveSettings, &supla_rs_LoadSettings);
/*
* SuplaDevice Initialization.
* Server address, LocationID and LocationPassword are available at https://cloud.supla.org
* If you do not have an account, you can create it at https://cloud.supla.org/account/create
* SUPLA and SUPLA CLOUD are free of charge
*
*/
SuplaDevice.begin(GUID, // Global Unique Identifier
mac, // Ethernet MAC address
"svrx.supla.org", // SUPLA server address
xxxx, // Location ID
"xxxx"); // Location Password
}
void loop() {
SuplaDevice.iterate();
}