Show Posts
Pages: [1] 2 3
1  Topics / Home Automation and Networked Objects / Re: Souliss, Home Automation and IoT on: April 27, 2013, 05:21:09 pm
SoulissApp client reached version 1.2, some of the new features include RGB support:




FEATURES:

-Automatically detects Souliss nodes and devices, supports sensors, lights, air conditioners, RGB lights and many other appliances
-Define custom Scenarios to group commands together
-custom Programs (timed, geo-referenced, Sensor-based) to automate your home's behaviour
-local Database to collect hystorical data
-Background Service to receive devices' updates
-battery-efficient UDP implementation
-tablet support and optimizations
-customizable look&feel
2  International / Megatopic / Re: Souliss, Domotica e IoT on: March 10, 2013, 05:03:01 pm
Rilasciata sul Play market la versione 1.1.6 di SoulissApp
3  Using Arduino / Programming Questions / Re: PROGMEM char array on: August 29, 2012, 03:23:11 pm
The snippet is part of a rudimental Air conditioner IR driver, I thought it was too long to be posted for a simple issue.

I'll post it, so maybe someone will find other inconsistencies in my rusty C code. It works, but I'd like to decrease memory usage furthermore.

Thanks to anyone who'll be looking at it.


Code:
#include <avr/pgmspace.h>
//These are Samsung MH026FB specific
#define tempmask 0xF//temp e` quarto byte dell'input
#define funmask 0xF0
#define fanmask 0x700
#define swirlmask 0x800

#include "IRremoteInt_light.h"
#include "IRremote_light.h"

const byte charSet[] PROGMEM = { 0x0, 0x8, 0x4, 0xc, 0x2, 0xA , 0x6, 0xE, 0x1, 0x9,0x5, 0xD, 0x3,0xB,0x7,0xF };

#define DEBUG 1
/**
 Souliss Aircon MH026FB Driver
 implements IR logic. Commanded by Souliss AirCon protocol
 
 SAMSUNG MH026 series
 
*/
//IR_Remote lite library
IRsend irsend;
/**
Counts number of 1 in a long
*/
int NumberOfSetBits(long i)
{
    i = i - ((i >> 1) & 0x55555555);
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
    return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
}
/**
 Reverse the bit in a byte via a lookup table
 Bit reversal lookup table
 0100 --> 0010
 //TODO use progmem
*/
char revbits(int n)
{

return pgm_read_byte(&charSet[n]);
//return reversed[n];
}
/**
Compute Samsung crappy checksum
Command is split between data and data2

Samsung checksum
1. Count the number of 1 bits in all the bytes except #2 (checksum)
2. Compute count mod 15. If the value is 0, use 15 instead.
3. Take the value from 2, flip the 4 bits, and reverse the 4 bits.
4. The checksum is Bn where n is the value from the previous step.

Note that step 2 is mod 15, not mod 16 (which you might expect). I
don't know why 15 is used as a special case instead of 0.

For step 3, the results in order are F, 7, B, 3, D, 5, 9, 1, E, 6, A,
2, C, 4, 8, 0. Note that these are exactly the same as the values you
got for byte 5 (temperature). This suggests that the reversed /
inverted bits are more "fundamental".

Thanks to Ken Shirriff
*/
long computeChecksum(long data, long data2){
char temp;
temp = NumberOfSetBits(data2);
temp +=NumberOfSetBits(data);
temp = temp%15;
if (temp == 0)
temp = 15;
#ifdef DEBUG
Serial.print("NUMBITS SET:");
Serial.println(temp, HEX);
#endif
temp = ~temp;
temp -=0xF0;
#ifdef DEBUG
Serial.print("INVERTED:");
Serial.println(temp, HEX);
Serial.print("REVERSED:");
Serial.println(revbits(temp), HEX);
#endif

return 0xB0 + revbits(temp);
}

/**************************************************************************
/*!
Remap Souliss AirCon data with device specific one (Samsung MH026FB).
You'll have to re-implement this function to support your
Air Conditioner. Souliss INPUT Data is:

0xABCD
A = 4 bit mask (XYZT X= powerON, Y PowerOFF, ionizer (airclean) , pwrsave)
B = Fan/Swirl (1bit switch + 3bits for four possible fan values)
C = Function (auto,cool,dry,fan,heat)
D = Temperature (from 16 to 30, see .h)

I comandi sono formati da due o tre burst


  ---------------------------------------------------------------
OUTPUT (Samsung specific)
Codice dati da inviare: 7F       XX       80       71       F    1    7    7    F0
const    check    swirl    const    ion  tem  fan  fun  const
DEFAULT 00000000 00000000 00000000 01110001 0000 0000 0000 0000 00000000

*/
/**************************************************************************/
void sendMH026FB(unsigned long data, U8 *memory_map, U8 slot){

long part1=0;
long part2=0;

#ifdef DEBUG
Serial.print("Souliss AirCon input:");
Serial.println(data, HEX);
#endif

if (data & 0x8000){//if first bit of input=0 TURN ON
#ifdef DEBUG
Serial.println("POWERON!");
#endif
irsend.sendSamsung(0xBFB20FFF, 0xFFFFF0);
irsend.sendSamsung(0x7FB40FFF, 0xFFFFFF);
//*status = Souliss_T_IrCom_AirCon_Pow_On;
//go on with command
}
else if (data<<1 & 0x8000) {//if second bit of input=0 SHUT OFF
#ifdef DEBUG
Serial.println("POWEROFF!");
#endif
irsend.sendSamsung(0xBFB20FFF, 0xFFFFFC);
irsend.sendSamsung(0x7FB40FFF, 0xFFFFFF);
irsend.sendSamsung(0x7FB08A71, 0xF84FFC);
//*status = Souliss_T_IrCom_AirCon_Pow_Off;

//memory_map[MaCaco_OUT_s + slot] = *status;
//memory_map[MaCaco_OUT_s + slot + 1] = *status;
memory_map[MaCaco_IN_s + slot] = Souliss_T_IrCom_AirCon_Reset;
return;
}
else {//Comando da due bursts, primo costante
irsend.sendSamsung(0xBFB20FFFUL ,0xFFFFF0UL );
}
//starting values
part1 =  0x7f000000;
part2 =  0x0000F0;
//last part1 const (andrebbe 11 -> turbo) e 01->Powersave
unsigned int powerMode = Souliss_T_IrCom_AirCon_opt_normal;
//FAN is bit 2,3,4 of 2nd BYTE of INPUT
char fan = (data & fanmask)>>8;
//FUN = 3rd byte of INPUT
char fun = (data & funmask)>>4;

//TEMP = 4th byte of INPUT
long temperat = data & tempmask;
//swirl OFF by default
unsigned int swirl = 0x80;

//swirl (if deflector has to swing)
if (data & swirlmask){
swirl=0x8A;
}

//Eco bit Toggle, only in cool mode
if ((data<<3 & 0x8000) && (fun == Souliss_T_IrCom_AirCon_Fun_Cool))
powerMode = Souliss_T_IrCom_AirCon_opt_eco;

//PART2

//OPT if terzo bit = 1 IONIZER
if (data<<2 & 0x8000)
part2 += 0x700000;//Ion ON
else
part2 += 0xF00000;//F = Ion OFF


//Fan has only 24 degrees
if (fun == Souliss_T_IrCom_AirCon_Fun_Fan)
temperat = Souliss_T_IrCom_AirCon_temp_24C;

//Dry has only AUTO fan setting
if (fun == Souliss_T_IrCom_AirCon_Fun_Dry)
fan = Souliss_T_IrCom_AirCon_Fan_Auto;

//Auto mode adjust: fan and options are fixed
if (fun == Souliss_T_IrCom_AirCon_Fun_Auto){
fan = 0x4;
//swirl=0x8A;
powerMode = Souliss_T_IrCom_AirCon_opt_normal;
}

part1 += swirl<<8;
part1 += powerMode;
//temperature on sixth byte
part2 += temperat<<16;

part2 += fan<<12;
part2 += fun<<8;

//has to be last call
part1 += computeChecksum(part1, part2)<<16;

//send command
irsend.sendSamsung(part1, part2);
#ifdef DEBUG
Serial.print("Sending 0x");
Serial.print(part1, HEX);
Serial.print(" ");
Serial.println(part2, HEX);
#endif

//*status = data;
}
4  Using Arduino / Programming Questions / Re: PROGMEM char array on: August 29, 2012, 03:08:41 pm
thank you. I had to add const keyword and to move the declaration outside the function.

Now it works.
5  Using Arduino / Programming Questions / Re: PROGMEM char array on: August 29, 2012, 02:48:01 pm
I'v tried with unsigned char and byte, but no luck. The output is:

Code:
0 8 4 C 2 A 6 E 1 9 5 D 3 B 7 F
 91 C8 3 A8 16 B9 6 CA 6 DB 6 A1 F0 E 94 D3

The code I'm using is:

Code:
byte charSet[] PROGMEM = { 0x0, 0x8, 0x4, 0xc, 0x2, 0xA , 0x6, 0xE, 0x1, 0x9,0x5, 0xD, 0x3,0xB,0x7,0xF };
byte reversed[]  = { 0x0, 0x8, 0x4, 0xc, 0x2, 0xA , 0x6, 0xE, 0x1, 0x9,0x5, 0xD, 0x3,0xB,0x7,0xF };
byte ff;
for (int i=0; i < 16; i++) {
Serial.print(" ");
Serial.print(reversed[i], HEX);
}
Serial.println(" ");
for (int i=0; i < 16; i++) {
Serial.print(" ");
ff = pgm_read_byte(&charSet[i]);
Serial.print(ff, HEX);
}
6  Using Arduino / Programming Questions / Re: PROGMEM char array on: August 29, 2012, 06:56:10 am
Quote
Surely you want Serial.print(ff, HEX); rather than just Serial.print(ff);
 if you want the output to look the same.

Yes, you're right. Anyway the output is the same. Also

Code:
Serial.print( pgm_read_byte( charSet + i ), HEX );

produces same output. I really can't understand
7  Using Arduino / Programming Questions / PROGMEM char array on: August 29, 2012, 05:08:25 am
consider this snippet, compiled with Arduino IDE:

Code:
PROGMEM  char charSet[]  = { 0x0, 0x8, 0x4, 0xc, 0x2, 0xA , 0x6, 0xE, 0x1, 0x9,0x5, 0xD, 0x3,0xB,0x7,0xF };
char reversed[]  = { 0x0, 0x8, 0x4, 0xc, 0x2, 0xA , 0x6, 0xE, 0x1, 0x9,0x5, 0xD, 0x3,0xB,0x7,0xF };
char ff;
for (int i=0; i < 16; i++) {
Serial.print(" ");
Serial.print(reversed[i], HEX);
}
Serial.println(" ");
for (int i=0; i < 16; i++) {
Serial.print(" ");
ff = pgm_read_byte(&charSet[i]);
Serial.print(ff);
}


I would expect the two for loops to produce same output. But the output is:
Code:
     0 8 4 C 2 A 6 E 1 9 5 D 3 B 7 F
      FFFFFF94 FFFFFFB0 6 FFFFFF80 FFFFFF91 FFFFFFC7 3 62 FFFFFFE3 E FFFFFF94 5E 29 FFFFFF99 23 39


What am I missing? Thank you

8  Using Arduino / Programming Questions / IR checksums on: August 08, 2012, 05:41:41 am
I had a long time decoding IR codes with optimum Ken Shirriff Library. I modified the code a bit so that I was able to dump Samsung Air Conditioner 56-bit signals.

The results of my work is located at:
https://docs.google.com/spreadsheet/ccc?key=0Aupzmp8AqC8JdGtNOXhUc0R0WC1hbVdRa0p3aDVxdFE#gid=0

it is a spreasheet with all dumped values and the interpretation of results. AFAIK, aircon unit sends out 2 or 3 "bursts" of 56bit data, depending on command. I was able to decode bits properly, figuring out where air conditioner temperature, fan, function are located.


The problem I have is related to checksum. In all those 7-byte codes, the second one is computed somehow from the latter 5bytes, for example:

BF B2 0F FF FF FF F0 (lead-in code)
7F B8 8A 71 F6 4F F0   (auto mode - 25degrees)
7F B2 80 71 7A 4F F0   (auto mode - 26degrees)
7F B4 80 71 FA 7D F0   (heat mode - 26degrees - fan auto)

I tried with many standard checksum algorithms, none of them gave meaningful results. The checksum seems to be related to number of zeroes in the rest of code (bytes from 3 to 7), but I really can't figure it how.

Anyone here messed up with Samsung IR codes and can help me out?
Thank you very much
9  Topics / Home Automation and Networked Objects / Re: Operate from Blackberry/Android/Iphone-Ipad/Nokia/PC/Mac across the Globe W/O PC on: July 19, 2012, 03:06:30 am

what did you use to build the android application ?


We used standard Android SDK on Eclipse. App supports VPN communications, private and/or public address, so that network latency is tuned to connection speed. Much work is still to be done, but the app is working properly so far.
10  Topics / Home Automation and Networked Objects / Re: Some ideas for a domestic antitheft system... and probably more. on: April 24, 2012, 04:45:31 am

I'm not good as you with hardware and pcbs, anyway I'll support on Android client every kind of Souliss improvement with new screens and controls to make it easy, for end-user, to interact with security features.

As for now, I'll follow your talk.
11  Using Arduino / Installation & Troubleshooting / Re: Arduino Nano-Bought from dealextreme.com-D8 pin is high by default. on: April 19, 2012, 04:49:08 am
Philip Torrone posted an article about Arduino unauthorized clones. IMHO It's worth reading

http://blog.makezine.com/2012/04/18/soapbox-counterfeit-open-source-hardware-knock-offs-101/
12  International / Megatopic / Re: (Libreria) Souliss Home Automation / Aggiornamento: Android Client on: April 11, 2012, 09:08:07 am
se ho capito pero' questi comandi memorizzati lato android dalla tua app saranno funzionanti solo se sono online. Cioe' se spengo il telefono nessuno andra' a verificare il sensore umidita' e nessuno attuera' il relativo comando di accensione condizionatore.
Inoltre se esco di casa devo restare connesso al GPRS ed aver gestito correttamente il forward delle porte del rouoter con l'esterno.

Sì, corretto. Purtroppo gestire il logging (e i trigger) a basso livello, ovvero direttamente sulla scheda, è difficoltoso per limiti di memoria. Richiederebbe di adottare schede più performanti, ma ci allontaneremmo dagli obbiettivi di economicità che per adesso rimangono primari.

Per quanto riguarda il forwarding è prevista anche la modalità VPN, che in Android è supportata nativamente ed è presente in quasi tutti i router domestici; questo naturalmente per evitare di avere una porta HTTP sempre aperta verso l'esterno.
13  International / Megatopic / Re: (Libreria) Souliss Home Automation / Aggiornamento: Android Client on: April 11, 2012, 05:39:50 am

Cioe' se raggiungo il mio bel arduino Souliss tramite il browser integrato in android faccio le stesse cose che posso fare con l'applicazione ?

No, perchè il client android "astrae" il modello a tipici/nodi di souliss, permettendo un'interazione più user friendly. Posto che è ancora in fase di sviluppo, l'app dispone per esempio di un database, su cui loggare la 'storia' dell'impianto domotico e su cui definire dei comportamenti ad "alto livello" (impossibile con i 2K di Arduino). Per esempio è possibile definire comandi temporizzati o geolocalizzati, in modo da poter inviare comandi a souliss a determinate ore oppure quando usciamo di casa.

O ancora, si possono definire i comandi "sensor based", ovvero trigger che si attivano quando determinati sensori raggiungono un certo valore (ad es. se l'umidità supera l'85%, accendi il condizionatore)

I tipici supportati dal client alla versione 0.7 sono le luci (11, 12 e 14) ed i sensori corrente e temperatura. Questi ultimi non sono tuttavia ancora inclusi nella distribuzione 'ufficiale'...Dario ed io ci stiamo lavorando molto, ma integrare attuatori e sensori anche banali (ad es. DHT, fotodiodi, CT sensor) in un sistema domotico distribuito non è sempre banale smiley

Inoltre il client android implementa un servizio in background che si occupa di mantenere il client aggiornato.
14  Using Arduino / Sensors / Re: DHT22 not working with 8mhz clockspeed? on: April 09, 2012, 05:51:28 pm
thank you, adafruit's patch worked for me, too.
15  International / Generale / Re: Domotichome con arduino e android on: April 04, 2012, 07:25:10 am
purtroppo è difficile aiutarti senza conoscere il codice Android.
L'eccezione che riporti deriva da un errore java dell'app, potrebbe essere qualunque cosa. Il modo migliore per ottenere supporto è quello di scaricare i sorgenti del progetto e riuscire a compilarlo sul tuo telefono, in modo da avere a disposizione tutte le informazioni necessarie al debug. Ti serve Eclipse, l'SDK di android e un plugin per farli dialogare (ADT)

Anche io avevo provato domohome, poi mi sono accorto che è sostanzialmente limitato ad un solo nodo e offre flessibilità limitata (non si possono definire facilmente altri tipi di sensore/attuatore). Il meccanismo di auto-generazione del codice dello sketch è affascinante, ma da sviluppatore di app volevo di più.

Tieni presente che, anche qualora individuassi il problema, senza sorgenti dell'app potrai difficilmente risolverlo. Per curiosità: hai provato Souliss?
Pages: [1] 2 3