Driving the Cheeky Mail Notifier from Arduino
The mail notifier from Dreamcheeky is advertised as follows:
The WebMail Notifier has pretty light and optional sound alert software to tell you when you have email on one or all of your accounts, including Facebook. Dream Cheeky did what we do best with this product… helping you be more unproductive at the office. Now when you sneak off to the bathroom to check personal emails on your Blackberry, your trip will definitely not be wasted.
WebMail Notifier supports: Gmail, Yahoo, Outlook Express, POP3, Weibo, Facebook, Twitter, etc.
As Oleg explains “To write to HID device you either need an OUT endpoint or write to control endpoint.” In the end i used the Usb.setReport command similar to that used in the keyboard example where the keyboard LEDs are turned on/offI wanted to control the Webmail Notifier from an arduino. As this is a USB device i needed to use the usb-host-shield manufactured by circuitsahome.
With a little help from Oleg from circuitsathome and with the windows program from Frederic Delhoume i finally maneged to get it working.
What was needed was to send the unit two innitiation sequences:
init1[7] = { 0x1F, 0×01, 0×25, 0×00, 0xC4, 0×00, 0×25, 0×03 };
init2[7] = { 0×00, 0×01, 0×25, 0×00, 0xC4, 0×00, 0×25, 0×04 };
Then you send the colour code eg:
msg3[7] = { 0xFF, 0xFF, 0×00, 0×00, 0×00, 0×00, 0×25, 0×05 };
The first three bytes are the brightness and colour coding. RR GG BB. It has 0x3F brightness as higher values do not increase the brightness.
Enclosed is the arduino software to get it working. At the moment its just a code to get it to cycle the colours as shown on the video.
Obviously i later on want to get it to do something usefull like checking my mail or something
Mail Notifier software
[spoiler intro=”Answer” title=”Flavor Sales”]
/* MAX3421E USB Host controller Mail Notifier demonstration */ // http://www.dreamcheeky.com/webmail-notifier #include <Spi.h> #include <Max3421e.h> #include <Usb.h> #include <Max_LCD.h> /* Mail Notifier data taken from configuration descriptor */ #define MailNotifier_ADDR 1 #define MailNotifier_EP 1 #define MailNotifier_IF 0 #define EP_MAXPKTSIZE 8 #define EP_POLL 0x0a EP_RECORD ep_record[ 1 ]; //endpoint record structure for the Mail Notifier MAX3421E Max; USB Usb; Max_LCD LCD; void setup() { Serial.begin( 9600 ); Serial.println("Start"); Max.powerOn(); delay( 200 ); } void loop() { Max.Task(); Usb.Task(); if( Usb.getUsbTaskState() == USB_STATE_CONFIGURING ) { //wait for addressing state MailNotifier_init(); Usb.setUsbTaskState( USB_STATE_RUNNING ); } if( Usb.getUsbTaskState() == USB_STATE_RUNNING ) { //poll the Mail Notifier MailNotifier_poll(); } } /* Initialize Mail Notifier */ void MailNotifier_init( void ) { byte rcode = 0; //return code /* Initialize data structures */ ep_record[ 0 ] = *( Usb.getDevTableEntry( 0,0 )); //copy endpoint 0 parameters ep_record[ 1 ].MaxPktSize = EP_MAXPKTSIZE; ep_record[ 1 ].Interval = EP_POLL; ep_record[ 1 ].sndToggle = bmSNDTOG0; ep_record[ 1 ].rcvToggle = bmRCVTOG0; Usb.setDevTableEntry( 1, ep_record ); //plug MailNotifier.endpoint parameters to devtable /* Configure device */ rcode = Usb.setConf( MailNotifier_ADDR, 0, 0x1F ); // byte addr, byte ep, byte conf_value, unsigned int nak_limit if( rcode ) { Serial.print("Error attempting to configure keyboard. Return code :"); Serial.println( rcode, HEX ); while(1); //stop } /* Set boot protocol */ rcode = Usb.setProto( MailNotifier_ADDR, 0, 0, 0 ); // byte addr, byte ep, byte interface, byte protocol, unsigned int nak_limit if( rcode ) { Serial.print("Error attempting to configure boot protocol. Return code :"); Serial.println( rcode, HEX ); while( 1 ); //stop } delay(2000); Serial.println("Mail Notifier initialized"); } /* Poll Mail Notifier and update intensity colour */ void MailNotifier_poll( void ) { char init1[] = { 0x1F, 0x01, 0x25, 0x00, 0xC4, 0x00, 0x25, 0x03 }; char init2[] = { 0x00, 0x01, 0x25, 0x00, 0xC4, 0x00, 0x25, 0x04 }; char msg1[] = { 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0x05 };//Red char msg2[] = { 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x25, 0x05 };//Green char msg3[] = { 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x25, 0x05 };//Yellow char msg4[] = { 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x25, 0x05 };//Blue char msg5[] = { 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x25, 0x05 };//Magenta char msg6[] = { 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x25, 0x05 };//Cyan char msg7[] = { 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x25, 0x05 };//White char msg8[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x25, 0x05 };//Off byte rcode = 0; //return code // byte addr, byte ep, unsigned int nbytes, byte interface, byte report_type, byte report_id, char* dataptr, unsigned int nak_limit rcode = Usb.setReport( MailNotifier_ADDR,0x00,0x08,MailNotifier_IF,0x02,0x00, init1 ); delay(500); rcode = Usb.setReport( MailNotifier_ADDR,0x00,0x08,MailNotifier_IF,0x02,0x00, init2 ); delay(500); rcode = Usb.setReport( MailNotifier_ADDR,0x00,0x08,MailNotifier_IF,0x02,0x00, msg1 ); delay(1500); rcode = Usb.setReport( MailNotifier_ADDR,0x00,0x08,MailNotifier_IF,0x02,0x00, msg2 ); delay(1500); rcode = Usb.setReport( MailNotifier_ADDR,0x00,0x08,MailNotifier_IF,0x02,0x00, msg3 ); delay(1500); rcode = Usb.setReport( MailNotifier_ADDR,0x00,0x08,MailNotifier_IF,0x02,0x00, msg4 ); delay(1500); rcode = Usb.setReport( MailNotifier_ADDR,0x00,0x08,MailNotifier_IF,0x02,0x00, msg5 ); delay(1500); rcode = Usb.setReport( MailNotifier_ADDR,0x00,0x08,MailNotifier_IF,0x02,0x00, msg6 ); delay(1500); rcode = Usb.setReport( MailNotifier_ADDR,0x00,0x08,MailNotifier_IF,0x02,0x00, msg7 ); delay(1500); rcode = Usb.setReport( MailNotifier_ADDR,0x00,0x08,MailNotifier_IF,0x02,0x00, msg8 ); delay(1500); }
[/spoiler]
Here are just some pictures and a short video of the program working.
Here is the code for download.
Interested in other shields look here.
Here you can find my other arduino projects.