diff options
65 files changed, 6986 insertions, 0 deletions
@@ -4,7 +4,45 @@ menu.cpu=Processor ############################################################## +yun.name=Arduino Yún +yun.upload.via_ssh=true + +yun.vid.0=0x2341 +yun.pid.0=0x0041 +yun.vid.1=0x2341 +yun.pid.1=0x8041 +yun.upload.tool=avrdude +yun.upload.protocol=avr109 +yun.upload.maximum_size=28672 +yun.upload.maximum_data_size=2560 +yun.upload.speed=57600 +yun.upload.disable_flushing=true +yun.upload.use_1200bps_touch=true +yun.upload.wait_for_upload_port=true + +yun.bootloader.tool=avrdude +yun.bootloader.low_fuses=0xff +yun.bootloader.high_fuses=0xd8 +yun.bootloader.extended_fuses=0xcb +yun.bootloader.file=caterina/Caterina-Yun.hex +yun.bootloader.unlock_bits=0x3F +yun.bootloader.lock_bits=0x2F + +yun.build.mcu=atmega32u4 +yun.build.f_cpu=16000000L +yun.build.vid=0x2341 +yun.build.pid=0x8041 +yun.build.usb_product="Arduino Yun" +yun.build.board=AVR_YUN +yun.build.core=arduino +yun.build.variant=leonardo +yun.build.extra_flags={build.usb_flags} + +############################################################## + uno.name=Arduino Uno +uno.vid.0=0x2341 +uno.pid.0=0x0043 uno.upload.tool=avrdude uno.upload.protocol=arduino uno.upload.maximum_size=32256 @@ -119,6 +157,10 @@ nano.menu.cpu.atmega168.build.mcu=atmega168 ############################################################## mega2560.name=Arduino Mega 2560 or Mega ADK +mega2560.vid.0=0x2341 +mega2560.pid.0=0x0044 +mega2560.vid.1=0x2341 +mega2560.pid.1=0x003f mega2560.cpu=2560 or ADK mega2560.upload.tool=avrdude @@ -167,6 +209,10 @@ mega.build.variant=mega ############################################################## leonardo.name=Arduino Leonardo +leonardo.vid.0=0x2341 +leonardo.pid.0=0x0036 +leonardo.vid.1=0x2341 +leonardo.pid.1=0x8036 leonardo.upload.tool=avrdude leonardo.upload.protocol=avr109 leonardo.upload.maximum_size=28672 @@ -227,6 +273,10 @@ micro.build.extra_flags={build.usb_flags} ############################################################## esplora.name=Arduino Esplora +esplora.vid.0=0x2341 +esplora.pid.0=0x003c +esplora.vid.1=0x2341 +esplora.pid.1=0x803c esplora.upload.tool=avrdude esplora.upload.protocol=avr109 esplora.upload.maximum_size=28672 diff --git a/bootloaders/caterina/Caterina-Yun.hex b/bootloaders/caterina/Caterina-Yun.hex new file mode 100644 index 0000000..1d76eb0 --- /dev/null +++ b/bootloaders/caterina/Caterina-Yun.hex @@ -0,0 +1,1025 @@ +:200000000C9475010C949D010C949D010C949D010C949D010C949D010C949D010C949D0118 +:200020000C949D010C949D010C940C050C9493050C949D010C949D010C949D010C949D0163 +:200040000C949D010C949D010C949D010C949D010C949D010C949D010C949D010C94BC0191 +:200060000C949D010C949D010C949D010C949D010C949D010C949D010C949D010C949D0190 +:200080000C949D010C949D010C949D010C949D010C949D010C949D010C949D010C949D0170 +:2000A0000C949D010C949D010C949D0100000000240027002A002D0030000000000025008F +:2000C00028002B002E003100000000002300260029002C002F00040404040403040502027D +:2000E0000202040302020202060606060606040402020204040802011040804010204080A8 +:200100004080080204018040201002011080102040400000000200080E0000030401000BB2 +:2001200000000000000000000000000000000000070605040100080A0B0C0D090403090455 +:200140002203410072006400750069006E006F002000590075006E002000200020002000CC +:2001600020001803410072006400750069006E006F0020004C004C00430012010002000062 +:2001800000404123418000010102000112010002020000404123418000010102000100C1B3 +:2001A0008081C1080B000202020100090400000102020000052400100105240101010424C3 +:2001C000020605240600010705810310004009040100020A00000007050202400000070591 +:2001E000830240000005010902A1010901A100850105091901290315002501950375018138 +:200200000295017505810305010930093109381581257F750895038106C0C005010906A182 +:20022000018502050719E029E7150025017501950881029501750881039506750815002567 +:20024000650507190029658100C009040200010300000009210101000122650007058403EB +:2002600040000100000000000000002A2B28000000000000000000000000000000000000C0 +:200280000000002C9EB4A0A1A2A434A6A7A5AE362D3738271E1F20212223242526B333B6BE +:2002A0002EB7B89F8485868788898A8B8C8D8E8F909192939495969798999A9B9C9D2F31F5 +:2002C00030A3AD350405060708090A0B0C0D0E0F101112131415161718191A1B1C1DAFB15C +:2002E000B0B50000480426072B0811241FBECFEFDAE0DEBFCDBF11E0A0E0B1E0EEECF2E18B +:2003000002C005900D92AC32B107D9F711E0ACE2B1E001C01D92AD39B107E1F712E0CAEEE1 +:20032000D2E004C02297FE010E946109C43ED107C9F70E9482030C9465090C940000809103 +:20034000000161E00E944F0368EE73E080E090E00E945A028091000160E00E944F0368EE54 +:2003600073E080E090E00E945A0208958091000161E00E94C20208951F920F920FB60F92B1 +:2003800011242F933F938F939F93AF93BF938091300190913101A0913201B091330130917D +:2003A00034010196A11DB11D232F2D5F2D3720F02D570196A11DB11D2093340180933001C0 +:2003C00090933101A0933201B093330180912C0190912D01A0912E01B0912F010196A11D38 +:2003E000B11D80932C0190932D01A0932E01B0932F01BF91AF919F918F913F912F910F90BA +:200400000FBE0F901F901895789484B5826084BD84B5816084BD85B5826085BD85B58160D8 +:2004200085BDEEE6F0E0808181608083E1E8F0E01082808182608083808181608083E0E833 +:20044000F0E0808181608083E1E9F0E0808182608083808181608083E0E9F0E08081816007 +:200460008083E1ECF0E0808184608083808182608083808181608083E3ECF0E080818160A8 +:200480008083E0ECF0E0808182608083E2ECF0E0808181608083EAE7F0E0808184608083CB +:2004A0008081826080838081816080838081806880830895EF92FF920F931F93CF93DF93AE +:2004C0007B018C013FB7F89480912C0190912D01A0912E01B0912F0126B5A89B05C02F3FE2 +:2004E00019F00196A11DB11D3FBFBA2FA92F982F8827820F911DA11DB11D52E0880F991F4F +:20050000AA1FBB1F5A95D1F7EC0130C00E9434093FB7F89480912C0190912D01A0912E0156 +:20052000B0912F0126B5A89B05C02F3F19F00196A11DB11D3FBFBA2FA92F982F8827820F07 +:20054000911DA11DB11D32E0880F991FAA1FBB1F3A95D1F78C1B9D0B885E9340B8F2089478 +:20056000E108F10801091109C851DC4FE114F1040105110559F6DF91CF911F910F91FF902D +:20058000EF900895CF93DF93482F50E0CA018C509F4FFC0134914A525F4FFA018491882368 +:2005A00069F190E0880F991FFC01E455FF4FA591B491FC01E654FF4FC591D491662351F415 +:2005C0002FB7F8948C91932F909589238C93888189230BC0623061F42FB7F8948C91932F22 +:2005E000909589238C938881832B88832FBF06C09FB7F8948C91832B8C939FBFDF91CF919B +:200600000895883071F1893068F4823031F1833020F4813009F042C01DC0833089F084300A +:20062000E9F512C08B3059F18C3028F48930E9F08A30A1F51EC08C3031F18E3079F529C07A +:20064000809180008F7703C0809180008F7D80938000089584B58F7702C084B58F7D84BDEC +:200660000895809190008F7707C0809190008F7D03C080919000877F809390000895809107 +:20068000C0008F7703C08091C0008F7D8093C00008958091C200877F8093C2000895FF92A8 +:2006A0000F931F93F62E482F50E0CA018E5E9E4FFC012491CA018C509F4FFC0114914A52F2 +:2006C0005F4FFA0104910023C9F0222319F0822F0E940103E02FF0E0EE0FFF1FE654FF4FD9 +:2006E000A591B4919FB7F894FF2021F48C911095812302C08C91812B8C939FBF1F910F91AB +:20070000FF900895CF93DF930E9404028DE391E00E9449040E94B601C0E0D0E00E949F0176 +:200720002097E1F30E940000F9CF282F809137018823C1F057FF1AC015C0289890933601A9 +:200740008091F1008193E217F307B9F74115510539F08091F200882319F48BE68093E800E4 +:20076000AFBF02C04FEF5FEFCA010895AFB7F89427702093E9008091F200282F30E024178B +:2007800035070CF4A901FB019B01240F311D94E6DACFDF93CF930F92CDB7DEB7BE016F5F1C +:2007A0007F4F41E050E00E949503019719F02FEF3FEF03C08981282F30E0C9010F90CF91F6 +:2007C000DF910895FF920F931F93F82E142F052F40913A0150913B01212F302FC901DC010B +:2007E000FB016EEF29C0F7FE02C0949101C09081209138013091390124173507ACF48091FC +:20080000E8008570E1F38091E80082FF03C02FEF3FEF17C09093F100C90101968F73907050 +:20082000892B11F46093E8002F5F3F4F3093390120933801119731961097A9F6812F902FFB +:200840009C01C9011F910F91FF9008959C018091E80082FFFCCFF901260F311D03C0809182 +:20086000F1008193E217F307D1F7289884E6809336018BEF8093E800CB0108958093E9006A +:200880008091F200882319F08AE38093E800089508951092370181E08093D70080EA80935D +:2008A000D80082E189BD09B400FEFDCF61E070E080E090E00E945A0280E98093D8008CE011 +:2008C0008093E2001092E000559A209A08955F926F927F928F929F92AF92BF92CF92DF92A2 +:2008E000EF92FF920F931F93CF93DF93E82E842E752E80913701882371F18B01242F352FBA +:20090000C901EC017AEFF72E67E0962E9E2050E4552E8E2D90E040E2A42EB12CA822B92271 +:200920003AE3632E20E4C22ED12CC822D92258C09FB7F8949092E9008091E80085FD02C0F1 +:2009400020E004C08091F200252D281B9FBF222361F4FA9419F42FEF3FEF4DC061E070E0BE +:2009600080E090E00E945A023BC0822F90E0C817D9070CF42C2FC21BD1094FB7F894909208 +:20098000E900A114B10421F406C01092F10021502223D9F719C0E7FC03C0F801922F10C007 +:2009A000C801322F06C0FC010196E491E093F10031503323C1F706C081918093F10091508E +:2009C0009923D1F7020F111D8091E80085FF05C0209729F4C114D10411F06092E8004FBFAB +:2009E000209709F0A5CF5D9884E680933501282D372DC9019C01C901DF91CF911F910F9121 +:200A0000FF90EF90DF90CF90BF90AF909F908F907F906F905F9008951F920F920FB60F92CC +:200A200011242F933F934F935F936F937F938F939F93AF93BF93EF93FF938091E100109275 +:200A4000E100982F83FF0FC01092E90081E08093EB001092EC0082E38093ED0010923701E6 +:200A600088E08093F00092FF34C083E08093E9008091F200882319F08AE38093E8008FB7C2 +:200A8000F89492E09093E9009091F2008FBF992321F082E891E00E9469078091350188233F +:200AA00051F08091350181508093350180913501882309F45D9A80913601882351F0809169 +:200AC000360181508093360180913601882309F4289AFF91EF91BF91AF919F918F917F9112 +:200AE0006F915F914F913F912F910F900FBE0F901F9018950F931F93DF93CF930F92CDB7E2 +:200B0000DEB719828E010F5F1F4FC8010E948F07C8010E942809898190E00F90CF91DF91B4 +:200B20001F910F9108951F920F920FB60F921124EF92FF921F932F933F934F935F936F93AD +:200B40007F938F939F93AF93BF93EF93FF93DF93CF93CDB7DEB76197DEBFCDBF1092E900EE +:200B60008091E80083FF0FC1FE0131969E01275F3F4F03C08091F1008193E217F307D1F71D +:200B8000289884E68093360182EF8093E800998197FF05C08091E80080FFFCCF03C08EEF7D +:200BA0008093E800292F30E0C90180769070892B09F0C2C08A81882329F41092F1001092DB +:200BC000F100D6C0813009F4D3C0833009F4D0C0853049F48091E80080FFFCCF8B818068E4 +:200BE0008093E300C5C0863009F07CC01C81EF80F8841230C1F51092E90010923901109206 +:200C0000380110923B0110923A010E947A0599E0FE013996DF01292F1D922A95E9F79987D2 +:200C20001A8791E09E8790E8988B9AEF998B2091380130913901275F3F4F3C872B878D87B3 +:200C40001092E9001092390110923801F0923B01E0923A0180E0BF0149E050E00E94E203E7 +:200C60000E947A0585C01092E9001092390110923801F0923B01E0923A01123241F482E284 +:200C800090E00E942009892B09F476C071C0113079F488E0E816F10419F481E080933C013A +:200CA00080913C01882309F06BC0EAE7F1E013C0133009F061C08B81882319F4ECE3F1E0E1 +:200CC0000AC0823019F4E0E4F1E005C0813009F053C0E2E6F1E0449180E8BF0150E00E940C +:200CE000E20346C0873009F447C0883021F481E08093F1003DC08930D9F523703070232B17 +:200D0000D9F5EFE9F1E091E031E026E39093E9003093EB0084918093EC002093ED009F5F65 +:200D20003196953099F78EE78093EA001092EA008B81809337011CC08F8198851092E900AE +:200D4000109239011092380190933B0180933A018D81882329F4CE0101960E949B0706C0E9 +:200D6000823051F4CE0101960E94F107882321F08EEF8093E80007C081E28093EB0003C05D +:200D8000ECE8F1E0A8CF6196DEBFCDBFCF91DF91FF91EF91BF91AF919F918F917F916F9147 +:200DA0005F914F913F912F911F91FF90EF900F900FBE0F901F90189520917E0130917F013D +:200DC0008091800190918101281B390B2F733070C901089520917E0130917F0180918001AB +:200DE000909181012817390719F42FEF3FEF09C0E0918001F0918101E25CFE4F8081282FD7 +:200E000030E0C901089520917E0130917F0180918001909181012817390719F42FEF3FEFDD +:200E200013C0E0918001F0918101E25CFE4F2081809180019091810101968F7390709093CD +:200E400081018093800130E0C9010895109285011092840188EE93E0A0E0B0E08093860123 +:200E600090938701A0938801B093890180E191E0909383018093820108950F931F93DF93CC +:200E8000CF930F92CDB7DEB78C01698380910901882369F083E0BE016F5F7F4F41E050E08F +:200EA0000E9467041816190614F49C0107C081E090E0F8019383828320E030E0C9010F900E +:200EC000CF91DF911F910F91089583E00E943E040895CF93DF9312C082E00E94C9032FEFDD +:200EE0008F3F9207C9F0E0917E01F0917F01E25CFE4F8083D0937F01C0937E01C0917E01CE +:200F0000D0917F012196CF73D0708091800190918101C817D90701F7DF91CF910895FC0161 +:200F200080818E5F808380E863EA71E042E450E00E94E2030895FC0181819081913A59F418 +:200F4000813209F04CC080E062E071E047E050E00E94E20342C0913209F041C0803239F46A +:200F600082E091E067E070E00E94260436C0823209F035C08281809309018091020190914E +:200F80000301A0910401B0910501805B9440A040B04019F58091090180FD12C087E797E7ED +:200FA00090930108809300082BE088E190E00FB6F894A895809360000FBE209360000DC058 +:200FC00088E10FB6F89480936000109260000FBEA895109201081092000881E0089580E025 +:200FE0000895FC0191818081813A31F4913089F080E0933089F40DC0813269F49B3021F4CD +:20100000828180930A0105C09A3029F4828180930B0181E0089580E00895EF92FF920F9332 +:201020001F938C01E62EDC01ED91FC910480F581E02D0995F82ED801ED91FC910680F781C8 +:20104000E02DC8016E2D09958F2D90E01F910F91FF90EF900895109290011092940110924E +:20106000930182E291E090939201809391010895EF92FF920F931F93DF93CF930F92CDB7B0 +:20108000DEB789838B017A0184E0BE016F5F7F4F41E050E00E94670484E4B801A7010E9420 +:2010A00067040F90CF91DF911F910F91FF90EF90089582E048E050E00E9438080895FC0125 +:2010C00016821782108611861286138614823496BF010E9459080895DC01683810F0685884 +:2010E00029C0E62FF0E067FF13C0E058F04081E090E002C0880F991FEA95E2F78095149688 +:201100002C911497282314962C93149760E012C0ED59FD4F6491662319F420E030E01DC0EC +:2011200067FF08C014968C9114978D7F14968C9314976F77FD0190E0662321F086818617FD +:2011400009F416829F5F31969630B1F7CD011496BD010E94590821E030E0C9010895CF93B4 +:20116000DF93DC01683810F0685825C0E62FF0E067FF12C0E058F04081E090E002C0880F2C +:20118000991FEA95E2F714962C911497282B14962C93149760E00FC0ED59FD4F64916623A7 +:2011A000D9F167FF08C014968C911497826014968C9314976F7716968C9116978617A9F1DC +:2011C00017968C911797861781F118968C911897861759F119968C911997861731F11A963C +:2011E0008C911A97861709F11B968C911B978617E1F0ED01E0E0F0E09E2F8E81882321F482 +:20120000EA0FFB1F668306C09F5F31962196E630F10591F7963049F481E090E013969C9350 +:201220008E93129720E030E007C0CD011496BD010E94590821E030E0C901DF91CF9108958C +:2012400080E865EE71E045E650E00E94E2030895FC0180818F5F808380E86AE472E049E1E2 +:2012600050E00E94E20308950895CF92DF92EF92FF920F931F93CF93DF937C016B018A01FD +:20128000C0E0D0E00FC0D6016D916D01D701ED91FC910190F081E02DC7010995C80FD91FC5 +:2012A000015010400115110571F7CE01DF91CF911F910F91FF90EF90DF90CF900895EE0F94 +:2012C000FF1F0590F491E02D0994F894FFCF0D0000E10000000000000101000000003D079E +:2012E0003509DC060307EA0665076907000000000D083509AF086C085F08FFFFFFFFFFFF19 +:20130000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFED +:20132000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFCD +:20134000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFAD +:20136000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8D +:20138000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF6D +:2013A000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF4D +:2013C000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF2D +:2013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FFFF2 +:206EC000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD2 +:206EE000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFB2 +:206F0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF91 +:206F2000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF71 +:206F4000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF51 +:206F6000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF31 +:206F8000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF11 +:206FA000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1 +:206FC000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD1 +:206FE000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFB1 +:2070000055C000006EC000006CC000006AC0000068C0000066C0000064C0000062C0000043 +:2070200060C000005EC00000FCC400005AC0000058C0000056C0000054C0000052C00000E4 +:2070400050C000005DC000004CC000004AC0000048C0000046C0000044C0000042C00000D9 +:2070600040C000003EC000003CC000003AC0000038C0000036C0000034C0000032C0000048 +:2070800030C000002EC000002CC000002AC0000028C0000026C0000024C0000022C00000A8 +:2070A00020C000001EC000001CC0000011241FBECFEFDAE0DEBFCDBF11E0A0E0B1E0E6E4B7 +:2070C000FFE702C005900D92A63AB107D9F711E0A6EAB1E001C01D92AF3BB107E1F74FD34E +:2070E00030C78ECFF89410926F001092810081E085BF15BE47985D9A289A0C94000008952F +:207100001F920F920FB60F9211242F938F939F93EF93FF9310928500109284008091A60153 +:207120009091A701009741F001979093A7018093A601892B09F45D9A8091A8019091A90174 +:20714000009741F001979093A9018093A801892B09F4289A8091AC019091AD01019690938C +:20716000AD018093AC01E0E0F0E0859194918F5F9F4F49F08091AA019091AB01019690937E +:20718000AB018093AA01FF91EF919F918F912F910F900FBE0F901F90189584E08093E9009E +:2071A0000DC08091E8008B778093E80003C08EB3882351F08091E80082FFF9CF8091E800E1 +:2071C00085FFEFCF8091F1000895982F83E08093E9008091E80085FD0DC08091E8008E7762 +:2071E0008093E80003C08EB3882369F08091E80080FFF9CF9093F1005D9884E690E0909346 +:20720000A7018093A60108954F925F926F927F928F929F92AF92BF92CF92DF92EF92FF92C3 +:207220000F931F93CF93DF9384E08093E9008091E80082FF57C2289884E690E09093A901CC +:207240008093A801AADF182F853481F48CE49DE19093AB018093AA0107B600FCFDCFF999E2 +:20726000FECF81E180935700E89503C0843519F494DF8DE00DC28C34E1F38035D1F38437F8 +:2072800021F484E4A2DF80E003C2813611F489E5FFC18134B1F481DF182F7FDF90E0880F7B +:2072A000991FAA2797FDA095BA2F312F330F20E0442737FD4095542F822B932BA42BB52BE0 +:2072C000B8C1803711F483E5E3C1833549F4C0E0D1E089917ADF21E0C730D207D1F7D9C181 +:2072E000863521F481E371DF80E3D2C1833731F487E86BDF85E969DF8EE1CAC18536B9F464 +:20730000E0E0F0E093E085E090935700E89507B600FCFDCF80935700E89507B600FCFDCF1D +:20732000E058FF4FA0E7E030FA0771F7A2CF823739F4E1E0F0E089E0809357008491A8C18E +:20734000863439F4E0E0F0E089E08093570084919FC18E3439F4E3E0F0E089E08093570019 +:20736000849196C1813539F4E2E0F0E089E08093570084918DC1823631F489E526DF80E046 +:2073800024DF80E885C1823419F0873609F0E5C01092AB011092AA0100DF082FFEDEF82E6F +:2073A000FCDE682E8554823008F071C1902F80E0CF2DD0E0C82BD92B10926F00173609F08F +:2073C0004BC081E180935700E895DD24CC24C3943FC0E090AF01F090B0010091B1011091DD +:2073E000B201B6E46B16D9F4ED2DF0E0EE29FF29E4918E2FEADEDD2081F082E090E0A0E00F +:20740000B0E0E80EF91E0A1F1B1FE092AF01F092B0010093B1011093B201DC2418C0D801CB +:20742000C701B695A7959795879575D5CEDE82E090E0A0E0B0E0E80EF91E0A1F1B1FE092FB +:20744000AF01F092B0010093B1011093B2012197209709F0BECF7DC08090AF019090B001EB +:20746000A090B101B090B20196E4691609F05DC083E0F40180935700E89507B600FCFDCF64 +:2074800054C0F6E46F1661F5772031F1E090AF01F090B0010091B1011091B2017EDED82E20 +:2074A000CC24852D90E08C299D29F7010C0140925700E895112482E090E0A0E0B0E0E80E87 +:2074C000F91E0A1F1B1FE092AF01F092B0010093B1011093B20102C060DE582E742423C041 +:2074E000E090AF01F090B0010091B1011091B20116950795F794E79450DE682FC70113D5E2 +:207500008091AF019091B001A091B101B091B2010296A11DB11D8093AF019093B001A09313 +:20752000B101B093B201219704C05524772444244394209709F0A5CF96E4691641F485E01D +:20754000F40180935700E89507B600FCFDCF8DE03CDE82E080936F009CC0833471F4009156 +:20756000AF011091B00119DE90E021E0F8010C0120935700E89511247CCE833619F5E0905E +:20758000AF01F090B0010091B1011091B20105DEF701E16090E021E00C0120935700E89552 +:2075A000112482E090E0A0E0B0E0E80EF91E0A1F1B1FE092AF01F092B0010093B101109307 +:2075C000B20157CE8D3661F4E091AF01F091B00185E080935700E89507B600FCFDCF49CE80 +:2075E000823551F4E091AF01F091B00105911491812FEBDD802F4CC0843421F5E090AF01E0 +:20760000F090B0010091B1011091B20116950795F794E794C2DD682FC70185D48091AF013D +:207620009091B001A091B101B091B2010296A11DB11D8093AF019093B001A093B101B093BE +:20764000B20117CE843609F5E090AF01F090B0010091B1011091B201D801C701B695A795CA +:207660009795879558D4B1DD82E090E0A0E0B0E0E80EF91E0A1F1B1FE092AF01F092B00161 +:207680000093B1011093B20104C08B3111F08FE39CDD83E08093E9009091E8008091E80082 +:2076A0008E778093E80095FF04C010C08EB38823C9F08091E80080FFF9CF8091E8008E77BF +:2076C0008093E80003C08EB3882361F08091E80080FFF9CF84E08093E9008091E8008B7714 +:2076E0008093E800DF91CF911F910F91FF90EF90DF90CF90BF90AF909F908F907F906F90A9 +:207700005F904F9008959091B701892F8F77813249F58091B8018032A1F0813219F5913ADD +:2077200009F58091E800877F8093E8008CE091E067E070E027D28091E8008B778093E800EE +:207740000895913279F48091E800877F8093E8008CE091E067E070E079D28091E8008E77A5 +:207760008093E800089582E061EC42E0D1D083E061E842E1CDD084E060E842E1C9C01F9389 +:20778000209100081092000844B714BE88E10FB6F89480936000109260000FBE80E8E0E095 +:2077A000F0E00FB6F89480936100E09361000FBE31E035BF92E095BF3F9A209A559A809333 +:2077C00061001092610047985D9A289A109289008AEF8093880090936F0083E080938100E5 +:2077E000859194918F5F9F4F11F03093AE01942F41FF19C0809109012817A9F08093000815 +:20780000789480911301882339F08091AC019091AD018F5E9240C8F310920008F89481E0C5 +:20782000809313010CC090FF04C08091AE01882351F493FF09C080910901281729F0809173 +:20784000AE01882309F04EDCD4D078941092AB011092AA011EEF20C0D7DC4BD38091AA01E6 +:207860009091AB0181549F4110F0109213018091B3019091B40101969093B4018093B301FF +:20788000292F97FF03C0512F591B252F220F281710F4479801C0479A809113018823E1F653 +:2078A0008091E00081608093E0001CDC80E090E01F910895FA01923049F0933061F0913023 +:2078C000F9F484E191E022E130E01EC086E291E02EE330E019C0882329F484E691E024E07A +:2078E00030E012C0813029F488E691E022E230E00BC0823029F48CE891E028E130E004C089 +:2079000080E090E020E030E091838083C90108958093E9008091EB0081608093EB00109290 +:20792000ED006093EC004093ED008091EE00881F8827881F08958091B70188238CF403C06B +:207940008EB38823B1F08091E80082FFF9CF8091E8008B778093E80008958EB3882349F0A0 +:207960008091E80080FFF9CF8091E8008E778093E8000895EF92FF920F931F9345D04CD09A +:2079800008ED10E0F80180818F77808380818068808380818F7D808319BC1EBA1092B501FE +:2079A00080EEE82EF12CF70180818B7F8083F80180818160808380E060E042E0A9DFE1EE29 +:2079C000F0E080818E7F8083E2EEF0E0808181608083808188608083F70180818E7F80834C +:2079E000F8018081806180831F910F91FF90EF900895E7EDF0E08081816080838AE482BF76 +:207A000081E08093B601B6CFE8EDF0E080818E7F80831092E20008951092DA001092E100E0 +:207A200008951F920F920FB60F9211242F933F934F935F936F937F938F939F93AF93BF9358 +:207A4000EF93FF938091DA0080FF1BC08091D80080FF17C08091DA008E7F8093DA00809198 +:207A6000D90080FF0BC080E189BD82E189BD09B400FEFDCF81E08EBB3BD203C019BC1EBAE5 +:207A800037D28091E10080FF17C08091E20080FF13C08091E2008E7F8093E2008091E20068 +:207AA00080618093E2008091D80080628093D80019BC85E08EBB1CD28091E10084FF2CC068 +:207AC0008091E20084FF28C080E189BD82E189BD09B400FEFDCF8091D8008F7D8093D80091 +:207AE0008091E1008F7E8093E1008091E2008F7E8093E2008091E20081608093E2008091C4 +:207B0000B501882331F48091E30087FD02C081E001C084E08EBBECD18091E10083FF21C0C4 +:207B20008091E20083FF1DC08091E100877F8093E10082E08EBB1092B5018091E1008E7F05 +:207B40008093E1008091E2008E7F8093E2008091E20080618093E20080E060E042E0D8DEFB +:207B6000C7D1FF91EF91BF91AF919F918F917F916F915F914F913F912F910F900FBE0F9002 +:207B80001F9018959C014091BD015091BE014617570718F4F90190E044C06115710511F09B +:207BA000AB01F8CF8091E8008E778093E80040E050E0F0CF8EB3882309F444C0853009F4AB +:207BC00043C08091E80083FF02C081E008958091E80082FD31C08091E80080FF22C0809193 +:207BE000F3009091F200782F60E0292F30E0262B372B07C081918093F100415050402F5FF1 +:207C00003F4F4115510519F02830310598F390E02830310509F491E08091E8008E7780938B +:207C2000E8004115510531F6992321F605C08EB3882341F0853041F08091E80082FFF7CFAE +:207C400080E0089582E0089583E008959C016115710529F48091E8008B778093E800F90192 +:207C600026C08EB3882391F1853091F18091E80083FF02C081E008958091E80082FFF1CF04 +:207C800006C08091F10081936150704059F02091F3008091F200322F20E090E0822B932B7B +:207CA000892B79F78091E8008B778093E80061157105B9F605C08EB3882341F0853041F047 +:207CC0008091E80080FFF7CF80E0089582E0089583E008950F931F93DF93CF9300D0CDB7EE +:207CE000DEB7E7EBF1E08091F100819381E0EF3BF807C9F708DD8091E80083FFE4C08091D7 +:207D0000B7019091B801953009F46DC0963040F4913081F1913070F0933009F0D4C02AC05A +:207D2000983009F4A3C0993009F4B2C0963009F0CAC07CC0803809F4C6C0823809F0C3C0ED +:207D40008091BB0187708093E9008091EB001092E9002091E800277F2093E80090E025E08D +:207D6000969587952A95E1F781708093F1001092F10087C0882319F0823009F0A4C08F7193 +:207D8000823009F0A0C08091B901882331F52091BB01277009F497C02093E9008091EB004C +:207DA00080FF1BC0933021F48091EB00806213C08091EB0080618093EB0081E090E002C072 +:207DC000880F991F2A95E2F78093EA001092EA008091EB0088608093EB001092E9008091B5 +:207DE000E800877F51C0882309F06DC01091B9011F770FB7F8948091E800877F8093E80076 +:207E00009ADD8091E80080FFFCCF8091E3008078812B8093E30080688093E300112311F403 +:207E200082E001C083E08EBB0FBF4DC08058823008F049C08091B9019091BA016091BB01B9 +:207E4000AE014F5F5F4F36DDBC01009709F43BC08091E800877F8093E80089819A8192DE29 +:207E60008091E8008B778093E8002DC0803859F58091E800877F8093E8008091B501809345 +:207E8000F1008091E8008E778093E80054DD1BC08823C9F49091B9019230A8F48091E80052 +:207EA000877F8093E8009093B50145DD8091B501882331F48091E30087FD02C081E001C0D3 +:207EC00084E08EBB50DC8091E80083FF0AC08091EB0080628093EB008091E800877F809396 +:207EE000E8000F900F90CF91DF911F910F91089508951F938EB3882361F01091E9001092E7 +:207F0000E9008091E80083FF01C0E4DE17701093E9001F910895F999FECF92BD81BDF89A9C +:207F2000992780B50895262FF999FECF1FBA92BD81BD20BD0FB6F894FA9AF99A0FBE0196DC +:207F40000895F894FFCF4341544552494E4100770008000000000000080112011001020035 +:207F600000084123410001000201000109023E000201008032090400000102020100052415 +:207F8000001001042402040524060001070582030800FF09040100020A00000007050402AE +:207FA00010000107058302100001040309042203410072006400750069006E006F002000E3 +:207FC000590075006E002000200020002000200000001803410072006400750069006E0047 +:0C7FE0006F0020004C004C00430000002B +:00000001FF diff --git a/cores/arduino/IPAddress.h b/cores/arduino/IPAddress.h index 2585aec..078ac97 100644 --- a/cores/arduino/IPAddress.h +++ b/cores/arduino/IPAddress.h @@ -26,6 +26,7 @@ #ifndef IPAddress_h #define IPAddress_h +#include <stdint.h> #include <Printable.h> // A class to make it easier to handle and pass around IP addresses diff --git a/libraries/Bridge/Bridge.cpp b/libraries/Bridge/Bridge.cpp new file mode 100644 index 0000000..a3d911f --- /dev/null +++ b/libraries/Bridge/Bridge.cpp @@ -0,0 +1,229 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "Bridge.h" +#include <util/crc16.h> + +BridgeClass::BridgeClass(Stream &_stream) : + index(0), stream(_stream), started(false), max_retries(0) { + // Empty +} + +void BridgeClass::begin() { + if (started) + return; + started = true; + + // Wait for U-boot to finish startup + do { + dropAll(); + delay(1000); + } while (stream.available()>0); + + while (true) { + // Bridge interrupt: + // - Ask the bridge to close itself + uint8_t quit_cmd[] = {'X','X','X','X','X'}; + max_retries = 1; + transfer(quit_cmd, 5); + + // Bridge startup: + // - If the bridge is not running starts it safely + stream.print(CTRL_C); + delay(250); + stream.print(F("\n")); + delay(250); + stream.print(F("\n")); + delay(500); + // Wait for OpenWRT message + // "Press enter to activate console" + stream.print(F("run-bridge\n")); + delay(500); + dropAll(); + + // Reset the brigde to check if it is running + uint8_t cmd[] = {'X','X', '1','0','0'}; + uint8_t res[1]; + max_retries = 50; + uint16_t l = transfer(cmd, 5, res, 1); + if (l == TRANSFER_TIMEOUT) { + // Bridge didn't start... + // Maybe the board is starting-up? + + // Wait and retry + delay(1000); + continue; + } + if (res[0] != 0) + while (true); + + max_retries = 50; + return; + } +} + +void BridgeClass::put(const char *key, const char *value) { + // TODO: do it in a more efficient way + String cmd = "D"; + cmd += key; + cmd += "\xFE"; + cmd += value; + transfer((uint8_t*)cmd.c_str(), cmd.length()); +} + +unsigned int BridgeClass::get(const char *key, uint8_t *value, unsigned int maxlen) { + uint8_t cmd[] = {'d'}; + unsigned int l = transfer(cmd, 1, (uint8_t *)key, strlen(key), value, maxlen); + if (l < maxlen) + value[l] = 0; // Zero-terminate string + return l; +} + +void BridgeClass::crcUpdate(uint8_t c) { + + CRC = _crc_ccitt_update(CRC, c); + //CRC = CRC ^ c; + //CRC = (CRC >> 8) + (CRC << 8); +} + +void BridgeClass::crcReset() { + CRC = 0xFFFF; +} + +void BridgeClass::crcWrite() { + stream.write((char)(CRC >> 8)); + stream.write((char)(CRC & 0xFF)); +} + +bool BridgeClass::crcCheck(uint16_t _CRC) { + return CRC == _CRC; +} + +uint16_t BridgeClass::transfer(const uint8_t *buff1, uint16_t len1, + const uint8_t *buff2, uint16_t len2, + const uint8_t *buff3, uint16_t len3, + uint8_t *rxbuff, uint16_t rxlen) +{ + uint16_t len = len1 + len2 + len3; + uint8_t retries = 0; + for ( ; retries<max_retries; retries++, delay(100), dropAll() /* Delay for retransmission */) { + // Send packet + crcReset(); + stream.write((char)0xFF); // Start of packet (0xFF) + crcUpdate(0xFF); + stream.write((char)index); // Message index + crcUpdate(index); + stream.write((char)((len >> 8) & 0xFF)); // Message length (hi) + crcUpdate((len >> 8) & 0xFF); + stream.write((char)(len & 0xFF)); // Message length (lo) + crcUpdate(len & 0xFF); + for (uint16_t i=0; i<len1; i++) { // Payload + stream.write((char)buff1[i]); + crcUpdate(buff1[i]); + } + for (uint16_t i=0; i<len2; i++) { // Payload + stream.write((char)buff2[i]); + crcUpdate(buff2[i]); + } + for (uint16_t i=0; i<len3; i++) { // Payload + stream.write((char)buff3[i]); + crcUpdate(buff3[i]); + } + crcWrite(); // CRC + + // Wait for ACK in 100ms + if (timedRead(100) != 0xFF) + continue; + crcReset(); + crcUpdate(0xFF); + + // Check packet index + if (timedRead(5) != index) + continue; + crcUpdate(index); + + // Recv len + int lh = timedRead(5); + if (lh < 0) + continue; + crcUpdate(lh); + int ll = timedRead(5); + if (ll < 0) + continue; + crcUpdate(ll); + uint16_t l = lh; + l <<= 8; + l += ll; + + // Recv data + for (uint16_t i=0; i<l; i++) { + int c = timedRead(5); + if (c < 0) + continue; + // Cut received data if rxbuffer is too small + if (i < rxlen) + rxbuff[i] = c; + crcUpdate(c); + } + + // Check CRC + int crc_hi = timedRead(5); + if (crc_hi < 0) + continue; + int crc_lo = timedRead(5); + if (crc_lo < 0) + continue; + if (!crcCheck((crc_hi<<8)+crc_lo)) + continue; + + // Increase index + index++; + + // Return bytes received + if (l > rxlen) + return rxlen; + return l; + } + + // Max retries exceeded + return TRANSFER_TIMEOUT; +} + +int BridgeClass::timedRead(unsigned int timeout) { + int c; + unsigned long _startMillis = millis(); + do { + c = stream.read(); + if (c >= 0) return c; + } while(millis() - _startMillis < timeout); + return -1; // -1 indicates timeout +} + +void BridgeClass::dropAll() { + while (stream.available() > 0) { + stream.read(); + } +} + +// Bridge instance +#ifdef __AVR_ATmega32U4__ + // Leonardo variants (where HardwareSerial is Serial1) + SerialBridgeClass Bridge(Serial1); +#else + SerialBridgeClass Bridge(Serial); +#endif diff --git a/libraries/Bridge/Bridge.h b/libraries/Bridge/Bridge.h new file mode 100644 index 0000000..e4ed9f8 --- /dev/null +++ b/libraries/Bridge/Bridge.h @@ -0,0 +1,97 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef BRIDGE_H_ +#define BRIDGE_H_ + +#include <Arduino.h> +#include <Stream.h> + +class BridgeClass { +public: + BridgeClass(Stream &_stream); + void begin(); + + // Methods to handle key/value datastore + void put(const char *key, const char *value); + void put(const String &key, const String &value) + { put(key.c_str(), value.c_str()); } + unsigned int get(const char *key, uint8_t *buff, unsigned int size); + unsigned int get(const char *key, char *value, unsigned int maxlen) + { get(key, reinterpret_cast<uint8_t *>(value), maxlen); } + + // Trasnfer a frame (with error correction and response) + uint16_t transfer(const uint8_t *buff1, uint16_t len1, + const uint8_t *buff2, uint16_t len2, + const uint8_t *buff3, uint16_t len3, + uint8_t *rxbuff, uint16_t rxlen); + // multiple inline versions of the same function to allow efficient frame concatenation + uint16_t transfer(const uint8_t *buff1, uint16_t len1) + { return transfer(buff1, len1, NULL, 0); } + uint16_t transfer(const uint8_t *buff1, uint16_t len1, + uint8_t *rxbuff, uint16_t rxlen) + { return transfer(buff1, len1, NULL, 0, rxbuff, rxlen); } + uint16_t transfer(const uint8_t *buff1, uint16_t len1, + const uint8_t *buff2, uint16_t len2, + uint8_t *rxbuff, uint16_t rxlen) + { return transfer(buff1, len1, buff2, len2, NULL, 0, rxbuff, rxlen); } + + static const int TRANSFER_TIMEOUT = 0xFFFF; + +private: + uint8_t index; + int timedRead(unsigned int timeout); + void dropAll(); + +private: + void crcUpdate(uint8_t c); + void crcReset(); + void crcWrite(); + bool crcCheck(uint16_t _CRC); + uint16_t CRC; + +private: + static const char CTRL_C = 3; + Stream &stream; + bool started; + uint8_t max_retries; +}; + +// This subclass uses a serial port Stream +class SerialBridgeClass : public BridgeClass { +public: + SerialBridgeClass(HardwareSerial &_serial) + : BridgeClass(_serial), serial(_serial) { + // Empty + } + + void begin() { + serial.begin(250000); + BridgeClass::begin(); + } + +private: + HardwareSerial &serial; +}; + +extern SerialBridgeClass Bridge; + +#endif /* BRIDGE_H_ */ + +#include <Console.h> +#include <Process.h> diff --git a/libraries/Bridge/Console.cpp b/libraries/Bridge/Console.cpp new file mode 100644 index 0000000..8607421 --- /dev/null +++ b/libraries/Bridge/Console.cpp @@ -0,0 +1,153 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include <Console.h> + +// Default constructor uses global Bridge instance +ConsoleClass::ConsoleClass() : + bridge(Bridge), inBuffered(0), inReadPos(0), inBuffer(NULL), + autoFlush(true) +{ + // Empty +} + +// Constructor with a user provided BridgeClass instance +ConsoleClass::ConsoleClass(BridgeClass &_b) : + bridge(_b), inBuffered(0), inReadPos(0), inBuffer(NULL), + autoFlush(true) +{ + // Empty +} + +ConsoleClass::~ConsoleClass() { + end(); +} + +size_t ConsoleClass::write(uint8_t c) { + if (autoFlush) { + uint8_t tmp[] = { 'P', c }; + bridge.transfer(tmp, 2); + return 1; + } else { + outBuffer[outBuffered++] = c; + if (outBuffered == outBufferSize) + flush(); + } +} + +size_t ConsoleClass::write(const uint8_t *buff, size_t size) { + if (autoFlush) { + // TODO: do it in a more efficient way + uint8_t *tmp = new uint8_t[size+1]; + tmp[0] = 'P'; + memcpy(tmp+1, buff, size); + bridge.transfer(tmp, size+1); + delete[] tmp; + return size; + } else { + while (size > 0) { + outBuffer[outBuffered++] = *buff++; + size--; + if (outBuffered == outBufferSize) + flush(); + } + } +} + +void ConsoleClass::flush() { + if (autoFlush) + return; + + bridge.transfer(outBuffer, outBuffered); + outBuffered = 1; +} + +void ConsoleClass::noBuffer() { + if (autoFlush) + return; + delete[] outBuffer; + autoFlush = true; +} + +void ConsoleClass::buffer(uint8_t size) { + noBuffer(); + if (size==0) + return; + outBuffer = new uint8_t[size+1]; + outBuffer[0] = 'P'; // WRITE tag + outBufferSize = size+1; + outBuffered = 1; + autoFlush = false; +} + +bool ConsoleClass::connected() { + uint8_t tmp = 'a'; + bridge.transfer(&tmp, 1, &tmp, 1); + return tmp==1; +} + +int ConsoleClass::available() { + // Look if there is new data available + doBuffer(); + return inBuffered; +} + +int ConsoleClass::read() { + doBuffer(); + if (inBuffered == 0) + return -1; // no chars available + else { + inBuffered--; + return inBuffer[inReadPos++]; + } +} + +int ConsoleClass::peek() { + doBuffer(); + if (inBuffered == 0) + return -1; // no chars available + else + return inBuffer[inReadPos]; +} + +void ConsoleClass::doBuffer() { + // If there are already char in buffer exit + if (inBuffered > 0) + return; + + // Try to buffer up to 32 characters + inReadPos = 0; + uint8_t tmp[] = { 'p', BUFFER_SIZE }; + inBuffered = bridge.transfer(tmp, 2, inBuffer, BUFFER_SIZE); +} + +void ConsoleClass::begin() { + bridge.begin(); + end(); + inBuffer = new uint8_t[BUFFER_SIZE]; +} + +void ConsoleClass::end() { + noBuffer(); + if (inBuffer) { + delete[] inBuffer; + inBuffer = NULL; + } +} + +ConsoleClass Console; diff --git a/libraries/Bridge/Console.h b/libraries/Bridge/Console.h new file mode 100644 index 0000000..73a9739 --- /dev/null +++ b/libraries/Bridge/Console.h @@ -0,0 +1,69 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef CONSOLE_H_ +#define CONSOLE_H_ + +#include <Bridge.h> + +class ConsoleClass : public Stream { +public: + // Default constructor uses global Bridge instance + ConsoleClass(); + // Constructor with a user provided BridgeClass instance + ConsoleClass(BridgeClass &_b); + ~ConsoleClass(); + + void begin(); + void end(); + + void buffer(uint8_t size); + void noBuffer(); + + bool connected(); + + // Stream methods + // (read from console socket) + int available(); + int read(); + int peek(); + // (write to console socket) + size_t write(uint8_t); + size_t write(const uint8_t *buffer, size_t size); + void flush(); + + operator bool () { return connected(); } + +private: + BridgeClass &bridge; + + void doBuffer(); + uint8_t inBuffered; + uint8_t inReadPos; + static const int BUFFER_SIZE = 32; + uint8_t *inBuffer; + + bool autoFlush; + uint8_t outBuffered; + uint8_t outBufferSize; + uint8_t *outBuffer; +}; + +extern ConsoleClass Console; + +#endif diff --git a/libraries/Bridge/FileIO.cpp b/libraries/Bridge/FileIO.cpp new file mode 100644 index 0000000..83c889e --- /dev/null +++ b/libraries/Bridge/FileIO.cpp @@ -0,0 +1,250 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include <FileIO.h> + + + +File::File(BridgeClass &b) : mode(255), bridge(b) { + // Empty +} + +File::File(const char *_filename, uint8_t _mode, BridgeClass &b) : mode(_mode), bridge(b) { + filename = _filename; + char modes[] = {'r','w','a'}; + uint8_t cmd[] = {'F', modes[mode]}; + uint8_t res[2]; + dirPosition = 1; + bridge.transfer(cmd, 2, (uint8_t*)filename.c_str(), filename.length(), res, 2); + if (res[0] != 0) { // res[0] contains error code + mode = 255; // In case of error keep the file closed + return; + } + handle = res[1]; + buffered = 0; +} + +File::operator bool() { + return (mode != 255); +} + +File::~File() { + close(); +} + +size_t File::write(uint8_t c) { + return write(&c, 1); +} + +size_t File::write(const uint8_t *buf, size_t size) { + if (mode == 255) + return -1; + uint8_t cmd[] = {'g', handle}; + uint8_t res[1]; + bridge.transfer(cmd, 2, buf, size, res, 1); + if (res[0] != 0) // res[0] contains error code + return -res[0]; + return size; +} + +int File::read() { + doBuffer(); + if (buffered == 0) + return -1; // no chars available + else { + buffered--; + return buffer[readPos++]; + } +} + +int File::peek() { + doBuffer(); + if (buffered == 0) + return -1; // no chars available + else + return buffer[readPos]; +} + +boolean File::seek(uint32_t position) { + uint8_t cmd[] = { + 's', + handle, + (position >> 24) & 0xFF, + (position >> 16) & 0xFF, + (position >> 8) & 0xFF, + position & 0xFF + }; + uint8_t res[1]; + bridge.transfer(cmd, 6, res, 1); + if (res[0]==0) { + // If seek succeed then flush buffers + buffered = 0; + return true; + } + return false; +} + +uint32_t File::position() { + uint8_t cmd[] = {'S', handle}; + uint8_t res[5]; + bridge.transfer(cmd, 2, res, 5); + //err = res[0]; // res[0] contains error code + uint32_t pos = res[1] << 24; + pos += res[2] << 16; + pos += res[3] << 8; + pos += res[4]; + return pos - buffered; +} + +void File::doBuffer() { + // If there are already char in buffer exit + if (buffered > 0) + return; + + // Try to buffer up to 32 characters + readPos = 0; + uint8_t cmd[] = {'G', handle, sizeof(buffer)}; + buffered = bridge.transfer(cmd, 3, buffer, sizeof(buffer)) - 1; + //err = buff[0]; // First byte is error code + if (buffered>0) { + // Shift the reminder of buffer + for (uint8_t i=0; i<buffered; i++) + buffer[i] = buffer[i+1]; + } +} + +int File::available() { + // Look if there is new data available + doBuffer(); + return buffered; +} + +void File::flush() { +} + +//int read(void *buf, uint16_t nbyte) + +//uint32_t size() + +void File::close() { + if (mode == 255) + return; + uint8_t cmd[] = {'f', handle}; + bridge.transfer(cmd, 2); + mode = 255; +} + +const char *File::name() { + return filename.c_str(); +} + + +boolean File::isDirectory() { + uint8_t res[1]; + uint8_t lenght; + uint8_t cmd[] = {'i'}; + if (mode != 255) + return 0; + + bridge.transfer(cmd, 1, (uint8_t *)filename.c_str(), filename.length(), res, 1); + return res[0]; +} + + +File File::openNextFile(uint8_t mode){ + Process awk; + char tmp; + String command; + String filepath; + if (dirPosition == 0xFFFF) return File(); + + command = "ls "; + command += filename; + command += " | awk 'NR=="; + command += dirPosition; + command += "'"; + + awk.runShellCommand(command); + + while(awk.running()); + + command = ""; + + while (awk.available()){ + tmp = awk.read(); + if (tmp!='\n') command += tmp; + } + if (command.length() == 0) + return File(); + dirPosition++; + filepath = filename + "/" + command; + return File(filepath.c_str(),mode); + +} + +void File::rewindDirectory(void){ + dirPosition = 1; +} + + + + + + +boolean FileSystemClass::begin() { + return true; +} + +File FileSystemClass::open(const char *filename, uint8_t mode) { + return File(filename, mode); +} + +boolean FileSystemClass::exists(const char *filepath) { + Process ls; + ls.begin("ls"); + ls.addParameter(filepath); + int res = ls.run(); + return (res == 0); +} + +boolean FileSystemClass::mkdir(const char *filepath) { + Process mk; + mk.begin("mkdir"); + mk.addParameter("-p"); + mk.addParameter(filepath); + int res = mk.run(); + return (res == 0); +} + +boolean FileSystemClass::remove(const char *filepath) { + Process rm; + rm.begin("rm"); + rm.addParameter(filepath); + int res = rm.run(); + return (res == 0); +} + +boolean FileSystemClass::rmdir(const char *filepath) { + Process rm; + rm.begin("rmdir"); + rm.addParameter(filepath); + int res = rm.run(); + return (res == 0); +} + +FileSystemClass FileSystem; diff --git a/libraries/Bridge/FileIO.h b/libraries/Bridge/FileIO.h new file mode 100644 index 0000000..0807287 --- /dev/null +++ b/libraries/Bridge/FileIO.h @@ -0,0 +1,103 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef __FILEIO_H__ +#define __FILEIO_H__ + +#include <Process.h> + +#define FILE_READ 0 +#define FILE_WRITE 1 +#define FILE_APPEND 2 + +class File : public Stream { + +public: + File(BridgeClass &b = Bridge); + File(const char *_filename, uint8_t _mode, BridgeClass &b = Bridge); + ~File(); + + virtual size_t write(uint8_t); + virtual size_t write(const uint8_t *buf, size_t size); + virtual int read(); + virtual int peek(); + virtual int available(); + virtual void flush(); + int read(void *buf, uint16_t nbyte); + boolean seek(uint32_t pos); + uint32_t position(); + uint32_t size(); + void close(); + operator bool(); + const char * name(); + boolean isDirectory(); + File openNextFile(uint8_t mode = FILE_READ); + void rewindDirectory(void); + + //using Print::write; + +private: + void doBuffer(); + uint8_t buffered; + uint8_t readPos; + uint16_t dirPosition; + static const int BUFFER_SIZE = 64; + uint8_t buffer[BUFFER_SIZE]; + + +private: + BridgeClass &bridge; + String filename; + uint8_t mode; + uint8_t handle; + +}; + +class FileSystemClass { +public: + FileSystemClass() : bridge(Bridge) { } + FileSystemClass(BridgeClass &_b) : bridge(_b) { } + + boolean begin(); + + // Open the specified file/directory with the supplied mode (e.g. read or + // write, etc). Returns a File object for interacting with the file. + // Note that currently only one file can be open at a time. + File open(const char *filename, uint8_t mode = FILE_READ); + + // Methods to determine if the requested file path exists. + boolean exists(const char *filepath); + + // Create the requested directory heirarchy--if intermediate directories + // do not exist they will be created. + boolean mkdir(const char *filepath); + + // Delete the file. + boolean remove(const char *filepath); + + boolean rmdir(const char *filepath); + +private: + friend class File; + + BridgeClass &bridge; +}; + +extern FileSystemClass FileSystem; + +#endif diff --git a/libraries/Bridge/HttpClient.cpp b/libraries/Bridge/HttpClient.cpp new file mode 100644 index 0000000..510af38 --- /dev/null +++ b/libraries/Bridge/HttpClient.cpp @@ -0,0 +1,53 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "HttpClient.h" + +unsigned int HttpClient::get(String &url) { + begin("curl"); + addParameter(url); + return run(); +} + +unsigned int HttpClient::get(const char *url) { + begin("curl"); + addParameter(url); + return run(); +} + +void HttpClient::getAsynchronously(String &url) { + begin("curl"); + addParameter(url); + runAsynchronously(); +} + +void HttpClient::getAsynchronously(const char *url) { + begin("curl"); + addParameter(url); + runAsynchronously(); +} + +boolean HttpClient::ready() { + return running(); +} + +unsigned int HttpClient::getResult() { + return exitValue(); +} + + diff --git a/libraries/Bridge/HttpClient.h b/libraries/Bridge/HttpClient.h new file mode 100644 index 0000000..940a66d --- /dev/null +++ b/libraries/Bridge/HttpClient.h @@ -0,0 +1,36 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef HTTPCLIENT_H_ +#define HTTPCLIENT_H_ + +#include <Process.h> + +class HttpClient : public Process { +public: + + unsigned int get(String &url); + unsigned int get(const char * url); + void getAsynchronously(String &url); + void getAsynchronously(const char * url); + boolean ready(); + unsigned int getResult(); + +}; + +#endif /* HTTPCLIENT_H_ */ diff --git a/libraries/Bridge/Mailbox.cpp b/libraries/Bridge/Mailbox.cpp new file mode 100644 index 0000000..cf2b9e5 --- /dev/null +++ b/libraries/Bridge/Mailbox.cpp @@ -0,0 +1,56 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include <Mailbox.h> + +unsigned int MailboxClass::readMessage(uint8_t *buff, unsigned int size) { + uint8_t tmp[] = { 'm' }; + return bridge.transfer(tmp, 1, buff, size); +} + +void MailboxClass::readMessage(String &str, unsigned int maxLength) { + uint8_t tmp[] = { 'm' }; + // XXX: Is there a better way to create the string? + uint8_t buff[maxLength+1]; + int l = bridge.transfer(tmp, 1, buff, maxLength); + buff[l] = 0; + str = (const char *)buff; +} + +void MailboxClass::writeMessage(const uint8_t *buff, unsigned int size) { + uint8_t cmd[] = {'M'}; + bridge.transfer(cmd, 1, buff, size, NULL, 0); +} + +void MailboxClass::writeMessage(const String& str) { + writeMessage((uint8_t*) str.c_str(), str.length()); +} + +void MailboxClass::writeJSON(const String& str) { + uint8_t cmd[] = {'J'}; + bridge.transfer(cmd, 1, (uint8_t*) str.c_str(), str.length(), NULL, 0); +} + +unsigned int MailboxClass::messageAvailable() { + uint8_t tmp[] = {'n'}; + uint8_t res[2]; + bridge.transfer(tmp, 1, res, 2); + return (res[0] << 8) + res[1]; +} + +MailboxClass Mailbox(Bridge); diff --git a/libraries/Bridge/Mailbox.h b/libraries/Bridge/Mailbox.h new file mode 100644 index 0000000..35bd1d6 --- /dev/null +++ b/libraries/Bridge/Mailbox.h @@ -0,0 +1,53 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _MAILBOX_CLASS_H_INCLUDED_ +#define _MAILBOX_CLASS_H_INCLUDED_ + +#include <Bridge.h> + +class MailboxClass { +public: + MailboxClass(BridgeClass &b = Bridge) : bridge(b) { } + + void begin() { } + void end() { } + + // Receive a message and store it inside a buffer + unsigned int readMessage(uint8_t *buffer, unsigned int size); + // Receive a message and store it inside a String + void readMessage(String &str, unsigned int maxLength=128); + + // Send a message + void writeMessage(const uint8_t *buffer, unsigned int size); + // Send a message + void writeMessage(const String& str); + // Send a JSON message + void writeJSON(const String& str); + + // Return the size of the next available message, 0 if there are + // no messages in queue. + unsigned int messageAvailable(); + +private: + BridgeClass &bridge; +}; + +extern MailboxClass Mailbox; + +#endif // _MAILBOX_CLASS_H_INCLUDED_ diff --git a/libraries/Bridge/Process.cpp b/libraries/Bridge/Process.cpp new file mode 100644 index 0000000..219922a --- /dev/null +++ b/libraries/Bridge/Process.cpp @@ -0,0 +1,142 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include <Process.h> + +Process::~Process() { + close(); +} + +size_t Process::write(uint8_t c) { + uint8_t cmd[] = {'I', handle, c}; + bridge.transfer(cmd, 3); + return 1; +} + +void Process::flush() { +} + +int Process::available() { + // Look if there is new data available + doBuffer(); + return buffered; +} + +int Process::read() { + doBuffer(); + if (buffered == 0) + return -1; // no chars available + else { + buffered--; + return buffer[readPos++]; + } +} + +int Process::peek() { + doBuffer(); + if (buffered == 0) + return -1; // no chars available + else + return buffer[readPos]; +} + +void Process::doBuffer() { + // If there are already char in buffer exit + if (buffered > 0) + return; + + // Try to buffer up to 32 characters + readPos = 0; + uint8_t cmd[] = {'O', handle, sizeof(buffer)}; + buffered = bridge.transfer(cmd, 3, buffer, sizeof(buffer)); +} + +void Process::begin(const String &command) { + close(); + cmdline = new String(command); +} + +void Process::addParameter(const String ¶m) { + *cmdline += "\xFE"; + *cmdline += param; +} + +void Process::runAsynchronously() { + uint8_t cmd[] = {'R'}; + uint8_t res[2]; + bridge.transfer(cmd, 1, (uint8_t*)cmdline->c_str(), cmdline->length(), res, 2); + handle = res[1]; + + delete cmdline; + cmdline = NULL; + + if (res[0]==0) // res[0] contains error code + started = true; +} + +boolean Process::running() { + uint8_t cmd[] = {'r', handle}; + uint8_t res[1]; + bridge.transfer(cmd, 2, res, 1); + return (res[0] == 1); +} + +unsigned int Process::exitValue() { + uint8_t cmd[] = {'W', handle}; + uint8_t res[2]; + bridge.transfer(cmd, 2, res, 2); + return (res[0] << 8) + res[1]; +} + +unsigned int Process::run() { + runAsynchronously(); + while (running()) + delay(100); + return exitValue(); +} + +void Process::close() { + if (started) { + uint8_t cmd[] = {'w', handle}; + bridge.transfer(cmd, 2); + } + started = false; +} + +unsigned int Process::runShellCommand(const String &command) { + runShellCommandAsynchronously(command); + while (running()) + delay(100); + return exitValue(); +} + +void Process::runShellCommandAsynchronously(const String &command) { + begin("/bin/ash"); + addParameter("-c"); + addParameter(command); + runAsynchronously(); +} + +// This method is currently unused +//static unsigned int __commandOutputAvailable(uint8_t handle) { +// uint8_t cmd[] = {'o', handle}; +// uint8_t res[1]; +// Bridge.transfer(cmd, 2, res, 1); +// return res[0]; +//} + diff --git a/libraries/Bridge/Process.h b/libraries/Bridge/Process.h new file mode 100644 index 0000000..cacf516 --- /dev/null +++ b/libraries/Bridge/Process.h @@ -0,0 +1,69 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef PROCESS_H_ +#define PROCESS_H_ + +#include <Bridge.h> + +class Process : public Stream { +public: + // Constructor with a user provided BridgeClass instance + Process(BridgeClass &_b = Bridge) : + bridge(_b), started(false), buffered(0), readPos(0) { } + ~Process(); + + void begin(const String &command); + void addParameter(const String ¶m); + unsigned int run(); + void runAsynchronously(); + boolean running(); + unsigned int exitValue(); + void close(); + + unsigned int runShellCommand(const String &command); + void runShellCommandAsynchronously(const String &command); + + operator bool () { return started; } + + // Stream methods + // (read from process stdout) + int available(); + int read(); + int peek(); + // (write to process stdin) + size_t write(uint8_t); + void flush(); + // TODO: add optimized function for block write + +private: + BridgeClass &bridge; + unsigned int handle; + String *cmdline; + boolean started; + +private: + void doBuffer(); + uint8_t buffered; + uint8_t readPos; + static const int BUFFER_SIZE = 64; + uint8_t buffer[BUFFER_SIZE]; + +}; + +#endif diff --git a/libraries/Bridge/YunClient.cpp b/libraries/Bridge/YunClient.cpp new file mode 100644 index 0000000..aaaf907 --- /dev/null +++ b/libraries/Bridge/YunClient.cpp @@ -0,0 +1,167 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include <YunClient.h> + +YunClient::YunClient(int _h, BridgeClass &_b) : + bridge(_b), handle(_h), opened(true), buffered(0) { +} + +YunClient::YunClient(BridgeClass &_b) : + bridge(_b), handle(0), opened(false), buffered(0) { +} + +YunClient::~YunClient() { +} + +YunClient& YunClient::operator=(const YunClient &_x) { + opened = _x.opened; + handle = _x.handle; + return *this; +} + +void YunClient::stop() { + if (opened) { + uint8_t cmd[] = {'j', handle}; + bridge.transfer(cmd, 2); + } + opened = false; +} + +void YunClient::doBuffer() { + // If there are already char in buffer exit + if (buffered > 0) + return; + + // Try to buffer up to 32 characters + readPos = 0; + uint8_t cmd[] = {'K', handle, sizeof(buffer)}; + buffered = bridge.transfer(cmd, 3, buffer, sizeof(buffer)); +} + +int YunClient::available() { + // Look if there is new data available + doBuffer(); + return buffered; +} + +int YunClient::read() { + doBuffer(); + if (buffered == 0) + return -1; // no chars available + else { + buffered--; + return buffer[readPos++]; + } +} + +int YunClient::read(uint8_t *buff, size_t size) { + int readed = 0; + do { + if (buffered == 0) { + doBuffer(); + if (buffered == 0) + return readed; + } + buff[readed++] = buffer[readPos++]; + buffered--; + } while (readed < size); + return readed; +} + +int YunClient::peek() { + doBuffer(); + if (buffered == 0) + return -1; // no chars available + else + return buffer[readPos]; +} + +size_t YunClient::write(uint8_t c) { + if (!opened) + return 0; + uint8_t cmd[] = {'l', handle, c}; + bridge.transfer(cmd, 3); + return 1; +} + +size_t YunClient::write(const uint8_t *buf, size_t size) { + if (!opened) + return 0; + uint8_t cmd[] = {'l', handle}; + bridge.transfer(cmd, 2, buf, size, NULL, 0); + return size; +} + +void YunClient::flush() { +} + +uint8_t YunClient::connected() { + if (!opened) + return false; + uint8_t cmd[] = {'L', handle}; + uint8_t res[1]; + bridge.transfer(cmd, 2, res, 1); + return (res[0] == 1); +} + +int YunClient::connect(IPAddress ip, uint16_t port) { + String address; + address.reserve(18); + address += ip[0]; + address += '.'; + address += ip[1]; + address += '.'; + address += ip[2]; + address += '.'; + address += ip[3]; + return connect(address.c_str(), port); +} + +int YunClient::connect(const char *host, uint16_t port) { + uint8_t tmp[] = { + 'C', + (port >> 8) & 0xFF, + port & 0xFF + }; + uint8_t res[1]; + int l = bridge.transfer(tmp, 3, (const uint8_t *)host, strlen(host), res, 1); + if (l==0) + return 0; + handle = res[0]; + + // wait for connection + uint8_t tmp2[] = { 'c', handle }; + uint8_t res2[1]; + while (true) { + bridge.transfer(tmp2, 2, res2, 1); + if (res2[0] == 0) + break; + delay(1); + } + opened = true; + + // check for successful connection + if (connected()) + return 1; + + opened = false; + handle = 0; + return 0; +} + diff --git a/libraries/Bridge/YunClient.h b/libraries/Bridge/YunClient.h new file mode 100644 index 0000000..59e3a0c --- /dev/null +++ b/libraries/Bridge/YunClient.h @@ -0,0 +1,68 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _YUN_CLIENT_H_ +#define _YUN_CLIENT_H_ + +#include <Bridge.h> +#include <Client.h> + +class YunClient : public Client { +public: + // Constructor with a user provided BridgeClass instance + YunClient(int _h, BridgeClass &_b = Bridge); + YunClient(BridgeClass &_b = Bridge); + ~YunClient(); + + // Stream methods + // (read message) + virtual int available(); + virtual int read(); + virtual int read(uint8_t *buf, size_t size); + virtual int peek(); + // (write response) + virtual size_t write(uint8_t); + virtual size_t write(const uint8_t *buf, size_t size); + virtual void flush(); + // TODO: add optimized function for block write + + virtual operator bool () { return opened; } + + YunClient& operator=(const YunClient &_x); + + virtual void stop(); + virtual uint8_t connected(); + + virtual int connect(IPAddress ip, uint16_t port); + virtual int connect(const char *host, uint16_t port); + +private: + BridgeClass &bridge; + unsigned int handle; + boolean opened; + +private: + void doBuffer(); + uint8_t buffered; + uint8_t readPos; + static const int BUFFER_SIZE = 64; + uint8_t buffer[BUFFER_SIZE]; + +}; + +#endif // _YUN_CLIENT_H_ diff --git a/libraries/Bridge/YunServer.cpp b/libraries/Bridge/YunServer.cpp new file mode 100644 index 0000000..3473ce8 --- /dev/null +++ b/libraries/Bridge/YunServer.cpp @@ -0,0 +1,54 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include <YunServer.h> +#include <YunClient.h> + +YunServer::YunServer(uint16_t _p, BridgeClass &_b) : + bridge(_b), port(_p), listening(false), useLocalhost(false) { +} + +void YunServer::begin() { + uint8_t tmp[] = { + 'N', + (port >> 8) & 0xFF, + port & 0xFF + }; + uint8_t res[1]; + String address = F("127.0.0.1"); + if (!useLocalhost) + address = F("0.0.0.0"); + bridge.transfer(tmp, 3, (const uint8_t *)address.c_str(), address.length(), res, 1); + listening = (res[0] == 1); +} + +YunClient YunServer::accept() { + uint8_t cmd[] = {'k'}; + uint8_t res[1]; + unsigned int l = bridge.transfer(cmd, 1, res, 1); + if (l==0) + return YunClient(); + return YunClient(res[0]); +} + +size_t YunServer::write(uint8_t c) { + uint8_t cmd[] = { 'b', c }; + bridge.transfer(cmd, 2); + return 1; +} + diff --git a/libraries/Bridge/YunServer.h b/libraries/Bridge/YunServer.h new file mode 100644 index 0000000..69fdeab --- /dev/null +++ b/libraries/Bridge/YunServer.h @@ -0,0 +1,47 @@ +/* + Copyright (c) 2013 Arduino LLC. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef _YUN_SERVER_H_ +#define _YUN_SERVER_H_ + +#include <Bridge.h> +#include <Server.h> + +class YunClient; + +class YunServer : public Server { +public: + // Constructor with a user provided BridgeClass instance + YunServer(uint16_t port = 5555, BridgeClass &_b = Bridge); + + void begin(); + YunClient accept(); + + virtual size_t write(uint8_t c); + + void listenOnLocalhost() { useLocalhost = true; } + void noListenOnLocalhost() { useLocalhost = false; } + +private: + uint16_t port; + bool listening; + bool useLocalhost; + BridgeClass &bridge; +}; + +#endif // _YUN_SERVER_H_ diff --git a/libraries/Bridge/examples/Bridge/Bridge.ino b/libraries/Bridge/examples/Bridge/Bridge.ino new file mode 100644 index 0000000..277982a --- /dev/null +++ b/libraries/Bridge/examples/Bridge/Bridge.ino @@ -0,0 +1,175 @@ + +// Possible commands are listed here: +// +// "digital/13" -> digitalRead(13) +// "digital/13/1" -> digitalWrite(13, HIGH) +// "analog/2/123" -> analogWrite(2, 123) +// "analog/2" -> analogRead(2) +// "mode/13/input" -> pinMode(13, INPUT) +// "mode/13/output" -> pinMode(13, OUTPUT) + +#include <Bridge.h> +#include <YunServer.h> +#include <YunClient.h> + +// Listen on default port 5555, the webserver on the Yun +// will forward there all the HTTP requests for us. +YunServer server; + +void setup() { + Serial.begin(9600); + + // Bridge startup + pinMode(13,OUTPUT); + digitalWrite(13, LOW); + Bridge.begin(); + digitalWrite(13, HIGH); + + // Listen for incoming connection only from localhost + // (no one from the external network could connect) + server.listenOnLocalhost(); + server.begin(); +} + +void loop() { + // Get clients coming from server + YunClient client = server.accept(); + + // There is a new client? + if (client) { + // Process request + process(client); + + // Close connection and free resources. + client.stop(); + } + + delay(50); // Poll every 50ms +} + +void process(YunClient client) { + // read the command + String command = client.readStringUntil('/'); + + // is "digital" command? + if (command == "digital") { + digitalCommand(client); + } + + // is "analog" command? + if (command == "analog") { + analogCommand(client); + } + + // is "mode" command? + if (command == "mode") { + modeCommand(client); + } +} + +void digitalCommand(YunClient client) { + int pin, value; + + // Read pin number + pin = client.parseInt(); + + // If the next character is a '/' it means we have an URL + // with a value like: "/digital/13/1" + if (client.read() == '/') { + value = client.parseInt(); + digitalWrite(pin, value); + } + else { + value = digitalRead(pin); + } + + // Send feedback to client + client.print(F("Pin D")); + client.print(pin); + client.print(F(" set to ")); + client.println(value); + + // Update datastore key with the current pin value + String key = "D"; + key += pin; + Bridge.put(key, String(value)); +} + +void analogCommand(YunClient client) { + int pin, value; + + // Read pin number + pin = client.parseInt(); + + // If the next character is a '/' it means we have an URL + // with a value like: "/analog/5/120" + if (client.read() == '/') { + // Read value and execute command + value = client.parseInt(); + analogWrite(pin, value); + + // Send feedback to client + client.print(F("Pin D")); + client.print(pin); + client.print(F(" set to analog ")); + client.println(value); + + // Update datastore key with the current pin value + String key = "D"; + key += pin; + Bridge.put(key, String(value)); + } + else { + // Read analog pin + value = analogRead(pin); + + // Send feedback to client + client.print(F("Pin A")); + client.print(pin); + client.print(F(" reads analog ")); + client.println(value); + + // Update datastore key with the current pin value + String key = "A"; + key += pin; + Bridge.put(key, String(value)); + } +} + +void modeCommand(YunClient client) { + int pin; + + // Read pin number + pin = client.parseInt(); + + // If the next character is not a '/' we have a malformed URL + if (client.read() != '/') { + client.println(F("error")); + return; + } + + String mode = client.readStringUntil('\r'); + + if (mode == "input") { + pinMode(pin, INPUT); + // Send feedback to client + client.print(F("Pin D")); + client.print(pin); + client.print(F(" configured as INPUT!")); + return; + } + + if (mode == "output") { + pinMode(pin, OUTPUT); + // Send feedback to client + client.print(F("Pin D")); + client.print(pin); + client.print(F(" configured as OUTPUT!")); + return; + } + + client.print(F("error: invalid mode ")); + client.print(mode); +} + + diff --git a/libraries/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino b/libraries/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino new file mode 100644 index 0000000..4cdf4c1 --- /dev/null +++ b/libraries/Bridge/examples/ConsoleAsciiTable/ConsoleAsciiTable.ino @@ -0,0 +1,94 @@ +/* + ASCII table + + Prints out byte values in all possible formats: + * as raw binary values + * as ASCII-encoded decimal, hex, octal, and binary values + + For more on ASCII, see http://www.asciitable.com and http://en.wikipedia.org/wiki/ASCII + + The circuit: No external hardware needed. + + created 2006 + by Nicholas Zambetti + modified 9 Apr 2012 + by Tom Igoe + modified 22 May 2013 + by Cristian Maglie + + This example code is in the public domain. + + <http://www.zambetti.com> + + */ + +#include <Console.h> + +void setup() { + //Initialize Console and wait for port to open: + Bridge.begin(); + Console.begin(); + + // Uncomment the following line to enable buffering: + // - better transmission speed and efficiency + // - needs to call Console.flush() to ensure that all + // transmitted data is sent + + //Console.buffer(64); + + while (!Console) { + ; // wait for Console port to connect. + } + + // prints title with ending line break + Console.println("ASCII Table ~ Character Map"); +} + +// first visible ASCIIcharacter '!' is number 33: +int thisByte = 33; +// you can also write ASCII characters in single quotes. +// for example. '!' is the same as 33, so you could also use this: +//int thisByte = '!'; + +void loop() { + // prints value unaltered, i.e. the raw binary version of the + // byte. The Console monitor interprets all bytes as + // ASCII, so 33, the first number, will show up as '!' + Console.write(thisByte); + + Console.print(", dec: "); + // prints value as string as an ASCII-encoded decimal (base 10). + // Decimal is the default format for Console.print() and Console.println(), + // so no modifier is needed: + Console.print(thisByte); + // But you can declare the modifier for decimal if you want to. + //this also works if you uncomment it: + + // Console.print(thisByte, DEC); + + Console.print(", hex: "); + // prints value as string in hexadecimal (base 16): + Console.print(thisByte, HEX); + + Console.print(", oct: "); + // prints value as string in octal (base 8); + Console.print(thisByte, OCT); + + Console.print(", bin: "); + // prints value as string in binary (base 2) + // also prints ending line break: + Console.println(thisByte, BIN); + + // if printed last visible character '~' or 126, stop: + if(thisByte == 126) { // you could also use if (thisByte == '~') { + // ensure the latest bit of data is sent + Console.flush(); + + // This loop loops forever and does nothing + while(true) { + continue; + } + } + // go on to the next character + thisByte++; +} diff --git a/libraries/Bridge/examples/ConsolePixel/ConsolePixel.ino b/libraries/Bridge/examples/ConsolePixel/ConsolePixel.ino new file mode 100644 index 0000000..c962b6e --- /dev/null +++ b/libraries/Bridge/examples/ConsolePixel/ConsolePixel.ino @@ -0,0 +1,62 @@ +/* + Console Pixel + + An example of using the Arduino board to receive data from the + Console on the Arduino Yun. In this case, the Arduino boards turns on an LED when + it receives the character 'H', and turns off the LED when it + receives the character 'L'. + + To see the Console, pick your Yún's name and IP address in the Port menu + then open the Port Monitor. You can also see it by opening a terminal window + and typing + ssh root@ yourYunsName.local 'telnet localhost 6571' + then pressing enter. When prompted for the password, enter it. + + + The circuit: + * LED connected from digital pin 13 to ground + + created 2006 + by David A. Mellis + modified 25 Jun 2013 + by Tom Igoe + + This example code is in the public domain. + + */ + +#include <Console.h> + +const int ledPin = 13; // the pin that the LED is attached to +char incomingByte; // a variable to read incoming Console data into + +void setup() { + Bridge.begin(); // Initialize Bridge + Console.begin(); // Initialize Console + + // Wait for the Console port to connect + while(!Console); + + Console.println("type H or L to turn pin 13 on or off"); + + // initialize the LED pin as an output: + pinMode(ledPin, OUTPUT); +} + +void loop() { + // see if there's incoming Console data: + if (Console.available() > 0) { + // read the oldest byte in the Console buffer: + incomingByte = Console.read(); + Console.println(incomingByte); + // if it's a capital H (ASCII 72), turn on the LED: + if (incomingByte == 'H') { + digitalWrite(ledPin, HIGH); + } + // if it's an L (ASCII 76) turn off the LED: + if (incomingByte == 'L') { + digitalWrite(ledPin, LOW); + } + } +} + diff --git a/libraries/Bridge/examples/ConsoleRead/ConsoleRead.ino b/libraries/Bridge/examples/ConsoleRead/ConsoleRead.ino new file mode 100644 index 0000000..0019c20 --- /dev/null +++ b/libraries/Bridge/examples/ConsoleRead/ConsoleRead.ino @@ -0,0 +1,56 @@ +/* + Console Read example + + Read data coming from bridge using the Console.read() function + and store it in a string. + + To see the Console, pick your Yún's name and IP address in the Port menu + then open the Port Monitor. You can also see it by opening a terminal window + and typing: + ssh root@ yourYunsName.local 'telnet localhost 6571' + then pressing enter. When prompted for the password, enter it. + + created 13 Jun 2013 + by Angelo Scialabba + modified 16 June 2013 + by Tom Igoe + + This example code is in the public domain. + */ + +#include <Console.h> + +String name; + +void setup() { + // Initialize Console and wait for port to open: + Bridge.begin(); + Console.begin(); + + // Wait for Console port to connect + while (!Console); + + Console.println("Hi, what's your name?"); +} + +void loop() { + if (Console.available() > 0) { + char c = Console.read(); // read the next char received + // look for the newline character, this is the last character in the string + if (c == '\n') { + //print text with the name received + Console.print("Hi "); + Console.print(name); + Console.println("! Nice to meet you!"); + Console.println(); + // Ask again for name and clear the old name + Console.println("Hi, what's your name?"); + name = ""; // clear the name string + } + else { // if the buffer is empty Cosole.read() returns -1 + name += c; // append the read char from Console to the name string + } + } +} + + diff --git a/libraries/Bridge/examples/Datalogger/Datalogger.ino b/libraries/Bridge/examples/Datalogger/Datalogger.ino new file mode 100644 index 0000000..2d792a4 --- /dev/null +++ b/libraries/Bridge/examples/Datalogger/Datalogger.ino @@ -0,0 +1,99 @@ +/* + SD card datalogger + + This example shows how to log data from three analog sensors + to an SD card mounted on the Arduino Yún using the Bridge library. + + The circuit: + * analog sensors on analog pins 0, 1 and 2 + * SD card attached to SD card slot of the Arduino Yún + + Prepare your SD card creating an empty folder in the SD root + named "arduino". This will ensure that the Yún will create a link + to the SD to the "/mnt/sd" path. + + You can remove the SD card while the Linux and the + sketch are running but be careful not to remove it while + the system is writing to it. + + created 24 Nov 2010 + modified 9 Apr 2012 + by Tom Igoe + adapted to the Yún Bridge library 20 Jun 2013 + by Federico Vanzati + modified 21 Jun 2013 + by Tom Igoe + + This example code is in the public domain. + + */ + +#include <FileIO.h> + +void setup() { + // Initialize the Bridge and the Serial + Bridge.begin(); + Serial.begin(9600); + FileSystem.begin(); + + while(!Serial); // wait for Serial port to connect. + Serial.println("Filesystem datalogger\n"); +} + + +void loop () { + // make a string that start with a timestamp for assembling the data to log: + String dataString; + dataString += getTimeStamp(); + dataString += " = "; + + // read three sensors and append to the string: + for (int analogPin = 0; analogPin < 3; analogPin++) { + int sensor = analogRead(analogPin); + dataString += String(sensor); + if (analogPin < 2) { + dataString += ","; // separate the values with a comma + } + } + + // open the file. note that only one file can be open at a time, + // so you have to close this one before opening another. + // The FileSystem card is mounted at the following "/mnt/FileSystema1" + File dataFile = FileSystem.open("/mnt/sd/datalog.txt", FILE_APPEND); + + // if the file is available, write to it: + if (dataFile) { + dataFile.println(dataString); + dataFile.close(); + // print to the serial port too: + Serial.println(dataString); + } + // if the file isn't open, pop up an error: + else { + Serial.println("error opening datalog.txt"); + } + + delay(15000); + +} + +// This function return a string with the time stamp +String getTimeStamp() { + String result; + Process time; + // date is a command line utility to get the date and the time + // in different formats depending on the additional parameter + time.begin("date"); + time.addParameter("+%D-%T"); // parameters: D for the complete date mm/dd/yy + // T for the time hh:mm:ss + time.run(); // run the command + + // read the output of the command + while(time.available()>0) { + char c = time.read(); + if(c != '\n') + result += c; + } + + return result; +} diff --git a/libraries/Bridge/examples/FileWriteScript/FileWriteScript.ino b/libraries/Bridge/examples/FileWriteScript/FileWriteScript.ino new file mode 100644 index 0000000..b550db2 --- /dev/null +++ b/libraries/Bridge/examples/FileWriteScript/FileWriteScript.ino @@ -0,0 +1,82 @@ +/* + Write to file using FileIO classes. + + This sketch demonstrate how to write file into the Yún filesystem. + A shell script file is created in /tmp, and it is executed afterwards. + + created 7 June 2010 + by Cristian Maglie + + This example code is in the public domain. + + */ + +#include <FileIO.h> + +void setup() { + // Setup Bridge (needed every time we communicate with the Arduino Yún) + Bridge.begin(); + // Initialize the Serial + Serial.begin(9600); + + while(!Serial); // wait for Serial port to connect. + Serial.println("File Write Script example\n\n"); + + // Setup File IO + FileSystem.begin(); + + // Upload script used to gain network statistics + uploadScript(); +} + +void loop() { + // Run stats script every 5 secs. + runScript(); + delay(5000); +} + +// this function creates a file into the linux processor that contains a shell script +// to check the network traffic of the WiFi interface +void uploadScript() { + // Write our shell script in /tmp + // Using /tmp stores the script in RAM this way we can preserve + // the limited amount of FLASH erase/write cycles + File script = FileSystem.open("/tmp/wlan-stats.sh", FILE_WRITE); + // Shell script header + script.print("#!/bin/sh\n"); + // shell commands: + // ifconfig: is a command line utility for controlling the network interfaces. + // wlan0 is the interface we want to query + // grep: search inside the output of the ifconfig command the "RX bytes" keyword + // and extract the line that contains it + script.print("ifconfig wlan0 | grep 'RX bytes'\n"); + script.close(); // close the file + + // Make the script executable + Process chmod; + chmod.begin("chmod"); // chmod: change mode + chmod.addParameter("+x"); // x stays for executable + chmod.addParameter("/tmp/wlan-stats.sh"); // path to the file to make it executable + chmod.run(); +} + + +// this function run the script and read the output data +void runScript() { + // Run the script and show results on the Serial + Process myscript; + myscript.begin("/tmp/wlan-stats.sh"); + myscript.run(); + + String output = ""; + + // read the output of the script + while (myscript.available()) { + output += (char)myscript.read(); + } + // remove the blank spaces at the beginning and the ending of the string + output.trim(); + Serial.println(output); + Serial.flush(); +} + diff --git a/libraries/Bridge/examples/HttpClient/HttpClient.ino b/libraries/Bridge/examples/HttpClient/HttpClient.ino new file mode 100644 index 0000000..4104ef4 --- /dev/null +++ b/libraries/Bridge/examples/HttpClient/HttpClient.ino @@ -0,0 +1,26 @@ + +#include <Bridge.h> +#include <HttpClient.h> + +void setup() { + pinMode(13, OUTPUT); + digitalWrite(13, LOW); + Bridge.begin(); + Serial.begin(9600); + while(!Serial); +} + +void loop() { + HttpClient client; + client.get("http://arduino.cc/asciilogo.txt"); + + while (client.available()) { + char c = client.read(); + Serial.print(c); + } + Serial.flush(); + + delay(5000); +} + + diff --git a/libraries/Bridge/examples/Process/Process.ino b/libraries/Bridge/examples/Process/Process.ino new file mode 100644 index 0000000..7646d15 --- /dev/null +++ b/libraries/Bridge/examples/Process/Process.ino @@ -0,0 +1,70 @@ +/* + Running process using Process class. + + This sketch demonstrate how to run linux processes + using an Arduino Yún. + + created 5 Jun 2013 + by Cristian Maglie + + This example code is in the public domain. + + */ + +#include <Process.h> + +void setup() { + // Initialize Bridge + Bridge.begin(); + + // Initialize Serial + Serial.begin(9600); + + // Wait until a Serial Monitor is connected. + while (!Serial); + + // run various example processes + runCurl(); + runCpuInfo(); +} + +void loop() { + // Do nothing here. +} + +void runCurl() { + // Launch "curl" command and get Arduino ascii art logo from the network + // curl is command line program for transferring data using different internet protocols + Process p; // Create a process and call it "p" + p.begin("curl"); // Process that launch the "curl" command + p.addParameter("http://arduino.cc/asciilogo.txt"); // Add the URL parameter to "curl" + p.run(); // Run the process and wait for its termination + + // Print arduino logo over the Serial + // A process output can be read with the stream methods + while (p.available()>0) { + char c = p.read(); + Serial.print(c); + } + // Ensure the last bit of data is sent. + Serial.flush(); +} + +void runCpuInfo() { + // Launch "cat /proc/cpuinfo" command (shows info on Atheros CPU) + // cat is a command line utility that shows the content of a file + Process p; // Create a process and call it "p" + p.begin("cat"); // Process that launch the "cat" command + p.addParameter("/proc/cpuinfo"); // Add the cpuifo file path as parameter to cut + p.run(); // Run the process and wait for its termination + + // Print command output on the Serial. + // A process output can be read with the stream methods + while (p.available()>0) { + char c = p.read(); + Serial.print(c); + } + // Ensure the last bit of data is sent. + Serial.flush(); +} + diff --git a/libraries/Bridge/examples/ShellCommands/ShellCommands.ino b/libraries/Bridge/examples/ShellCommands/ShellCommands.ino new file mode 100644 index 0000000..5a4c291 --- /dev/null +++ b/libraries/Bridge/examples/ShellCommands/ShellCommands.ino @@ -0,0 +1,53 @@ +/* + Running shell commands using Process class. + + This sketch demonstrate how to run linux shell commands + using an Arduino Yún. It runs the wifiCheck script on the linino side + of the Yun, then uses grep to get just the signal strength line. + Then it uses parseInt() to read the wifi signal strength as an integer, + and finally uses that number to fade an LED using analogWrite(). + + The circuit: + * Arduino Yun with LED connected to pin 9 + + created 12 Jun 2013 + by Cristian Maglie + modified 25 June 2013 + by Tom Igoe + + This example code is in the public domain. + + */ + +#include <Process.h> + +void setup() { + Bridge.begin(); // Initialize the Bridge + Serial.begin(9600); // Initialize the Serial + + // Wait until a Serial Monitor is connected. + while(!Serial); +} + +void loop() { + Process p; + // This command line runs the WifiStatus script, (/usr/bin/pretty-wifi-info.lua), then + // sends the result to the grep command to look for a line containing the word + // "Signal:" the result is passed to this sketch: + p.runShellCommand("/usr/bin/pretty-wifi-info.lua | grep Signal"); + + // do nothing until the process finishes, so you get the whole output: + while(p.running()); + + // Read command output. runShellCommand() should have passed "Signal: xx&": + while (p.available()) { + int result = p.parseInt(); // look for an integer + int signal = map(result, 0, 100, 0, 255); // map result from 0-100 range to 0-255 + analogWrite(9, signal); // set the brightness of LED on pin 9 + Serial.println(result); // print the number as well + } + delay(5000); // wait 5 seconds before you do it again +} + + + diff --git a/libraries/Bridge/examples/SpacebrewYun/inputOutput/inputOutput.ino b/libraries/Bridge/examples/SpacebrewYun/inputOutput/inputOutput.ino new file mode 100644 index 0000000..be22850 --- /dev/null +++ b/libraries/Bridge/examples/SpacebrewYun/inputOutput/inputOutput.ino @@ -0,0 +1,130 @@ +/* + Input Output + + Demonstrates how to create a sketch that sends and receives all standard + spacebrew data types, and a custom data type. Every time data is + received it is output to the Serial monitor. + + Make sure that your Yun is connected to the internet for this example + to function properly. + + The circuit: + - No circuit required + + created 2013 + by Julio Terra + + This example code is in the public domain. + + More information about Spacebrew is available at: + http://spacebrew.cc/ + + */ + +#include <Bridge.h> +#include <SpacebrewYun.h> + +// create a variable of type SpacebrewYun and initialize it with the constructor +SpacebrewYun sb = SpacebrewYun("aYun", "Arduino Yun spacebrew test"); + +// create variables to manage interval between each time we send a string +long last = 0; +int interval = 2000; + +int counter = 0; + +void setup() { + + // start the serial port + Serial.begin(57600); + + // for debugging, wait until a serial console is connected + delay(4000); + while (!Serial) { ; } + + // start-up the bridge + Bridge.begin(); + + // configure the spacebrew object to print status messages to serial + sb.verbose(true); + + // configure the spacebrew publisher and subscriber + sb.addPublish("string test", "string"); + sb.addPublish("range test", "range"); + sb.addPublish("boolean test", "boolean"); + sb.addPublish("custom test", "crazy"); + sb.addSubscribe("string test", "string"); + sb.addSubscribe("range test", "range"); + sb.addSubscribe("boolean test", "boolean"); + sb.addSubscribe("custom test", "crazy"); + + // register the string message handler method + sb.onRangeMessage(handleRange); + sb.onStringMessage(handleString); + sb.onBooleanMessage(handleBoolean); + sb.onCustomMessage(handleCustom); + + // connect to cloud spacebrew server at "sandbox.spacebrew.cc" + sb.connect("sandbox.spacebrew.cc"); + +} + + +void loop() { + // monitor spacebrew connection for new data + sb.monitor(); + + // connected to spacebrew then send a string every 2 seconds + if ( sb.connected() ) { + + // check if it is time to send a new message + if ( (millis() - last) > interval ) { + String test_str_msg = "testing, testing, "; + test_str_msg += counter; + counter ++; + + sb.send("string test", test_str_msg); + sb.send("range test", 500); + sb.send("boolean test", true); + sb.send("custom test", "youre loco"); + + last = millis(); + + } + } +} + +// define handler methods, all standard data type handlers take two appropriate arguments + +void handleRange (String route, int value) { + Serial.print("Range msg "); + Serial.print(route); + Serial.print(", value "); + Serial.println(value); +} + +void handleString (String route, String value) { + Serial.print("String msg "); + Serial.print(route); + Serial.print(", value "); + Serial.println(value); +} + +void handleBoolean (String route, boolean value) { + Serial.print("Boolen msg "); + Serial.print(route); + Serial.print(", value "); + Serial.println(value ? "true" : "false"); +} + +// custom data type handlers takes three String arguments + +void handleCustom (String route, String value, String type) { + Serial.print("Custom msg "); + Serial.print(route); + Serial.print(" of type "); + Serial.print(type); + Serial.print(", value "); + Serial.println(value); +} + diff --git a/libraries/Bridge/examples/SpacebrewYun/spacebrewBoolean/spacebrewBoolean.ino b/libraries/Bridge/examples/SpacebrewYun/spacebrewBoolean/spacebrewBoolean.ino new file mode 100644 index 0000000..0f068aa --- /dev/null +++ b/libraries/Bridge/examples/SpacebrewYun/spacebrewBoolean/spacebrewBoolean.ino @@ -0,0 +1,89 @@ +/* + Spacebrew Boolean + + Demonstrates how to create a sketch that sends and receives a + boolean value to and from Spacebrew. Every time the buttton is + pressed (or other digital input component) a spacebrew message + is sent. The sketch also accepts analog range messages from + other Spacebrew apps. + + Make sure that your Yun is connected to the internet for this example + to function properly. + + The circuit: + - Button connected to Yun, using the Arduino's internal pullup resistor. + + created 2013 + by Julio Terra + + This example code is in the public domain. + + More information about Spacebrew is available at: + http://spacebrew.cc/ + + */ + +#include <Bridge.h> +#include <SpacebrewYun.h> + +// create a variable of type SpacebrewYun and initialize it with the constructor +SpacebrewYun sb = SpacebrewYun("spacebrewYun Boolean", "Boolean sender and receiver"); + +// variable that holds the last potentiometer value +int last_value = 0; + +// create variables to manage interval between each time we send a string +void setup() { + + // start the serial port + Serial.begin(57600); + + // for debugging, wait until a serial console is connected + delay(4000); + while (!Serial) { ; } + + // start-up the bridge + Bridge.begin(); + + // configure the spacebrew object to print status messages to serial + sb.verbose(true); + + // configure the spacebrew publisher and subscriber + sb.addPublish("physical button", "boolean"); + sb.addSubscribe("virtual button", "boolean"); + + // register the string message handler method + sb.onBooleanMessage(handleBoolean); + + // connect to cloud spacebrew server at "sandbox.spacebrew.cc" + sb.connect("sandbox.spacebrew.cc"); + + pinMode(3, INPUT); + digitalWrite(3, HIGH); +} + + +void loop() { + // monitor spacebrew connection for new data + sb.monitor(); + + // connected to spacebrew then send a new value whenever the pot value changes + if ( sb.connected() ) { + int cur_value = digitalRead(3); + if ( last_value != cur_value ) { + if (cur_value == HIGH) sb.send("physical button", false); + else sb.send("physical button", true); + last_value = cur_value; + } + } +} + +// handler method that is called whenever a new string message is received +void handleBoolean (String route, boolean value) { + // print the message that was received + Serial.print("From "); + Serial.print(route); + Serial.print(", received msg: "); + Serial.println(value ? "true" : "false"); +} + diff --git a/libraries/Bridge/examples/SpacebrewYun/spacebrewRange/spacebrewRange.ino b/libraries/Bridge/examples/SpacebrewYun/spacebrewRange/spacebrewRange.ino new file mode 100644 index 0000000..6dcbff8 --- /dev/null +++ b/libraries/Bridge/examples/SpacebrewYun/spacebrewRange/spacebrewRange.ino @@ -0,0 +1,86 @@ +/* + Spacebrew Range + + Demonstrates how to create a sketch that sends and receives analog + range value to and from Spacebrew. Every time the state of the + potentiometer (or other analog input component) change a spacebrew + message is sent. The sketch also accepts analog range messages from + other Spacebrew apps. + + Make sure that your Yun is connected to the internet for this example + to function properly. + + The circuit: + - Potentiometer connected to Yun. Middle pin connected to analog pin A0, + other pins connected to 5v and GND pins. + + created 2013 + by Julio Terra + + This example code is in the public domain. + + More information about Spacebrew is available at: + http://spacebrew.cc/ + + */ + +#include <Bridge.h> +#include <SpacebrewYun.h> + +// create a variable of type SpacebrewYun and initialize it with the constructor +SpacebrewYun sb = SpacebrewYun("spacebrewYun Range", "Range sender and receiver"); + +// variable that holds the last potentiometer value +int last_value = 0; + +// create variables to manage interval between each time we send a string +void setup() { + + // start the serial port + Serial.begin(57600); + + // for debugging, wait until a serial console is connected + delay(4000); + while (!Serial) { ; } + + // start-up the bridge + Bridge.begin(); + + // configure the spacebrew object to print status messages to serial + sb.verbose(true); + + // configure the spacebrew publisher and subscriber + sb.addPublish("physical pot", "range"); + sb.addSubscribe("virtual pot", "range"); + + // register the string message handler method + sb.onRangeMessage(handleRange); + + // connect to cloud spacebrew server at "sandbox.spacebrew.cc" + sb.connect("sandbox.spacebrew.cc"); +} + + +void loop() { + // monitor spacebrew connection for new data + sb.monitor(); + + // connected to spacebrew then send a new value whenever the pot value changes + if ( sb.connected() ) { + int cur_value = analogRead(A0); + if ( last_value != cur_value ) { + sb.send("physical pot", cur_value); + last_value = cur_value; + } + } +} + +// handler method that is called whenever a new string message is received +void handleRange (String route, int value) { + // print the message that was received + Serial.print("From "); + Serial.print(route); + Serial.print(", received msg: "); + Serial.println(value); +} + diff --git a/libraries/Bridge/examples/SpacebrewYun/spacebrewString/spacebrewString.ino b/libraries/Bridge/examples/SpacebrewYun/spacebrewString/spacebrewString.ino new file mode 100644 index 0000000..8c8f1c7 --- /dev/null +++ b/libraries/Bridge/examples/SpacebrewYun/spacebrewString/spacebrewString.ino @@ -0,0 +1,84 @@ +/* + Spacebrew String + + Demonstrates how to create a sketch that sends and receives strings + to and from Spacebrew. Every time string data is received it + is output to the Serial monitor. + + Make sure that your Yun is connected to the internet for this example + to function properly. + + The circuit: + - No circuit required + + created 2013 + by Julio Terra + + This example code is in the public domain. + + More information about Spacebrew is available at: + http://spacebrew.cc/ + + */ + +#include <Bridge.h> +#include <SpacebrewYun.h> + +// create a variable of type SpacebrewYun and initialize it with the constructor +SpacebrewYun sb = SpacebrewYun("spacebrewYun Strings", "String sender and receiver"); + +// create variables to manage interval between each time we send a string +long last_time = 0; +int interval = 2000; + +void setup() { + + // start the serial port + Serial.begin(57600); + + // for debugging, wait until a serial console is connected + delay(4000); + while (!Serial) { ; } + + // start-up the bridge + Bridge.begin(); + + // configure the spacebrew object to print status messages to serial + sb.verbose(true); + + // configure the spacebrew publisher and subscriber + sb.addPublish("speak", "string"); + sb.addSubscribe("listen", "string"); + + // register the string message handler method + sb.onStringMessage(handleString); + + // connect to cloud spacebrew server at "sandbox.spacebrew.cc" + sb.connect("sandbox.spacebrew.cc"); +} + + +void loop() { + // monitor spacebrew connection for new data + sb.monitor(); + + // connected to spacebrew then send a string every 2 seconds + if ( sb.connected() ) { + + // check if it is time to send a new message + if ( (millis() - last_time) > interval ) { + sb.send("speak", "is anybody out there?"); + last_time = millis(); + } + } +} + +// handler method that is called whenever a new string message is received +void handleString (String route, String value) { + // print the message that was received + Serial.print("From "); + Serial.print(route); + Serial.print(", received msg: "); + Serial.println(value); +} + diff --git a/libraries/Bridge/examples/Temboo/ControlBySMS/ControlBySMS.ino b/libraries/Bridge/examples/Temboo/ControlBySMS/ControlBySMS.ino new file mode 100644 index 0000000..6543935 --- /dev/null +++ b/libraries/Bridge/examples/Temboo/ControlBySMS/ControlBySMS.ino @@ -0,0 +1,443 @@ +/* + ControlBySMS + + Demonstrates using an SMS message to a Twilio account to turn an LED + on the Yun board on and off using the Temboo Arduino Yun SDK. + Sending a SMS with the text "LED ON" to your Twilio phone number + will turn on the LED on the Yun. Sending "LED OFF" will turn it off. + + Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino + + A Temboo account and application key are necessary to run all Temboo examples. + If you don't already have one, you can register for a free Temboo account at + http://www.temboo.com + + Since this sketch uses Twilio to retrieve the SMS, you'll also need a valid + Twilio account. You can create one for free at https://www.twilio.com. + + The sketch needs your Twilio Account SID and Auth Token you get when you + register with Twilio. Make sure to use the Account SID and Auth Token from + your Twilio Dashboard (not your test credentials from the Dev Tools panel). + + Normally, Twilio expects to contact a web site you provide to get a response + when an SMS message is received for your Twilio number. In this case, we + don't want to send any response (and we don't want to have to set up a web + site just to receive SMS messages.) You can use a URL that Twilio provides + for this purpose. When a message is received and sent to the Twilio "twimlets" + URL, it returns a code meaning "no response required." To set this up: + + 1. Log in to your Twilio account and go to this URL: + + https://www.twilio.com/user/account/phone-numbers/incoming + + 2. Select the Twilio number you want to receive SMS messages at. + + 3. Put this URL in the "SMS Request URL" field: + + http://twimlets.com/echo?Twiml=%3CResponse%3E%3C%2FResponse%3E + + See this link to Twilio's FAQ for details: + + https://www.twilio.com/help/faq/sms/how-can-i-receive-sms-messages-without-responding + + 4. Click the "Save Changes" button at the bottom of the page. + + Your account will now receive SMS messages, but won't send any responses. + + This example assumes basic familiarity with Arduino sketches, and that your Yun is connected + to the Internet. + + Looking for another API? We've got over 100 in our Library! + + This example code is in the public domain. +*/ + +#include <Bridge.h> +#include <Temboo.h> +#include "TembooAccount.h" // contains Temboo account information + // as described in the footer comment below + + + +/*** SUBSTITUTE YOUR VALUES BELOW: ***/ + +// Note that for additional security and reusability, you could +// use #define statements to specify these values in a .h file. + +// the Account SID from your Twilio account +const String TWILIO_ACCOUNT_SID = "xxxxxxxxxxxxxxxxxx"; + +// the Auth Token from your Twilio account +const String TWILIO_AUTH_TOKEN = "xxxxxxxxxxxxxxxxx"; + +// only act on messages sent from this phone number. (e.g. 15415551212) +const String FROM_PHONE_NUMBER = "xxxxxxxxxxx"; + +// how often (in milliseconds) to check for new SMS messages. +const unsigned long SMS_CHECK_PERIOD = 60000; + +// keep track of when we last checked for new messages +// (initialize it to SMS_CHECK_PERIOD seconds ago so +// we do the first check as soon as the sketch starts.) +unsigned long lastSMSCheckTime = -SMS_CHECK_PERIOD; + +// keep track of the ID of the last SMS message we processed. +// (we only need to process newer messages) +String lastSid; + +// we'll be turning the LED built in to the Yun on and off +// to simulate controlling some device. That LED is on pin 13. +int LED_PIN = 13; + +int numRuns = 1; // execution count, so this doesn't run forever +int maxRuns = 10; // the max number of times the Twitter HomeTimeline Choreo should run + + +void setup() { + Serial.begin(9600); + + // for debugging, wait until a serial console is connected + delay(4000); + while(!Serial); + + // tell the board to treat the LED pin as an output. + pinMode(LED_PIN, OUTPUT); + + // start with the LED off + digitalWrite(LED_PIN, LOW); + + // initialize the connection to the Linino processor. + Bridge.begin(); + + // Twilio will report old SMS messages. We want to + // ignore any existing control messages when we start. + Serial.println("Ignoring any existing control messages..."); + checkForMessages(true); + +} + +void loop() +{ + + // get the number of milliseconds the CPU has been running. + unsigned long now = millis(); + + // see if it's time to check for new SMS messages. + if (now - lastSMSCheckTime >= SMS_CHECK_PERIOD) { + + // it's time to check for new messages + // save this time so we know when to check next + lastSMSCheckTime = now; + + if (numRuns <= maxRuns) { + Serial.println("Checking for new SMS messages - Run #" + String(numRuns++)); + + // execute the choreo and don't ignore control messages. + checkForMessages(false); + } else { + Serial.println("Already ran " + String(maxRuns) + " times."); + } + } +} + +/* +This function executes the Twilio > SMSMessages > ListMessages choreo +and processes the results. + +If ignoreCommands is 'true', this function will read and process messages +updating 'lastSid', but will not actually take any action on any commands +found. This is so we can ignore any old control messages when we start. + +If ignoreCommands is 'false', control messages WILL be acted on. +*/ +void checkForMessages(bool ignoreCommands) { + + // we need a TembooChoreo object to send a Choreo request to Temboo + TembooChoreo ListMessagesChoreo; + + ListMessagesChoreo.begin(); + + // set Temboo account credentials + ListMessagesChoreo.setAccountName(TEMBOO_ACCOUNT); + ListMessagesChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); + ListMessagesChoreo.setAppKey(TEMBOO_APP_KEY); + + // identify the Temboo Library choreo to run (Twilio > SMSMessages > ListMessages) + ListMessagesChoreo.setChoreo("/Library/Twilio/SMSMessages/ListMessages"); + + // set the choreo inputs + // see https://www.temboo.com/library/Library/Twilio/SMSMessages/ListMessages/ + // for complete details about the inputs for this Choreo + + // the first input is a your Twilio AccountSID + ListMessagesChoreo.addInput("AccountSID", TWILIO_ACCOUNT_SID); + + // next is your Twilio Auth Token + ListMessagesChoreo.addInput("AuthToken", TWILIO_AUTH_TOKEN); + + // we only want to know about messages sent from our designated phone number + ListMessagesChoreo.addInput("From", FROM_PHONE_NUMBER); + + // Twilio can return information about up to 1000 messages at a time. + // we're only interested in the 3 most recent ones. Note that if + // this account receives lots of messages in quick succession, + // (more than 3 per minute in this case), we might miss some control + // messages. But if we request too many messages, we might run out of + // memory on the Arduino side of the Yun. + ListMessagesChoreo.addInput("PageSize", "3"); + + // We want the response in XML format to process with our + // XPath output filters. + ListMessagesChoreo.addInput("ResponseFormat", "xml"); + + // we don't want everything from the output, just the + // message IDs (the Sids) and the message texts + ListMessagesChoreo.addOutputFilter("sid", "Sid", "Response"); + ListMessagesChoreo.addOutputFilter("text", "Body", "Response"); + + // tell the Choreo to run and wait for the results. The + // return code (returnCode) will tell us whether the Temboo client + // was able to send our request to the Temboo servers + unsigned int returnCode = ListMessagesChoreo.run(); + + // a return code of zero (0) means success + if (returnCode == 0) { + + // Need a string to hold the list of message IDs. + String messageSids; + + // Need a string to hold the texts of the messages. + String messageTexts; + + // when the choreo results are available, process them. + // the output filters we specified will return comma delimited + // lists containing the Sids and texts of the messages + // from our designated phone number. + + while(ListMessagesChoreo.available()) { + + // output names are terminated with '\x1F' characters. + String name = ListMessagesChoreo.readStringUntil('\x1F'); + name.trim(); + //Serial.println(name); + + // output values are terminated with '\x1E' characters. + String data = ListMessagesChoreo.readStringUntil('\x1E'); + data.trim(); + //Serial.println(data); + + // assign the data to the appropriate string based on the name + if (name == "sid") { + messageSids = data; + } else if (name == "text") { + messageTexts = data; + } + } + + // done reading output, close the Choreo to free up resources. + ListMessagesChoreo.close(); + + // parse the comma delimited lists of messages and Sids + processMessages(messageTexts, messageSids, ignoreCommands); + + } else { + // a non-zero return code means there was an error + // read and print the error message + while(ListMessagesChoreo.available()) { + char c = ListMessagesChoreo.read(); + Serial.print(c); + } + } +} + +/* +This function processes the lists of message texts and Sids. +If a message contains a comma as part of the +message text, that message will be enclosed in double quotes +(") in the list. Example: + + A message,"Hey, now",Another message text + +If the message contains double quotes, it will be enclosed in +double quotes AND the internal quotes will be doubled. +Example: + + "Hi ""Sam"" the man", Led on + +NOTE! We are assuming that Twilio returns more recent messages +first. This isn't officially documented by Twilio, but we've +not seen any other case. + +'messageTexts' is a String containing a comma separated list of +message texts with commas and quotes escaped as described above. + +'messageSids' is a String containing a comma separated list of +message Sids. Sids should not contain embedded commas or quotes. + +'ignoreCommands' is a boolean. 'true' means and control messages +will not be acted upon. 'false' means control messages will be +acted upon in the usual way. +*/ +void processMessages(String messageTexts, String messageSids, bool ignoreCommands) { + + // proceed if we received at least one message + if (messageSids.length() > 0) { + int i = -1; + int sidsStart = 0; + int textsStart = 0; + String sid; + String text; + bool ledUpdated = false; + + // go through the list until we run out of items + // or otherwise know we can stop + do { + + // Output filter list items are separated by commas + // find the start of the next item in the list + i = messageSids.indexOf(',', sidsStart); + if (i >= 0) { + + //extract a single Sid from the list. + sid = messageSids.substring(sidsStart, i); + sidsStart = i + 1; + + // find the start of the next text in the list. + // Note that we have to be prepared to handle embedded + // quotes and commans in the message texts. + // The standard Arduino String class doesn't handle + // this, so we have to write our own function to do it. + i = quotedIndexOf(messageTexts, ',', textsStart); + if (i >= 0) { + + // extract a single message text from the list. + text = messageTexts.substring(textsStart, i); + textsStart = i + 1; + + // process the Sid and text to see if it's a + // control message. + ledUpdated = processMessage(sid, text, ignoreCommands); + } + } else { + + // the last item in the lists won't have a comma at the end, + // so we have to handle them specially. + // Since we know this is the last item, we can just + // take the rest of the string for the Sid and text. + sid = messageSids.substring(sidsStart); + text = messageTexts.substring(textsStart); + + // process the last item. + ledUpdated = processMessage(sid, text, ignoreCommands); + } + + // keep going until either we run out of list items + // or we run into a message we processed on a previous run. + } while ((i >=0) && (sid != lastSid)); + + // print what we've found to the serial monitor, + // just so we can see what's going on. + if (sid == lastSid) { + if (ledUpdated) + Serial.println("Control message processed."); + else + Serial.println("No new control messages received."); + } else { + Serial.println("No control messages received."); + } + } else { + Serial.println("No messages found"); + } +} + +/* +This function knows how to tell if a message is a control message +or not. It also knows know to control whatever it is we're controlling +(the state of the LED on pin 13 in this case.) + +A message with the text "LED ON" turns the LED on. +A message with the text "LED OFF" turns the LED off. +(Case is ignored.) + +If 'ignoreCommands' is true, the actions described above will NOT +take place. + +It also updates the 'lastSid' global variable when +a control message is processed. + +It returns 'true' if the message was a control message, and +'false' if it wasn't or if we've already processed this message. +*/ +bool processMessage(String sid, String text, bool ignoreCommands) { + + // a flag to indicate whether this was a control message or not + bool ledUpdated = false; + + // if we haven't already processed this message + if (sid != lastSid) { + + if (text.equalsIgnoreCase("LED ON")) { + + if (!ignoreCommands) { + //turn on the LED + digitalWrite(LED_PIN, HIGH); + Serial.println("LED ON"); + } + ledUpdated = true; + } else if (text.equalsIgnoreCase("LED OFF")) { + if (!ignoreCommands) { + //turn off the LED + digitalWrite(LED_PIN, LOW); + Serial.println("LED OFF"); + } + ledUpdated = true; + } + + // If the LED state was updated, remember the Sid if this message. + if (ledUpdated) + lastSid = sid; + } + return ledUpdated; +} + +/* +This function finds the index of a delimiter character in a String, +ignoring delimiters that appear inside double-quotes. +*/ +int quotedIndexOf(String s, char delim, int start) { + bool inQuotes = false; + char c; + int index = -1; + const char QUOTE = '"'; + do { + c = s[start++]; + if (c == QUOTE) + inQuotes = !inQuotes; + else if (c == delim && !inQuotes) + index = --start; + } while ((c != '\0') && (index < 0)); + return index; +} + + +/* + IMPORTANT NOTE: TembooAccount.h: + + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: + + #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name + #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name + #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + You can find your Temboo App Key information on the Temboo website, + under My Account > Application Keys + + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + + Keeping your account information in a separate file means you can save it once, + then just distribute the main .ino file without worrying that you forgot to delete your credentials. +*/ + diff --git a/libraries/Bridge/examples/Temboo/ControlBySMS/TembooAccount.h b/libraries/Bridge/examples/Temboo/ControlBySMS/TembooAccount.h new file mode 100644 index 0000000..8d7dcfb --- /dev/null +++ b/libraries/Bridge/examples/Temboo/ControlBySMS/TembooAccount.h @@ -0,0 +1,5 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + diff --git a/libraries/Bridge/examples/Temboo/GetYahooWeatherReport/GetYahooWeatherReport.ino b/libraries/Bridge/examples/Temboo/GetYahooWeatherReport/GetYahooWeatherReport.ino new file mode 100644 index 0000000..669aba5 --- /dev/null +++ b/libraries/Bridge/examples/Temboo/GetYahooWeatherReport/GetYahooWeatherReport.ino @@ -0,0 +1,115 @@ +/* + GetYahooWeatherReport + + Demonstrates making a request to the Yahoo! Weather API using Temboo from an Arduino Yun. + + Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino + + A Temboo account and application key are necessary to run all Temboo examples. + If you don't already have one, you can register for a free Temboo account at + http://www.temboo.com + + This example assumes basic familiarity with Arduino sketches, and that your Yun is connected + to the Internet. + + Looking for another API to use with your Arduino Yun? We've got over 100 in our Library! + + This example code is in the public domain. +*/ + +#include <Bridge.h> +#include <Temboo.h> +#include "TembooAccount.h" // contains Temboo account information + // as described in the footer comment below + + +// the address for which a weather forecast will be retrieved +String ADDRESS_FOR_FORECAST = "104 Franklin St., New York NY 10013"; + +int numRuns = 1; // execution count, so that this doesn't run forever +int maxRuns = 10; // max number of times the Yahoo WeatherByAddress Choreo should be run + + +void setup() { + Serial.begin(9600); + + // for debugging, wait until a serial console is connected + delay(4000); + while(!Serial); + Bridge.begin(); + +} + +void loop() +{ + // while we haven't reached the max number of runs... + if (numRuns <= maxRuns) { + + // print status + Serial.println("Running GetWeatherByAddress - Run #" + String(numRuns++) + "..."); + + // create a TembooChoreo object to send a Choreo request to Temboo + TembooChoreo GetWeatherByAddressChoreo; + + // invoke the Temboo client + GetWeatherByAddressChoreo.begin(); + + // add your temboo account info + GetWeatherByAddressChoreo.setAccountName(TEMBOO_ACCOUNT); + GetWeatherByAddressChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); + GetWeatherByAddressChoreo.setAppKey(TEMBOO_APP_KEY); + + // set the name of the choreo we want to run + GetWeatherByAddressChoreo.setChoreo("/Library/Yahoo/Weather/GetWeatherByAddress"); + + // set choreo inputs; in this case, the address for which to retrieve weather data + // the Temboo client provides standardized calls to 100+ cloud APIs + GetWeatherByAddressChoreo.addInput("Address", ADDRESS_FOR_FORECAST); + + // add an output filter to extract the name of the city. + GetWeatherByAddressChoreo.addOutputFilter("city", "/rss/channel/yweather:location/@city", "Response"); + + // add an output filter to extract the current temperature + GetWeatherByAddressChoreo.addOutputFilter("temperature", "/rss/channel/item/yweather:condition/@temp", "Response"); + + // add an output filter to extract the date and time of the last report. + GetWeatherByAddressChoreo.addOutputFilter("date", "/rss/channel/item/yweather:condition/@date", "Response"); + + // run the choreo + GetWeatherByAddressChoreo.run(); + + // when the choreo results are available, print them to the serial monitor + while(GetWeatherByAddressChoreo.available()) { + + char c = GetWeatherByAddressChoreo.read(); + Serial.print(c); + } + GetWeatherByAddressChoreo.close(); + + } + + Serial.println("Waiting..."); + Serial.println(""); + delay(30000); // wait 30 seconds between GetWeatherByAddress calls +} + +/* + IMPORTANT NOTE: TembooAccount.h: + + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: + + #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name + #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name + #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + You can find your Temboo App Key information on the Temboo website, + under My Account > Application Keys + + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + + Keeping your account information in a separate file means you can share the main .ino file without worrying + that you forgot to delete your credentials. +*/ diff --git a/libraries/Bridge/examples/Temboo/GetYahooWeatherReport/TembooAccount.h b/libraries/Bridge/examples/Temboo/GetYahooWeatherReport/TembooAccount.h new file mode 100644 index 0000000..c58b447 --- /dev/null +++ b/libraries/Bridge/examples/Temboo/GetYahooWeatherReport/TembooAccount.h @@ -0,0 +1,4 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + diff --git a/libraries/Bridge/examples/Temboo/ReadATweet/ReadATweet.ino b/libraries/Bridge/examples/Temboo/ReadATweet/ReadATweet.ino new file mode 100644 index 0000000..b2edd1f --- /dev/null +++ b/libraries/Bridge/examples/Temboo/ReadATweet/ReadATweet.ino @@ -0,0 +1,173 @@ +/* + ReadATweet + + Demonstrates retrieving the most recent Tweet from a user's home timeline + using Temboo from an Arduino Yun. + + Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino + + A Temboo account and application key are necessary to run all Temboo examples. + If you don't already have one, you can register for a free Temboo account at + http://www.temboo.com + + In order to run this sketch, you'll need to register an application using + the Twitter dev console at https://dev.twitter.com. After creating the + app, you'll find OAuth credentials for that application under the "OAuth Tool" tab. + Substitute these values for the placeholders below. + + This example assumes basic familiarity with Arduino sketches, and that your Yun + is connected to the Internet. + + Want to use another social API with your Arduino Yun? We've got Facebook, + Google+, Instagram, Tumblr and more in our Library! + + This example code is in the public domain. +*/ + +#include <Bridge.h> +#include <Temboo.h> +#include "TembooAccount.h" // contains Temboo account information + // as described in the footer comment below + +/*** SUBSTITUTE YOUR VALUES BELOW: ***/ + +// Note that for additional security and reusability, you could +// use #define statements to specify these values in a .h file. +const String TWITTER_ACCESS_TOKEN = "your-twitter-access-token"; +const String TWITTER_ACCESS_TOKEN_SECRET = "your-twitter-access-token-secret"; +const String TWITTER_CONSUMER_KEY = "your-twitter-consumer-key"; +const String TWITTER_CONSUMER_SECRET = "your-twitter-consumer-secret"; + +int numRuns = 1; // execution count, so this doesn't run forever +int maxRuns = 10; // the max number of times the Twitter HomeTimeline Choreo should run + +void setup() { + Serial.begin(9600); + + // For debugging, wait until a serial console is connected. + delay(4000); + while(!Serial); + Bridge.begin(); +} +void loop() +{ + // while we haven't reached the max number of runs... + if (numRuns <= maxRuns) { + Serial.println("Running ReadATweet - Run #" + String(numRuns++)); + + TembooChoreo HomeTimelineChoreo; + + // invoke the Temboo client. + // NOTE that the client must be reinvoked, and repopulated with + // appropriate arguments, each time its run() method is called. + HomeTimelineChoreo.begin(); + + // set Temboo account credentials + HomeTimelineChoreo.setAccountName(TEMBOO_ACCOUNT); + HomeTimelineChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); + HomeTimelineChoreo.setAppKey(TEMBOO_APP_KEY); + + // tell the Temboo client which Choreo to run (Twitter > Timelines > HomeTimeline) + HomeTimelineChoreo.setChoreo("/Library/Twitter/Timelines/HomeTimeline"); + + + // set the required choreo inputs + // see https://www.temboo.com/library/Library/Twitter/Timelines/HomeTimeline/ + // for complete details about the inputs for this Choreo + + HomeTimelineChoreo.addInput("Count", "1"); // the max number of Tweets to return from each request + HomeTimelineChoreo.addInput("AccessToken", TWITTER_ACCESS_TOKEN); + HomeTimelineChoreo.addInput("AccessTokenSecret", TWITTER_ACCESS_TOKEN_SECRET); + HomeTimelineChoreo.addInput("ConsumerKey", TWITTER_CONSUMER_KEY); + HomeTimelineChoreo.addInput("ConsumerSecret", TWITTER_CONSUMER_SECRET); + + // next, we'll define two output filters that let us specify the + // elements of the response from Twitter that we want to receive. + // see the examples at http://www.temboo.com/arduino + // for more on using output filters + + // we want the text of the tweet + HomeTimelineChoreo.addOutputFilter("tweet", "/[1]/text", "Response"); + + // and the name of the author + HomeTimelineChoreo.addOutputFilter("author", "/[1]/user/screen_name", "Response"); + + + // tell the Process to run and wait for the results. The + // return code will tell us whether the Temboo client + // was able to send our request to the Temboo servers + unsigned int returnCode = HomeTimelineChoreo.run(); + + // a response code of 0 means success; print the API response + if(returnCode == 0) { + + String author; // a String to hold the tweet author's name + String tweet; // a String to hold the text of the tweet + + + // choreo outputs are returned as key/value pairs, delimited with + // newlines and record/field terminator characters, for example: + // Name1\n\x1F + // Value1\n\x1E + // Name2\n\x1F + // Value2\n\x1E + + // see the examples at http://www.temboo.com/arduino for more details + // we can read this format into separate variables, as follows: + + while(HomeTimelineChoreo.available()) { + // read the name of the output item + String name = HomeTimelineChoreo.readStringUntil('\x1F'); + name.trim(); + + // read the value of the output item + String data = HomeTimelineChoreo.readStringUntil('\x1E'); + data.trim(); + + // assign the value to the appropriate String + if (name == "tweet") { + tweet = data; + } else if (name == "author") { + author = data; + } + } + + Serial.println("@" + author + " - " + tweet); + + } else { + // there was an error + // print the raw output from the choreo + while(HomeTimelineChoreo.available()) { + char c = HomeTimelineChoreo.read(); + Serial.print(c); + } + } + + HomeTimelineChoreo.close(); + + } + + Serial.println("Waiting..."); + delay(90000); // wait 90 seconds between HomeTimeline calls +} + +/* + IMPORTANT NOTE: TembooAccount.h: + + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: + + #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name + #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name + #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + You can find your Temboo App Key information on the Temboo website, + under My Account > Application Keys + + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + + Keeping your account information in a separate file means you can share the main .ino file without worrying + that you forgot to delete your credentials. +*/ diff --git a/libraries/Bridge/examples/Temboo/ReadATweet/TembooAccount.h b/libraries/Bridge/examples/Temboo/ReadATweet/TembooAccount.h new file mode 100644 index 0000000..c58b447 --- /dev/null +++ b/libraries/Bridge/examples/Temboo/ReadATweet/TembooAccount.h @@ -0,0 +1,4 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + diff --git a/libraries/Bridge/examples/Temboo/SendATweet/SendATweet.ino b/libraries/Bridge/examples/Temboo/SendATweet/SendATweet.ino new file mode 100644 index 0000000..2e34a82 --- /dev/null +++ b/libraries/Bridge/examples/Temboo/SendATweet/SendATweet.ino @@ -0,0 +1,138 @@ +/* + SendATweet + + Demonstrates sending a tweet via a Twitter account using Temboo from an Arduino Yun. + + Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino + + A Temboo account and application key are necessary to run all Temboo examples. + If you don't already have one, you can register for a free Temboo account at + http://www.temboo.com + + In order to run this sketch, you'll need to register an application using + the Twitter dev console at https://dev.twitter.com. Note that since this + sketch creates a new tweet, your application will need to be configured with + read+write permissions. After creating the app, you'll find OAuth credentials + for that application under the "OAuth Tool" tab. Substitute these values for + the placeholders below. + + This example assumes basic familiarity with Arduino sketches, and that your Yun is connected + to the Internet. + + Want to use another social API with your Arduino Yun? We've got Facebook, + Google+, Instagram, Tumblr and more in our Library! + + This example code is in the public domain. +*/ + +#include <Bridge.h> +#include <Temboo.h> +#include "TembooAccount.h" // contains Temboo account information + // as described in the footer comment below + + +/*** SUBSTITUTE YOUR VALUES BELOW: ***/ + +// Note that for additional security and reusability, you could +// use #define statements to specify these values in a .h file. +const String TWITTER_ACCESS_TOKEN = "your-twitter-access-token"; +const String TWITTER_ACCESS_TOKEN_SECRET = "your-twitter-access-token-secret"; +const String TWITTER_CONSUMER_KEY = "your-twitter-consumer-key"; +const String TWITTER_CONSUMER_SECRET = "your-twitter-consumer-secret"; + +int numRuns = 1; // execution count, so this sketch doesn't run forever +int maxRuns = 3; // the max number of times the Twitter Update Choreo should run + +void setup() { + Serial.begin(9600); + + // for debugging, wait until a serial console is connected + delay(4000); + while(!Serial); + + Bridge.begin(); +} + +void loop() +{ + // only try to send the tweet if we haven't already sent it successfully + if (numRuns <= maxRuns) { + + Serial.println("Running SendATweet - Run #" + String(numRuns++) + "..."); + + // define the text of the tweet we want to send + String tweetText("My Arduino Yun has been running for " + String(millis()) + " milliseconds."); + + + TembooChoreo StatusesUpdateChoreo; + + // invoke the Temboo client + // NOTE that the client must be reinvoked, and repopulated with + // appropriate arguments, each time its run() method is called. + StatusesUpdateChoreo.begin(); + + // set Temboo account credentials + StatusesUpdateChoreo.setAccountName(TEMBOO_ACCOUNT); + StatusesUpdateChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); + StatusesUpdateChoreo.setAppKey(TEMBOO_APP_KEY); + + // identify the Temboo Library choreo to run (Twitter > Tweets > StatusesUpdate) + StatusesUpdateChoreo.setChoreo("/Library/Twitter/Tweets/StatusesUpdate"); + + // set the required choreo inputs + // see https://www.temboo.com/library/Library/Twitter/Tweets/StatusesUpdate/ + // for complete details about the inputs for this Choreo + + // add the Twitter account information + StatusesUpdateChoreo.addInput("AccessToken", TWITTER_ACCESS_TOKEN); + StatusesUpdateChoreo.addInput("AccessTokenSecret", TWITTER_ACCESS_TOKEN_SECRET); + StatusesUpdateChoreo.addInput("ConsumerKey", TWITTER_CONSUMER_KEY); + StatusesUpdateChoreo.addInput("ConsumerSecret", TWITTER_CONSUMER_SECRET); + + // and the tweet we want to send + StatusesUpdateChoreo.addInput("StatusUpdate", tweetText); + + // tell the Process to run and wait for the results. The + // return code (returnCode) will tell us whether the Temboo client + // was able to send our request to the Temboo servers + unsigned int returnCode = StatusesUpdateChoreo.run(); + + // a return code of zero (0) means everything worked + if (returnCode == 0) { + Serial.println("Success! Tweet sent!"); + } else { + // a non-zero return code means there was an error + // read and print the error message + while (StatusesUpdateChoreo.available()) { + char c = StatusesUpdateChoreo.read(); + Serial.print(c); + } + } + StatusesUpdateChoreo.close(); + + // do nothing for the next 90 seconds + Serial.println("Waiting..."); + delay(90000); + } +} + +/* + IMPORTANT NOTE: TembooAccount.h: + + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: + + #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name + #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name + #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + You can find your Temboo App Key information on the Temboo website, + under My Account > Application Keys + + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + + Keeping your account information in a separate file means you can share the main .ino file without worrying + that you forgot to delete your credentials. +*/ diff --git a/libraries/Bridge/examples/Temboo/SendATweet/TembooAccount.h b/libraries/Bridge/examples/Temboo/SendATweet/TembooAccount.h new file mode 100644 index 0000000..c58b447 --- /dev/null +++ b/libraries/Bridge/examples/Temboo/SendATweet/TembooAccount.h @@ -0,0 +1,4 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + diff --git a/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino b/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino new file mode 100644 index 0000000..4f841f8 --- /dev/null +++ b/libraries/Bridge/examples/Temboo/SendAnEmail/SendAnEmail.ino @@ -0,0 +1,137 @@ +/* + SendAnEmail + + Demonstrates sending an email via a Google Gmail account using Temboo from an Arduino Yun. + + Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino + + A Temboo account and application key are necessary to run all Temboo examples. + If you don't already have one, you can register for a free Temboo account at + http://www.temboo.com + + Since this sketch uses Gmail to send the email, you'll also need a valid + Google Gmail account. The sketch needs the username and password you use + to log into your Gmail account - substitute the placeholders below for these values. + + This example assumes basic familiarity with Arduino sketches, and that your Yun is connected + to the Internet. + + Looking for another API to use with your Arduino Yun? We've got over 100 in our Library! + + This example code is in the public domain. +*/ + +#include <Bridge.h> +#include <Temboo.h> +#include "TembooAccount.h" // contains Temboo account information + // as described in the footer comment below + +/*** SUBSTITUTE YOUR VALUES BELOW: ***/ + +// Note that for additional security and reusability, you could +// use #define statements to specify these values in a .h file. + +// your Gmail username, formatted as a complete email address, eg "bob.smith@gmail.com" +const String GMAIL_USER_NAME = "xxxxxxxxxx"; + +// your Gmail password +const String GMAIL_PASSWORD = "xxxxxxxxxx"; + +// the email address you want to send the email to, eg "jane.doe@temboo.com" +const String TO_EMAIL_ADDRESS = "xxxxxxxxxx"; + +// a flag to indicate whether we've tried to send the email yet or not +boolean attempted = false; + +void setup() { + Serial.begin(9600); + + // for debugging, wait until a serial console is connected + delay(4000); + while(!Serial); + + Bridge.begin(); +} + +void loop() +{ + // only try to send the email if we haven't already tried + if (!attempted) { + + Serial.println("Running SendAnEmail..."); + + TembooChoreo SendEmailChoreo; + + // invoke the Temboo client + // NOTE that the client must be reinvoked, and repopulated with + // appropriate arguments, each time its run() method is called. + SendEmailChoreo.begin(); + + // set Temboo account credentials + SendEmailChoreo.setAccountName(TEMBOO_ACCOUNT); + SendEmailChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); + SendEmailChoreo.setAppKey(TEMBOO_APP_KEY); + + // identify the Temboo Library choreo to run (Google > Gmail > SendEmail) + SendEmailChoreo.setChoreo("/Library/Google/Gmail/SendEmail"); + + + // set the required choreo inputs + // see https://www.temboo.com/library/Library/Google/Gmail/SendEmail/ + // for complete details about the inputs for this Choreo + + // the first input is your Gmail email address. + SendEmailChoreo.addInput("Username", GMAIL_USER_NAME); + // next is your Gmail password. + SendEmailChoreo.addInput("Password", GMAIL_PASSWORD); + // who to send the email to + SendEmailChoreo.addInput("ToAddress", TO_EMAIL_ADDRESS); + // then a subject line + SendEmailChoreo.addInput("Subject", "ALERT: Greenhouse Temperature"); + + // next comes the message body, the main content of the email + SendEmailChoreo.addInput("MessageBody", "Hey! The greenhouse is too cold!"); + + // tell the Choreo to run and wait for the results. The + // return code (returnCode) will tell us whether the Temboo client + // was able to send our request to the Temboo servers + unsigned int returnCode = SendEmailChoreo.run(); + + // a return code of zero (0) means everything worked + if (returnCode == 0) { + Serial.println("Success! Email sent!"); + } else { + // a non-zero return code means there was an error + // read and print the error message + while (SendEmailChoreo.available()) { + char c = SendEmailChoreo.read(); + Serial.print(c); + } + } + SendEmailChoreo.close(); + + // set the flag showing we've tried + attempted = true; + } +} + +/* + IMPORTANT NOTE: TembooAccount.h: + + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: + + #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name + #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name + #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + You can find your Temboo App Key information on the Temboo website, + under My Account > Application Keys + + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + + Keeping your account information in a separate file means you can share the main .ino file without worrying + that you forgot to delete your credentials. +*/ diff --git a/libraries/Bridge/examples/Temboo/SendAnEmail/TembooAccount.h b/libraries/Bridge/examples/Temboo/SendAnEmail/TembooAccount.h new file mode 100644 index 0000000..c58b447 --- /dev/null +++ b/libraries/Bridge/examples/Temboo/SendAnEmail/TembooAccount.h @@ -0,0 +1,4 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + diff --git a/libraries/Bridge/examples/Temboo/SendAnSMS/SendAnSMS.ino b/libraries/Bridge/examples/Temboo/SendAnSMS/SendAnSMS.ino new file mode 100644 index 0000000..2b0cfb1 --- /dev/null +++ b/libraries/Bridge/examples/Temboo/SendAnSMS/SendAnSMS.ino @@ -0,0 +1,154 @@ +/* + SendAnSMS + + Demonstrates sending an SMS via Twilio using Temboo from an Arduino Yun. + + Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino + + A Temboo account and application key are necessary to run all Temboo examples. + If you don't already have one, you can register for a free Temboo account at + http://www.temboo.com + + Since this sketch uses Twilio to send the SMS, you'll also need a valid + Twilio account. You can create one for free at https://www.twilio.com. + + The sketch needs your Twilio phone number, along with + the Account SID and Auth Token you get when you register with Twilio. + Make sure to use the Account SID and Auth Token from your Twilio Dashboard + (not your test credentials from the Dev Tools panel). + + Also note that if you're using a free Twilio account, you'll need to verify + the phone number to which messages are being sent by going to twilio.com and following + the instructions under the "Numbers > Verified Caller IDs" tab (this restriction + doesn't apply if you have a paid Twilio account). + + This example assumes basic familiarity with Arduino sketches, and that your Yun is connected + to the Internet. + + Looking for another API to use with your Arduino Yun? We've got over 100 in our Library! + + This example code is in the public domain. +*/ + +#include <Bridge.h> +#include <Temboo.h> +#include "TembooAccount.h" // contains Temboo account information + // as described in the footer comment below + + + +/*** SUBSTITUTE YOUR VALUES BELOW: ***/ + +// Note that for additional security and reusability, you could +// use #define statements to specify these values in a .h file. + +// the Account SID from your Twilio account +const String TWILIO_ACCOUNT_SID = "xxxxxxxxxx"; + +// the Auth Token from your Twilio account +const String TWILIO_AUTH_TOKEN = "xxxxxxxxxx"; + +// your Twilio phone number, e.g., "+1 555-222-1212" +const String TWILIO_NUMBER = "xxxxxxxxxx"; + +// the number to which the SMS should be sent, e.g., "+1 555-222-1212" +const String RECIPIENT_NUMBER = "xxxxxxxxxx"; + +// a flag to indicate whether we've attempted to send the SMS yet or not +boolean attempted = false; + +void setup() { + Serial.begin(9600); + + // for debugging, wait until a serial console is connected + delay(4000); + while(!Serial); + + Bridge.begin(); +} + +void loop() +{ + // only try to send the SMS if we haven't already sent it successfully + if (!attempted) { + + Serial.println("Running SendAnSMS..."); + + // we need a Process object to send a Choreo request to Temboo + TembooChoreo SendSMSChoreo; + + // invoke the Temboo client + // NOTE that the client must be reinvoked and repopulated with + // appropriate arguments each time its run() method is called. + SendSMSChoreo.begin(); + + // set Temboo account credentials + SendSMSChoreo.setAccountName(TEMBOO_ACCOUNT); + SendSMSChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); + SendSMSChoreo.setAppKey(TEMBOO_APP_KEY); + + // identify the Temboo Library choreo to run (Twilio > SMSMessages > SendSMS) + SendSMSChoreo.setChoreo("/Library/Twilio/SMSMessages/SendSMS"); + + // set the required choreo inputs + // see https://www.temboo.com/library/Library/Twilio/SMSMessages/SendSMS/ + // for complete details about the inputs for this Choreo + + // the first input is a your AccountSID + SendSMSChoreo.addInput("AccountSID", TWILIO_ACCOUNT_SID); + + // next is your Auth Token + SendSMSChoreo.addInput("AuthToken", TWILIO_AUTH_TOKEN); + + // next is your Twilio phone number + SendSMSChoreo.addInput("From", TWILIO_NUMBER); + + // next, what number to send the SMS to + SendSMSChoreo.addInput("To", RECIPIENT_NUMBER); + + // finally, the text of the message to send + SendSMSChoreo.addInput("Body", "Hey, there! This is a message from your Arduino Yun!"); + + // tell the Process to run and wait for the results. The + // return code (returnCode) will tell us whether the Temboo client + // was able to send our request to the Temboo servers + unsigned int returnCode = SendSMSChoreo.run(); + + // a return code of zero (0) means everything worked + if (returnCode == 0) { + Serial.println("Success! SMS sent!"); + } else { + // a non-zero return code means there was an error + // read and print the error message + while (SendSMSChoreo.available()) { + char c = SendSMSChoreo.read(); + Serial.print(c); + } + } + SendSMSChoreo.close(); + + // set the flag indicatine we've tried once. + attempted=true; + } +} + +/* + IMPORTANT NOTE: TembooAccount.h: + + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: + + #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name + #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name + #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + You can find your Temboo App Key information on the Temboo website, + under My Account > Application Keys + + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + + Keeping your account information in a separate file means you can share the main .ino file without worrying + that you forgot to delete your credentials. +*/ diff --git a/libraries/Bridge/examples/Temboo/SendAnSMS/TembooAccount.h b/libraries/Bridge/examples/Temboo/SendAnSMS/TembooAccount.h new file mode 100644 index 0000000..8d7dcfb --- /dev/null +++ b/libraries/Bridge/examples/Temboo/SendAnSMS/TembooAccount.h @@ -0,0 +1,5 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + diff --git a/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/SendDataToGoogleSpreadsheet.ino b/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/SendDataToGoogleSpreadsheet.ino new file mode 100644 index 0000000..1f1b6b4 --- /dev/null +++ b/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/SendDataToGoogleSpreadsheet.ino @@ -0,0 +1,178 @@ +/* + SendDataToGoogleSpreadsheet + + Demonstrates appending a row of data to a Google spreadsheet using Temboo from an Arduino Yun. + + Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino + + A Temboo account and application key are necessary to run all Temboo examples. + If you don't already have one, you can register for a free Temboo account at + http://www.temboo.com + + Since this sketch uses a Google spreadsheet, you'll also need a + Google account: substitute the placeholders below for your Google account values. + + This example assumes basic familiarity with Arduino sketches, and that your + Yun is connected to the Internet. + + The columns in your spreadsheet must have labels for the Choreo to + work properly. It doesn't matter what the column labels actually are, + but there must be text in the first row of each column. This example + assumes there are two columns. The first column is the time (in milliseconds) + that the row was appended, and the second column is a sensor value. + In other words, your spreadsheet should look like: + + Time | Sensor Value | + ------+----------------- + | | + + NOTE that the first time you run this sketch, you may receive a warning from + Google, prompting you to authorize access from a 3rd party system. + + Looking for another API to use with your Arduino Yun? We've got over 100 in our Library! + + This example code is in the public domain. + +*/ + +#include <Bridge.h> +#include <Temboo.h> +#include "TembooAccount.h" // contains Temboo account information, + // as described in the footer comment below + + +/*** SUBSTITUTE YOUR VALUES BELOW: ***/ + +// Note that for additional security and reusability, you could +// use #define statements to specify these values in a .h file. + +const String GOOGLE_USERNAME = "your-google-username"; +const String GOOGLE_PASSWORD = "your-google-password"; + +// the title of the spreadsheet you want to send data to +// (Note that this must actually be the title of a Google spreadsheet +// that exists in your Google Drive/Docs account, and is configured +// as described above.) +const String SPREADSHEET_TITLE = "your-spreadsheet-title"; + +const unsigned long RUN_INTERVAL_MILLIS = 60000; // how often to run the Choreo (in milliseconds) + +// the last time we ran the Choreo +// (initialized to 60 seconds ago so the +// Choreo is run immediately when we start up) +unsigned long lastRun = (unsigned long)-60000; + +void setup() { + + // for debugging, wait until a serial console is connected + Serial.begin(9600); + delay(4000); + while(!Serial); + + Serial.print("Initializing the bridge..."); + Bridge.begin(); + Serial.println("Done"); +} + +void loop() +{ + // get the number of milliseconds this sketch has been running + unsigned long now = millis(); + + // run again if it's been 60 seconds since we last ran + if (now - lastRun >= RUN_INTERVAL_MILLIS) { + + // remember 'now' as the last time we ran the choreo + lastRun = now; + + Serial.println("Getting sensor value..."); + + // get the value we want to append to our spreadsheet + unsigned long sensorValue = getSensorValue(); + + Serial.println("Appending value to spreadsheet..."); + + // we need a Process object to send a Choreo request to Temboo + TembooChoreo AppendRowChoreo; + + // invoke the Temboo client + // NOTE that the client must be reinvoked and repopulated with + // appropriate arguments each time its run() method is called. + AppendRowChoreo.begin(); + + // set Temboo account credentials + AppendRowChoreo.setAccountName(TEMBOO_ACCOUNT); + AppendRowChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); + AppendRowChoreo.setAppKey(TEMBOO_APP_KEY); + + // identify the Temboo Library choreo to run (Google > Spreadsheets > AppendRow) + AppendRowChoreo.setChoreo("/Library/Google/Spreadsheets/AppendRow"); + + // set the required Choreo inputs + // see https://www.temboo.com/library/Library/Google/Spreadsheets/AppendRow/ + // for complete details about the inputs for this Choreo + + // your Google username (usually your email address) + AppendRowChoreo.addInput("Username", GOOGLE_USERNAME); + + // your Google account password + AppendRowChoreo.addInput("Password", GOOGLE_PASSWORD); + + // the title of the spreadsheet you want to append to + // NOTE: substitute your own value, retaining the "SpreadsheetTitle:" prefix. + AppendRowChoreo.addInput("SpreadsheetTitle", SPREADSHEET_TITLE); + + // convert the time and sensor values to a comma separated string + String rowData(now); + rowData += ","; + rowData += sensorValue; + + // add the RowData input item + AppendRowChoreo.addInput("RowData", rowData); + + // run the Choreo and wait for the results + // The return code (returnCode) will indicate success or failure + unsigned int returnCode = AppendRowChoreo.run(); + + // return code of zero (0) means success + if (returnCode == 0) { + Serial.println("Success! Appended " + rowData); + Serial.println(""); + } else { + // return code of anything other than zero means failure + // read and display any error messages + while (AppendRowChoreo.available()) { + char c = AppendRowChoreo.read(); + Serial.print(c); + } + } + + AppendRowChoreo.close(); + } +} + +// this function simulates reading the value of a sensor +unsigned long getSensorValue() { + return analogRead(A0); +} + +/* + IMPORTANT NOTE: TembooAccount.h: + + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: + + #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name + #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name + #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + You can find your Temboo App Key information on the Temboo website, + under My Account > Application Keys + + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + + Keeping your account information in a separate file means you can share the main .ino file without worrying + that you forgot to delete your credentials. +*/ diff --git a/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/TembooAccount.h b/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/TembooAccount.h new file mode 100644 index 0000000..8d7dcfb --- /dev/null +++ b/libraries/Bridge/examples/Temboo/SendDataToGoogleSpreadsheet/TembooAccount.h @@ -0,0 +1,5 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + diff --git a/libraries/Bridge/examples/Temboo/ToxicFacilitiesSearch/TembooAccount.h b/libraries/Bridge/examples/Temboo/ToxicFacilitiesSearch/TembooAccount.h new file mode 100644 index 0000000..8d7dcfb --- /dev/null +++ b/libraries/Bridge/examples/Temboo/ToxicFacilitiesSearch/TembooAccount.h @@ -0,0 +1,5 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + diff --git a/libraries/Bridge/examples/Temboo/ToxicFacilitiesSearch/ToxicFacilitiesSearch.ino b/libraries/Bridge/examples/Temboo/ToxicFacilitiesSearch/ToxicFacilitiesSearch.ino new file mode 100644 index 0000000..3b7f1d1 --- /dev/null +++ b/libraries/Bridge/examples/Temboo/ToxicFacilitiesSearch/ToxicFacilitiesSearch.ino @@ -0,0 +1,171 @@ +/* + ToxicFacilitiesSearch + + Demonstrates making a request to the Envirofacts API using Temboo from an Arduino Yun. + This example retrieves the names and addresses of EPA-regulated facilities in the + Toxins Release Inventory (TRI) database within a given zip code. + + Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino + + A Temboo account and application key are necessary to run all Temboo examples. + If you don't already have one, you can register for a free Temboo account at + http://www.temboo.com + + This example assumes basic familiarity with Arduino sketches, and that your Yun is connected + to the Internet. + + Looking for another API to use with your Arduino Yun? We've got over 100 in our Library! + + This example code is in the public domain. +*/ + +#include <Bridge.h> +#include <Temboo.h> +#include "TembooAccount.h" // contains Temboo account information + // as described in the footer comment below + +// the zip code to search for toxin-emitting facilities +String US_ZIP_CODE = "11215"; + +int numRuns = 1; // execution count, so that this doesn't run forever +int maxRuns = 10; // max number of times the Envirofacts FacilitiesSearch Choreo should be run + +void setup() { + Serial.begin(9600); + + // for debugging, wait until a serial console is connected + delay(4000); + while(!Serial); + Bridge.begin(); +} + +void loop() +{ + // while we haven't reached the max number of runs... + if (numRuns <= maxRuns) { + + // print status + Serial.println("Running ToxicFacilitiesSearch - Run #" + String(numRuns++) + "..."); + + // we need a Process object to send a Choreo request to Temboo + TembooChoreo FacilitiesSearchByZipChoreo; + + // invoke the Temboo client + // NOTE that the client must be reinvoked and repopulated with + // appropriate arguments each time its run() method is called. + FacilitiesSearchByZipChoreo.begin(); + + // set Temboo account credentials + FacilitiesSearchByZipChoreo.setAccountName(TEMBOO_ACCOUNT); + FacilitiesSearchByZipChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); + FacilitiesSearchByZipChoreo.setAppKey(TEMBOO_APP_KEY); + + // identify the Temboo Library choreo to run (EnviroFacts > Toxins > FacilitiesSearchByZip) + FacilitiesSearchByZipChoreo.setChoreo("/Library/EnviroFacts/Toxins/FacilitiesSearchByZip"); + + // set choreo inputs; in this case, the US zip code for which to retrieve toxin release data + // the Temboo client provides standardized calls to 100+ cloud APIs + FacilitiesSearchByZipChoreo.addInput("Zip", US_ZIP_CODE); + + // specify two output filters, to help simplify the Envirofacts API results. + // see the tutorials on using Temboo SDK output filters at http://www.temboo.com/arduino + FacilitiesSearchByZipChoreo.addOutputFilter("fac", "FACILITY_NAME", "Response"); + + FacilitiesSearchByZipChoreo.addOutputFilter("addr", "STREET_ADDRESS", "Response"); + + // run the choreo + unsigned int returnCode = FacilitiesSearchByZipChoreo.run(); + if (returnCode == 0) { + String facilities; + String addresses; + + // when the choreo results are available, process them. + // the output filters we specified will return comma delimited + // lists containing the name and street address of the facilities + // located in the specified zip code. + while(FacilitiesSearchByZipChoreo.available()) { + String name = FacilitiesSearchByZipChoreo.readStringUntil('\x1F'); + name.trim(); + + String data = FacilitiesSearchByZipChoreo.readStringUntil('\x1E'); + data.trim(); + + if (name == "fac") { + facilities = data; + } else if (name == "addr") { + addresses = data; + } + } + FacilitiesSearchByZipChoreo.close(); + + // parse the comma delimited lists of facilities to join the + // name with the address and print it to the serial monitor + if (facilities.length() > 0) { + int i = -1; + int facilityStart = 0; + int addressStart = 0; + String facility; + String address; + do { + i = facilities.indexOf(',', facilityStart); + if (i >= 0) { + facility = facilities.substring(facilityStart, i); + facilityStart = i + 1; + } + + i = addresses.indexOf(',', addressStart); + if (i >= 0) { + address = addresses.substring(addressStart, i); + addressStart = i + 1; + } + + if (i >= 0) { + printResult(facility, address); + } + + }while (i >= 0); + facility = facilities.substring(facilityStart); + address = addresses.substring(addressStart); + printResult(facility, address); + } else { + Serial.println("No facilities found in zip code " + US_ZIP_CODE); + } + } else { + while(FacilitiesSearchByZipChoreo.available()) { + char c = FacilitiesSearchByZipChoreo.read(); + Serial.print(c); + } + } + } + Serial.println("Waiting..."); + Serial.println(""); + delay(30000); // wait 30 seconds between calls +} + +// a simple utility function, to output the facility name and address in the serial monitor. +void printResult(String facility, String address) { + Serial.print(facility); + Serial.print(" - "); + Serial.println(address); +} + +/* + IMPORTANT NOTE: TembooAccount.h: + + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: + + #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name + #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name + #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + You can find your Temboo App Key information on the Temboo website, + under My Account > Application Keys + + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + + Keeping your account information in a separate file means you can share the main .ino file without worrying + that you forgot to delete your credentials. +*/ diff --git a/libraries/Bridge/examples/Temboo/UpdateFacebookStatus/TembooAccount.h b/libraries/Bridge/examples/Temboo/UpdateFacebookStatus/TembooAccount.h new file mode 100644 index 0000000..8d7dcfb --- /dev/null +++ b/libraries/Bridge/examples/Temboo/UpdateFacebookStatus/TembooAccount.h @@ -0,0 +1,5 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + diff --git a/libraries/Bridge/examples/Temboo/UpdateFacebookStatus/UpdateFacebookStatus.ino b/libraries/Bridge/examples/Temboo/UpdateFacebookStatus/UpdateFacebookStatus.ino new file mode 100644 index 0000000..dd8cabd --- /dev/null +++ b/libraries/Bridge/examples/Temboo/UpdateFacebookStatus/UpdateFacebookStatus.ino @@ -0,0 +1,132 @@ +/* + UpdateFacebookStatus + + Demonstrates sending a Facebook status update using Temboo from an Arduino Yun. + + Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino + + A Temboo account and application key are necessary to run all Temboo examples. + If you don't already have one, you can register for a free Temboo account at + http://www.temboo.com + + In order to run this sketch, you'll need to register an application using + the Facebook dev console at https://developers.facebook.com/apps -- after creating + the app, log in to Temboo and visit https://www.temboo.com/library/Library/Facebook/Publishing/SetStatus/ + to use our OAuth Wizard (or OAuth Choreos) to obtain a Facebook access token. + Substitute your access token for the placeholder value of FACEBOOK_ACCESS_TOKEN below. + + This example assumes basic familiarity with Arduino sketches, and that your Yun + is connected to the Internet. + + Want to use another social API with your Arduino Yun? We've got Twitter, Google+, + Instagram, Tumblr and more in our Library! + + This example code is in the public domain. +*/ + +#include <Bridge.h> +#include <Temboo.h> +#include "TembooAccount.h" // contains Temboo account information, + // as described in the footer comment below + +/*** SUBSTITUTE YOUR VALUES BELOW: ***/ + +// Note that for additional security and reusability, you could +// use a #define statement to specify this value in a .h file. + +// the Facebook Access Token, which can be obtained using the Temboo OAuth Wizard or Choreos +const String FACEBOOK_ACCESS_TOKEN = "xxxxxxxxxx"; + + +int numRuns = 1; // execution count, so this sketch doesn't run forever +int maxRuns = 10; // the max number of times the Facebook SetStatus Choreo should run + +void setup() { + Serial.begin(9600); + + // For debugging, wait until a serial console is connected. + delay(4000); + while(!Serial); + Bridge.begin(); +} + +void loop() { + // while we haven't reached the max number of runs... + if (numRuns <= maxRuns) { + + // print status + Serial.println("Running UpdateFacebookStatus - Run #" + String(numRuns++) + "..."); + + // Define the status message we want to post on Facebook; since Facebook + // doesn't allow duplicate status messages, we'll include a changing value. + String statusMsg = "My Arduino Yun has been running for " + String(millis()) + " milliseconds!"; + + // define the Process that will be used to call the "temboo" client + TembooChoreo SetStatusChoreo; + + // invoke the Temboo client + // NOTE that the client must be reinvoked and repopulated with + // appropriate arguments each time its run() method is called. + SetStatusChoreo.begin(); + + // set Temboo account credentials + SetStatusChoreo.setAccountName(TEMBOO_ACCOUNT); + SetStatusChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); + SetStatusChoreo.setAppKey(TEMBOO_APP_KEY); + + // tell the Temboo client which Choreo to run (Facebook > Publishing > SetStatus) + SetStatusChoreo.setChoreo("/Library/Facebook/Publishing/SetStatus"); + + // set the required choreo inputs + // see https://www.temboo.com/library/Library/Facebook/Publishing/SetStatus/ + // for complete details about the inputs for this Choreo + + SetStatusChoreo.addInput("AccessToken", FACEBOOK_ACCESS_TOKEN); + SetStatusChoreo.addInput("Message", statusMsg); + + + // tell the Process to run and wait for the results. The + // return code (returnCode) will tell us whether the Temboo client + // was able to send our request to the Temboo servers + unsigned int returnCode = SetStatusChoreo.run(); + + // print the response code and API response. + Serial.println("Response code: " + String(returnCode)); + + // note that in this case, we're just printing the raw response from Facebook. + // see the examples on using Temboo SDK output filters at http://www.temboo.com/arduino + // for information on how to filter this data + while(SetStatusChoreo.available()) { + char c = SetStatusChoreo.read(); + Serial.print(c); + } + + SetStatusChoreo.close(); + } + + Serial.println("Waiting..."); + Serial.println(""); + + delay(30000); // wait 30 seconds between SetStatus calls +} + +/* + IMPORTANT NOTE: TembooAccount.h: + + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: + + #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name + #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name + #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + You can find your Temboo App Key information on the Temboo website, + under My Account > Application Keys + + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + + Keeping your account information in a separate file means you can share the main .ino file without worrying + that you forgot to delete your credentials. +*/ diff --git a/libraries/Bridge/examples/Temboo/UploadToDropbox/TembooAccount.h b/libraries/Bridge/examples/Temboo/UploadToDropbox/TembooAccount.h new file mode 100644 index 0000000..8d7dcfb --- /dev/null +++ b/libraries/Bridge/examples/Temboo/UploadToDropbox/TembooAccount.h @@ -0,0 +1,5 @@ +#define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name +#define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name +#define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + diff --git a/libraries/Bridge/examples/Temboo/UploadToDropbox/UploadToDropbox.ino b/libraries/Bridge/examples/Temboo/UploadToDropbox/UploadToDropbox.ino new file mode 100644 index 0000000..744dcdb --- /dev/null +++ b/libraries/Bridge/examples/Temboo/UploadToDropbox/UploadToDropbox.ino @@ -0,0 +1,208 @@ +/* + UploadToDropbox + + Demonstrates uploading a file to a Dropbox account using Temboo from an Arduino Yun. + + Check out the latest Arduino & Temboo examples and support docs at http://www.temboo.com/arduino + + A Temboo account and application key are necessary to run all Temboo examples. + If you don't already have one, you can register for a free Temboo account at + http://www.temboo.com + + You'll also need a valid Dropbox app and accompanying OAuth credentials. + To create a Dropbox app, visit https://www.dropbox.com/developers/apps and + do the following: + + 1. Create a "Dropbox API app" + 2. Select "Files and datastores" + 3. Select "Yes - my app only needs access to the files it creates." + + Once you've created your app, follow the instructions at + https://www.temboo.com/library/Library/Dropbox/OAuth/ to run the Initialize and Finalize + OAuth Choreos. These Choreos complete the OAuth handshake and retrieve your Dropbox OAuth access tokens. + + This example assumes basic familiarity with Arduino sketches, and that your Yun is connected + to the Internet. + + Looking for another API to use with your Arduino Yun? We've got over 100 in our Library! + + This example code is in the public domain. +*/ + +#include <Bridge.h> +#include <Temboo.h> +#include "TembooAccount.h" // contains Temboo account information + // as described in the footer comment below + + +/*** SUBSTITUTE YOUR VALUES BELOW: ***/ + +// Note that for additional security and reusability, you could +// use #define statements to specify these values in a .h file. + +// your Dropbox app key, available on the Dropbox developer console after registering an app +const String DROPBOX_APP_KEY = "xxxxxxxxxx"; + +// your Dropbox app secret, available on the Dropbox developer console after registering an app +const String DROPBOX_APP_SECRET = "xxxxxxxxxx"; + +// your Dropbox access token, which is returned by the FinalizeOAuth Choreo +const String DROPBOX_ACCESS_TOKEN = "xxxxxxxxxx"; + +// your Dropbox access token secret, which is returned by the FinalizeOAuth Choreo +const String DROPBOX_ACCESS_TOKEN_SECRET = "xxxxxxxxxx"; + + +boolean success = false; // a flag to indicate whether we've uploaded the file yet + +void setup() { + Serial.begin(9600); + + // For debugging, wait until a serial console is connected. + delay(4000); + while(!Serial); + Bridge.begin(); +} + +void loop() +{ + // only try to upload the file if we haven't already done so + if (!success) { + + Serial.println("Base64 encoding data to upload..."); + + // base64 encode the data to upload + String base64EncodedData = base64Encode("Hello, Arduino!"); + + + Serial.println("Uploading data to Dropbox..."); + + // we need a Process object to send a Choreo request to Temboo + TembooChoreo UploadFileChoreo; + + // invoke the Temboo client + // NOTE that the client must be reinvoked and repopulated with + // appropriate arguments each time its run() method is called. + UploadFileChoreo.begin(); + + // set Temboo account credentials + UploadFileChoreo.setAccountName(TEMBOO_ACCOUNT); + UploadFileChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); + UploadFileChoreo.setAppKey(TEMBOO_APP_KEY); + + // identify the Temboo Library choreo to run (Dropbox > FilesAndMetadata > UploadFile) + UploadFileChoreo.setChoreo("/Library/Dropbox/FilesAndMetadata/UploadFile"); + + // set the required choreo inputs + // see https://www.temboo.com/library/Library/Dropbox/FilesAndMetadata/UploadFile/ + // for complete details about the inputs for this Choreo + + // first specify the name of the file to create/update on Dropbox + UploadFileChoreo.addInput("FileName", "ArduinoTest.txt"); + + // next, the root folder on Dropbox relative to which the file path is specified. + // to work with the Dropbox app you created earlier, this should be left as "sandbox" + // if your Dropbox app has full access to your files, specify "dropbox" + UploadFileChoreo.addInput("Root","sandbox"); + + // next, the Base64 encoded file data to upload + UploadFileChoreo.addInput("FileContents", base64EncodedData); + + // finally, the Dropbox OAuth credentials defined above + UploadFileChoreo.addInput("AppSecret", DROPBOX_APP_SECRET); + UploadFileChoreo.addInput("AccessToken", DROPBOX_ACCESS_TOKEN); + UploadFileChoreo.addInput("AccessTokenSecret", DROPBOX_ACCESS_TOKEN_SECRET); + UploadFileChoreo.addInput("AppKey", DROPBOX_APP_KEY); + + // tell the Process to run and wait for the results. The + // return code (returnCode) will tell us whether the Temboo client + // was able to send our request to the Temboo servers + unsigned int returnCode = UploadFileChoreo.run(); + + // a return code of zero (0) means everything worked + if (returnCode == 0) { + Serial.println("Success! File uploaded!"); + success = true; + } else { + // a non-zero return code means there was an error + Serial.println("Uh-oh! Something went wrong!"); + } + + // print out the full response to the serial monitor in all + // cases, just for debugging + while (UploadFileChoreo.available()) { + char c = UploadFileChoreo.read(); + Serial.print(c); + } + UploadFileChoreo.close(); + + Serial.println("Waiting..."); + } + + delay(30000); // wait 30 seconds between upload attempts +} + + +/* + A utility function to Base64 encode the specified string + by calling a Temboo Utilities Choreo. +*/ +String base64Encode(String toEncode) { + + // we need a Process object to send a Choreo request to Temboo + TembooChoreo Base64EncodeChoreo; + + // invoke the Temboo client + Base64EncodeChoreo.begin(); + + // set Temboo account credentials + Base64EncodeChoreo.setAccountName(TEMBOO_ACCOUNT); + Base64EncodeChoreo.setAppKeyName(TEMBOO_APP_KEY_NAME); + Base64EncodeChoreo.setAppKey(TEMBOO_APP_KEY); + + // identify the Temboo Library choreo to run (Utilities > Encoding > Base64Encode) + Base64EncodeChoreo.setChoreo("/Library/Utilities/Encoding/Base64Encode"); + + // set choreo inputs + Base64EncodeChoreo.addInput("Text", toEncode); + + // run the choreo + Base64EncodeChoreo.run(); + + // read in the choreo results, and return the "Base64EncodedText" output value. + // see http://www.temboo.com/arduino for more details on using choreo outputs. + while(Base64EncodeChoreo.available()) { + // read the name of the output item + String name = Base64EncodeChoreo.readStringUntil('\x1F'); + name.trim(); + + // read the value of the output item + String data = Base64EncodeChoreo.readStringUntil('\x1E'); + data.trim(); + + if(name == "Base64EncodedText") { + return data; + } + } +} + +/* + IMPORTANT NOTE: TembooAccount.h: + + TembooAccount.h is a file referenced by this sketch that contains your Temboo account information. + You'll need to edit the placeholder version of TembooAccount.h included with this example sketch, + by inserting your own Temboo account name and app key information. The contents of the file should + look like: + + #define TEMBOO_ACCOUNT "myTembooAccountName" // your Temboo account name + #define TEMBOO_APP_KEY_NAME "myFirstApp" // your Temboo app key name + #define TEMBOO_APP_KEY "xxx-xxx-xxx-xx-xxx" // your Temboo app key + + You can find your Temboo App Key information on the Temboo website, + under My Account > Application Keys + + The same TembooAccount.h file settings can be used for all Temboo SDK sketches. + + Keeping your account information in a separate file means you can share the main .ino file without worrying + that you forgot to delete your credentials. +*/ diff --git a/libraries/Bridge/examples/TemperatureWebPanel/TemperatureWebPanel.ino b/libraries/Bridge/examples/TemperatureWebPanel/TemperatureWebPanel.ino new file mode 100644 index 0000000..2149737 --- /dev/null +++ b/libraries/Bridge/examples/TemperatureWebPanel/TemperatureWebPanel.ino @@ -0,0 +1,121 @@ +/* + Temperature web interface + + This example shows how to serve data from an analog input + via the Arduino Yún's built-in webserver using the Bridge library. + + The circuit: + * TMP36 temperature sensor on analog pin A1 + * SD card attached to SD card slot of the Arduino Yún + + Prepare your SD card with an empty folder in the SD root + named "arduino" and a subfolder of that named "www". + This will ensure that the Yún will create a link + to the SD to the "/mnt/sd" path. + + In this sketch folder is a basic webpage and a copy of zepto.js, a + minimized version of jQuery. When you upload your sketch, these files + will be placed in the /arduino/www/TemperatureWebPanel folder on your SD card. + + You can then go to http://arduino.local/sd/TemperatureWebPanel + to see the output of this sketch. + + You can remove the SD card while the Linux and the + sketch are running but be careful not to remove it while + the system is writing to it. + + created 6 July 2013 + by Tom Igoe + + + This example code is in the public domain. + + */ +#include <Bridge.h> +#include <YunServer.h> +#include <YunClient.h> + +// Listen on default port 5555, the webserver on the Yun +// will forward there all the HTTP requests for us. +YunServer server; +String startString; +long hits = 0; + +void setup() { + Serial.begin(9600); + + // Bridge startup + pinMode(13,OUTPUT); + digitalWrite(13, LOW); + Bridge.begin(); + digitalWrite(13, HIGH); + + // using A0 and A2 as vcc and gnd for the TMP36 sensor: + pinMode(A0, OUTPUT); + pinMode(A2, OUTPUT); + digitalWrite(A0, HIGH); + digitalWrite(A2, LOW); + + // Listen for incoming connection only from localhost + // (no one from the external network could connect) + server.listenOnLocalhost(); + server.begin(); + + // get the time that this sketch started: + Process startTime; + startTime.runShellCommand("date"); + while(startTime.available()) { + char c = startTime.read(); + startString += c; + } +} + +void loop() { + // Get clients coming from server + YunClient client = server.accept(); + + // There is a new client? + if (client) { + // read the command + String command = client.readString(); + command.trim(); //kill whitespace + Serial.println(command); + // is "temperature" command? + if (command == "temperature") { + + // get the time from the server: + Process time; + time.runShellCommand("date"); + String timeString = ""; + while(time.available()) { + char c = time.read(); + timeString += c; + } + Serial.println(timeString); + int sensorValue = analogRead(A1); + // convert the reading to millivolts: + float voltage = sensorValue * (5000/ 1024); + // convert the millivolts to temperature celsius: + float temperature = (voltage - 500)/10; + // print the temperature: + client.print("Current time on the Yún: "); + client.println(timeString); + client.print("<br>Current temperature: "); + client.print(temperature); + client.print(" degrees C"); + client.print("<br>This sketch has been running since "); + client.print(startString); + client.print("<br>Hits so far: "); + client.print(hits); + } + + // Close connection and free resources. + client.stop(); + hits++; + } + + delay(50); // Poll every 50ms +} + + + diff --git a/libraries/Bridge/examples/TemperatureWebPanel/www/index.html b/libraries/Bridge/examples/TemperatureWebPanel/www/index.html new file mode 100755 index 0000000..c6b6747 --- /dev/null +++ b/libraries/Bridge/examples/TemperatureWebPanel/www/index.html @@ -0,0 +1,16 @@ +<!DOCTYPE html> +<html> + <head> + <script type="text/javascript" src="zepto.min.js"></script> + <script type="text/javascript"> + function refresh() { + $('#content').load('/arduino/temperature'); + } +</script> + + </head> + <body onload="setInterval(refresh, 2000);"> + <span id="content">0</span> + </body> +</html> + diff --git a/libraries/Bridge/examples/TemperatureWebPanel/www/zepto.min.js b/libraries/Bridge/examples/TemperatureWebPanel/www/zepto.min.js new file mode 100755 index 0000000..dbe4e3c --- /dev/null +++ b/libraries/Bridge/examples/TemperatureWebPanel/www/zepto.min.js @@ -0,0 +1,2 @@ +/* Zepto v1.0-1-ga3cab6c - polyfill zepto detect event ajax form fx - zeptojs.com/license */ +(function(a){String.prototype.trim===a&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")}),Array.prototype.reduce===a&&(Array.prototype.reduce=function(b){if(this===void 0||this===null)throw new TypeError;var c=Object(this),d=c.length>>>0,e=0,f;if(typeof b!="function")throw new TypeError;if(d==0&&arguments.length==1)throw new TypeError;if(arguments.length>=2)f=arguments[1];else do{if(e in c){f=c[e++];break}if(++e>=d)throw new TypeError}while(!0);while(e<d)e in c&&(f=b.call(a,f,c[e],e,c)),e++;return f})})();var Zepto=function(){function E(a){return a==null?String(a):y[z.call(a)]||"object"}function F(a){return E(a)=="function"}function G(a){return a!=null&&a==a.window}function H(a){return a!=null&&a.nodeType==a.DOCUMENT_NODE}function I(a){return E(a)=="object"}function J(a){return I(a)&&!G(a)&&a.__proto__==Object.prototype}function K(a){return a instanceof Array}function L(a){return typeof a.length=="number"}function M(a){return g.call(a,function(a){return a!=null})}function N(a){return a.length>0?c.fn.concat.apply([],a):a}function O(a){return a.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function P(a){return a in j?j[a]:j[a]=new RegExp("(^|\\s)"+a+"(\\s|$)")}function Q(a,b){return typeof b=="number"&&!l[O(a)]?b+"px":b}function R(a){var b,c;return i[a]||(b=h.createElement(a),h.body.appendChild(b),c=k(b,"").getPropertyValue("display"),b.parentNode.removeChild(b),c=="none"&&(c="block"),i[a]=c),i[a]}function S(a){return"children"in a?f.call(a.children):c.map(a.childNodes,function(a){if(a.nodeType==1)return a})}function T(c,d,e){for(b in d)e&&(J(d[b])||K(d[b]))?(J(d[b])&&!J(c[b])&&(c[b]={}),K(d[b])&&!K(c[b])&&(c[b]=[]),T(c[b],d[b],e)):d[b]!==a&&(c[b]=d[b])}function U(b,d){return d===a?c(b):c(b).filter(d)}function V(a,b,c,d){return F(b)?b.call(a,c,d):b}function W(a,b,c){c==null?a.removeAttribute(b):a.setAttribute(b,c)}function X(b,c){var d=b.className,e=d&&d.baseVal!==a;if(c===a)return e?d.baseVal:d;e?d.baseVal=c:b.className=c}function Y(a){var b;try{return a?a=="true"||(a=="false"?!1:a=="null"?null:isNaN(b=Number(a))?/^[\[\{]/.test(a)?c.parseJSON(a):a:b):a}catch(d){return a}}function Z(a,b){b(a);for(var c in a.childNodes)Z(a.childNodes[c],b)}var a,b,c,d,e=[],f=e.slice,g=e.filter,h=window.document,i={},j={},k=h.defaultView.getComputedStyle,l={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},m=/^\s*<(\w+|!)[^>]*>/,n=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,o=/^(?:body|html)$/i,p=["val","css","html","text","data","width","height","offset"],q=["after","prepend","before","append"],r=h.createElement("table"),s=h.createElement("tr"),t={tr:h.createElement("tbody"),tbody:r,thead:r,tfoot:r,td:s,th:s,"*":h.createElement("div")},u=/complete|loaded|interactive/,v=/^\.([\w-]+)$/,w=/^#([\w-]*)$/,x=/^[\w-]+$/,y={},z=y.toString,A={},B,C,D=h.createElement("div");return A.matches=function(a,b){if(!a||a.nodeType!==1)return!1;var c=a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.matchesSelector;if(c)return c.call(a,b);var d,e=a.parentNode,f=!e;return f&&(e=D).appendChild(a),d=~A.qsa(e,b).indexOf(a),f&&D.removeChild(a),d},B=function(a){return a.replace(/-+(.)?/g,function(a,b){return b?b.toUpperCase():""})},C=function(a){return g.call(a,function(b,c){return a.indexOf(b)==c})},A.fragment=function(b,d,e){b.replace&&(b=b.replace(n,"<$1></$2>")),d===a&&(d=m.test(b)&&RegExp.$1),d in t||(d="*");var g,h,i=t[d];return i.innerHTML=""+b,h=c.each(f.call(i.childNodes),function(){i.removeChild(this)}),J(e)&&(g=c(h),c.each(e,function(a,b){p.indexOf(a)>-1?g[a](b):g.attr(a,b)})),h},A.Z=function(a,b){return a=a||[],a.__proto__=c.fn,a.selector=b||"",a},A.isZ=function(a){return a instanceof A.Z},A.init=function(b,d){if(!b)return A.Z();if(F(b))return c(h).ready(b);if(A.isZ(b))return b;var e;if(K(b))e=M(b);else if(I(b))e=[J(b)?c.extend({},b):b],b=null;else if(m.test(b))e=A.fragment(b.trim(),RegExp.$1,d),b=null;else{if(d!==a)return c(d).find(b);e=A.qsa(h,b)}return A.Z(e,b)},c=function(a,b){return A.init(a,b)},c.extend=function(a){var b,c=f.call(arguments,1);return typeof a=="boolean"&&(b=a,a=c.shift()),c.forEach(function(c){T(a,c,b)}),a},A.qsa=function(a,b){var c;return H(a)&&w.test(b)?(c=a.getElementById(RegExp.$1))?[c]:[]:a.nodeType!==1&&a.nodeType!==9?[]:f.call(v.test(b)?a.getElementsByClassName(RegExp.$1):x.test(b)?a.getElementsByTagName(b):a.querySelectorAll(b))},c.contains=function(a,b){return a!==b&&a.contains(b)},c.type=E,c.isFunction=F,c.isWindow=G,c.isArray=K,c.isPlainObject=J,c.isEmptyObject=function(a){var b;for(b in a)return!1;return!0},c.inArray=function(a,b,c){return e.indexOf.call(b,a,c)},c.camelCase=B,c.trim=function(a){return a.trim()},c.uuid=0,c.support={},c.expr={},c.map=function(a,b){var c,d=[],e,f;if(L(a))for(e=0;e<a.length;e++)c=b(a[e],e),c!=null&&d.push(c);else for(f in a)c=b(a[f],f),c!=null&&d.push(c);return N(d)},c.each=function(a,b){var c,d;if(L(a)){for(c=0;c<a.length;c++)if(b.call(a[c],c,a[c])===!1)return a}else for(d in a)if(b.call(a[d],d,a[d])===!1)return a;return a},c.grep=function(a,b){return g.call(a,b)},window.JSON&&(c.parseJSON=JSON.parse),c.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){y["[object "+b+"]"]=b.toLowerCase()}),c.fn={forEach:e.forEach,reduce:e.reduce,push:e.push,sort:e.sort,indexOf:e.indexOf,concat:e.concat,map:function(a){return c(c.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return c(f.apply(this,arguments))},ready:function(a){return u.test(h.readyState)?a(c):h.addEventListener("DOMContentLoaded",function(){a(c)},!1),this},get:function(b){return b===a?f.call(this):this[b>=0?b:b+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){this.parentNode!=null&&this.parentNode.removeChild(this)})},each:function(a){return e.every.call(this,function(b,c){return a.call(b,c,b)!==!1}),this},filter:function(a){return F(a)?this.not(this.not(a)):c(g.call(this,function(b){return A.matches(b,a)}))},add:function(a,b){return c(C(this.concat(c(a,b))))},is:function(a){return this.length>0&&A.matches(this[0],a)},not:function(b){var d=[];if(F(b)&&b.call!==a)this.each(function(a){b.call(this,a)||d.push(this)});else{var e=typeof b=="string"?this.filter(b):L(b)&&F(b.item)?f.call(b):c(b);this.forEach(function(a){e.indexOf(a)<0&&d.push(a)})}return c(d)},has:function(a){return this.filter(function(){return I(a)?c.contains(this,a):c(this).find(a).size()})},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){var a=this[0];return a&&!I(a)?a:c(a)},last:function(){var a=this[this.length-1];return a&&!I(a)?a:c(a)},find:function(a){var b,d=this;return typeof a=="object"?b=c(a).filter(function(){var a=this;return e.some.call(d,function(b){return c.contains(b,a)})}):this.length==1?b=c(A.qsa(this[0],a)):b=this.map(function(){return A.qsa(this,a)}),b},closest:function(a,b){var d=this[0],e=!1;typeof a=="object"&&(e=c(a));while(d&&!(e?e.indexOf(d)>=0:A.matches(d,a)))d=d!==b&&!H(d)&&d.parentNode;return c(d)},parents:function(a){var b=[],d=this;while(d.length>0)d=c.map(d,function(a){if((a=a.parentNode)&&!H(a)&&b.indexOf(a)<0)return b.push(a),a});return U(b,a)},parent:function(a){return U(C(this.pluck("parentNode")),a)},children:function(a){return U(this.map(function(){return S(this)}),a)},contents:function(){return this.map(function(){return f.call(this.childNodes)})},siblings:function(a){return U(this.map(function(a,b){return g.call(S(b.parentNode),function(a){return a!==b})}),a)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(a){return c.map(this,function(b){return b[a]})},show:function(){return this.each(function(){this.style.display=="none"&&(this.style.display=null),k(this,"").getPropertyValue("display")=="none"&&(this.style.display=R(this.nodeName))})},replaceWith:function(a){return this.before(a).remove()},wrap:function(a){var b=F(a);if(this[0]&&!b)var d=c(a).get(0),e=d.parentNode||this.length>1;return this.each(function(f){c(this).wrapAll(b?a.call(this,f):e?d.cloneNode(!0):d)})},wrapAll:function(a){if(this[0]){c(this[0]).before(a=c(a));var b;while((b=a.children()).length)a=b.first();c(a).append(this)}return this},wrapInner:function(a){var b=F(a);return this.each(function(d){var e=c(this),f=e.contents(),g=b?a.call(this,d):a;f.length?f.wrapAll(g):e.append(g)})},unwrap:function(){return this.parent().each(function(){c(this).replaceWith(c(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(b){return this.each(function(){var d=c(this);(b===a?d.css("display")=="none":b)?d.show():d.hide()})},prev:function(a){return c(this.pluck("previousElementSibling")).filter(a||"*")},next:function(a){return c(this.pluck("nextElementSibling")).filter(a||"*")},html:function(b){return b===a?this.length>0?this[0].innerHTML:null:this.each(function(a){var d=this.innerHTML;c(this).empty().append(V(this,b,a,d))})},text:function(b){return b===a?this.length>0?this[0].textContent:null:this.each(function(){this.textContent=b})},attr:function(c,d){var e;return typeof c=="string"&&d===a?this.length==0||this[0].nodeType!==1?a:c=="value"&&this[0].nodeName=="INPUT"?this.val():!(e=this[0].getAttribute(c))&&c in this[0]?this[0][c]:e:this.each(function(a){if(this.nodeType!==1)return;if(I(c))for(b in c)W(this,b,c[b]);else W(this,c,V(this,d,a,this.getAttribute(c)))})},removeAttr:function(a){return this.each(function(){this.nodeType===1&&W(this,a)})},prop:function(b,c){return c===a?this[0]&&this[0][b]:this.each(function(a){this[b]=V(this,c,a,this[b])})},data:function(b,c){var d=this.attr("data-"+O(b),c);return d!==null?Y(d):a},val:function(b){return b===a?this[0]&&(this[0].multiple?c(this[0]).find("option").filter(function(a){return this.selected}).pluck("value"):this[0].value):this.each(function(a){this.value=V(this,b,a,this.value)})},offset:function(a){if(a)return this.each(function(b){var d=c(this),e=V(this,a,b,d.offset()),f=d.offsetParent().offset(),g={top:e.top-f.top,left:e.left-f.left};d.css("position")=="static"&&(g.position="relative"),d.css(g)});if(this.length==0)return null;var b=this[0].getBoundingClientRect();return{left:b.left+window.pageXOffset,top:b.top+window.pageYOffset,width:Math.round(b.width),height:Math.round(b.height)}},css:function(a,c){if(arguments.length<2&&typeof a=="string")return this[0]&&(this[0].style[B(a)]||k(this[0],"").getPropertyValue(a));var d="";if(E(a)=="string")!c&&c!==0?this.each(function(){this.style.removeProperty(O(a))}):d=O(a)+":"+Q(a,c);else for(b in a)!a[b]&&a[b]!==0?this.each(function(){this.style.removeProperty(O(b))}):d+=O(b)+":"+Q(b,a[b])+";";return this.each(function(){this.style.cssText+=";"+d})},index:function(a){return a?this.indexOf(c(a)[0]):this.parent().children().indexOf(this[0])},hasClass:function(a){return e.some.call(this,function(a){return this.test(X(a))},P(a))},addClass:function(a){return this.each(function(b){d=[];var e=X(this),f=V(this,a,b,e);f.split(/\s+/g).forEach(function(a){c(this).hasClass(a)||d.push(a)},this),d.length&&X(this,e+(e?" ":"")+d.join(" "))})},removeClass:function(b){return this.each(function(c){if(b===a)return X(this,"");d=X(this),V(this,b,c,d).split(/\s+/g).forEach(function(a){d=d.replace(P(a)," ")}),X(this,d.trim())})},toggleClass:function(b,d){return this.each(function(e){var f=c(this),g=V(this,b,e,X(this));g.split(/\s+/g).forEach(function(b){(d===a?!f.hasClass(b):d)?f.addClass(b):f.removeClass(b)})})},scrollTop:function(){if(!this.length)return;return"scrollTop"in this[0]?this[0].scrollTop:this[0].scrollY},position:function(){if(!this.length)return;var a=this[0],b=this.offsetParent(),d=this.offset(),e=o.test(b[0].nodeName)?{top:0,left:0}:b.offset();return d.top-=parseFloat(c(a).css("margin-top"))||0,d.left-=parseFloat(c(a).css("margin-left"))||0,e.top+=parseFloat(c(b[0]).css("border-top-width"))||0,e.left+=parseFloat(c(b[0]).css("border-left-width"))||0,{top:d.top-e.top,left:d.left-e.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||h.body;while(a&&!o.test(a.nodeName)&&c(a).css("position")=="static")a=a.offsetParent;return a})}},c.fn.detach=c.fn.remove,["width","height"].forEach(function(b){c.fn[b]=function(d){var e,f=this[0],g=b.replace(/./,function(a){return a[0].toUpperCase()});return d===a?G(f)?f["inner"+g]:H(f)?f.documentElement["offset"+g]:(e=this.offset())&&e[b]:this.each(function(a){f=c(this),f.css(b,V(this,d,a,f[b]()))})}}),q.forEach(function(a,b){var d=b%2;c.fn[a]=function(){var a,e=c.map(arguments,function(b){return a=E(b),a=="object"||a=="array"||b==null?b:A.fragment(b)}),f,g=this.length>1;return e.length<1?this:this.each(function(a,h){f=d?h:h.parentNode,h=b==0?h.nextSibling:b==1?h.firstChild:b==2?h:null,e.forEach(function(a){if(g)a=a.cloneNode(!0);else if(!f)return c(a).remove();Z(f.insertBefore(a,h),function(a){a.nodeName!=null&&a.nodeName.toUpperCase()==="SCRIPT"&&(!a.type||a.type==="text/javascript")&&!a.src&&window.eval.call(window,a.innerHTML)})})})},c.fn[d?a+"To":"insert"+(b?"Before":"After")]=function(b){return c(b)[a](this),this}}),A.Z.prototype=c.fn,A.uniq=C,A.deserializeValue=Y,c.zepto=A,c}();window.Zepto=Zepto,"$"in window||(window.$=Zepto),function(a){function b(a){var b=this.os={},c=this.browser={},d=a.match(/WebKit\/([\d.]+)/),e=a.match(/(Android)\s+([\d.]+)/),f=a.match(/(iPad).*OS\s([\d_]+)/),g=!f&&a.match(/(iPhone\sOS)\s([\d_]+)/),h=a.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),i=h&&a.match(/TouchPad/),j=a.match(/Kindle\/([\d.]+)/),k=a.match(/Silk\/([\d._]+)/),l=a.match(/(BlackBerry).*Version\/([\d.]+)/),m=a.match(/(BB10).*Version\/([\d.]+)/),n=a.match(/(RIM\sTablet\sOS)\s([\d.]+)/),o=a.match(/PlayBook/),p=a.match(/Chrome\/([\d.]+)/)||a.match(/CriOS\/([\d.]+)/),q=a.match(/Firefox\/([\d.]+)/);if(c.webkit=!!d)c.version=d[1];e&&(b.android=!0,b.version=e[2]),g&&(b.ios=b.iphone=!0,b.version=g[2].replace(/_/g,".")),f&&(b.ios=b.ipad=!0,b.version=f[2].replace(/_/g,".")),h&&(b.webos=!0,b.version=h[2]),i&&(b.touchpad=!0),l&&(b.blackberry=!0,b.version=l[2]),m&&(b.bb10=!0,b.version=m[2]),n&&(b.rimtabletos=!0,b.version=n[2]),o&&(c.playbook=!0),j&&(b.kindle=!0,b.version=j[1]),k&&(c.silk=!0,c.version=k[1]),!k&&b.android&&a.match(/Kindle Fire/)&&(c.silk=!0),p&&(c.chrome=!0,c.version=p[1]),q&&(c.firefox=!0,c.version=q[1]),b.tablet=!!(f||o||e&&!a.match(/Mobile/)||q&&a.match(/Tablet/)),b.phone=!b.tablet&&!!(e||g||h||l||m||p&&a.match(/Android/)||p&&a.match(/CriOS\/([\d.]+)/)||q&&a.match(/Mobile/))}b.call(a,navigator.userAgent),a.__detect=b}(Zepto),function(a){function g(a){return a._zid||(a._zid=d++)}function h(a,b,d,e){b=i(b);if(b.ns)var f=j(b.ns);return(c[g(a)]||[]).filter(function(a){return a&&(!b.e||a.e==b.e)&&(!b.ns||f.test(a.ns))&&(!d||g(a.fn)===g(d))&&(!e||a.sel==e)})}function i(a){var b=(""+a).split(".");return{e:b[0],ns:b.slice(1).sort().join(" ")}}function j(a){return new RegExp("(?:^| )"+a.replace(" "," .* ?")+"(?: |$)")}function k(b,c,d){a.type(b)!="string"?a.each(b,d):b.split(/\s/).forEach(function(a){d(a,c)})}function l(a,b){return a.del&&(a.e=="focus"||a.e=="blur")||!!b}function m(a){return f[a]||a}function n(b,d,e,h,j,n){var o=g(b),p=c[o]||(c[o]=[]);k(d,e,function(c,d){var e=i(c);e.fn=d,e.sel=h,e.e in f&&(d=function(b){var c=b.relatedTarget;if(!c||c!==this&&!a.contains(this,c))return e.fn.apply(this,arguments)}),e.del=j&&j(d,c);var g=e.del||d;e.proxy=function(a){var c=g.apply(b,[a].concat(a.data));return c===!1&&(a.preventDefault(),a.stopPropagation()),c},e.i=p.length,p.push(e),b.addEventListener(m(e.e),e.proxy,l(e,n))})}function o(a,b,d,e,f){var i=g(a);k(b||"",d,function(b,d){h(a,b,d,e).forEach(function(b){delete c[i][b.i],a.removeEventListener(m(b.e),b.proxy,l(b,f))})})}function t(b){var c,d={originalEvent:b};for(c in b)!r.test(c)&&b[c]!==undefined&&(d[c]=b[c]);return a.each(s,function(a,c){d[a]=function(){return this[c]=p,b[a].apply(b,arguments)},d[c]=q}),d}function u(a){if(!("defaultPrevented"in a)){a.defaultPrevented=!1;var b=a.preventDefault;a.preventDefault=function(){this.defaultPrevented=!0,b.call(this)}}}var b=a.zepto.qsa,c={},d=1,e={},f={mouseenter:"mouseover",mouseleave:"mouseout"};e.click=e.mousedown=e.mouseup=e.mousemove="MouseEvents",a.event={add:n,remove:o},a.proxy=function(b,c){if(a.isFunction(b)){var d=function(){return b.apply(c,arguments)};return d._zid=g(b),d}if(typeof c=="string")return a.proxy(b[c],b);throw new TypeError("expected function")},a.fn.bind=function(a,b){return this.each(function(){n(this,a,b)})},a.fn.unbind=function(a,b){return this.each(function(){o(this,a,b)})},a.fn.one=function(a,b){return this.each(function(c,d){n(this,a,b,null,function(a,b){return function(){var c=a.apply(d,arguments);return o(d,b,a),c}})})};var p=function(){return!0},q=function(){return!1},r=/^([A-Z]|layer[XY]$)/,s={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};a.fn.delegate=function(b,c,d){return this.each(function(e,f){n(f,c,d,b,function(c){return function(d){var e,g=a(d.target).closest(b,f).get(0);if(g)return e=a.extend(t(d),{currentTarget:g,liveFired:f}),c.apply(g,[e].concat([].slice.call(arguments,1)))}})})},a.fn.undelegate=function(a,b,c){return this.each(function(){o(this,b,c,a)})},a.fn.live=function(b,c){return a(document.body).delegate(this.selector,b,c),this},a.fn.die=function(b,c){return a(document.body).undelegate(this.selector,b,c),this},a.fn.on=function(b,c,d){return!c||a.isFunction(c)?this.bind(b,c||d):this.delegate(c,b,d)},a.fn.off=function(b,c,d){return!c||a.isFunction(c)?this.unbind(b,c||d):this.undelegate(c,b,d)},a.fn.trigger=function(b,c){if(typeof b=="string"||a.isPlainObject(b))b=a.Event(b);return u(b),b.data=c,this.each(function(){"dispatchEvent"in this&&this.dispatchEvent(b)})},a.fn.triggerHandler=function(b,c){var d,e;return this.each(function(f,g){d=t(typeof b=="string"?a.Event(b):b),d.data=c,d.target=g,a.each(h(g,b.type||b),function(a,b){e=b.proxy(d);if(d.isImmediatePropagationStopped())return!1})}),e},"focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(b){a.fn[b]=function(a){return a?this.bind(b,a):this.trigger(b)}}),["focus","blur"].forEach(function(b){a.fn[b]=function(a){return a?this.bind(b,a):this.each(function(){try{this[b]()}catch(a){}}),this}}),a.Event=function(a,b){typeof a!="string"&&(b=a,a=b.type);var c=document.createEvent(e[a]||"Events"),d=!0;if(b)for(var f in b)f=="bubbles"?d=!!b[f]:c[f]=b[f];return c.initEvent(a,d,!0,null,null,null,null,null,null,null,null,null,null,null,null),c.isDefaultPrevented=function(){return this.defaultPrevented},c}}(Zepto),function($){function triggerAndReturn(a,b,c){var d=$.Event(b);return $(a).trigger(d,c),!d.defaultPrevented}function triggerGlobal(a,b,c,d){if(a.global)return triggerAndReturn(b||document,c,d)}function ajaxStart(a){a.global&&$.active++===0&&triggerGlobal(a,null,"ajaxStart")}function ajaxStop(a){a.global&&!--$.active&&triggerGlobal(a,null,"ajaxStop")}function ajaxBeforeSend(a,b){var c=b.context;if(b.beforeSend.call(c,a,b)===!1||triggerGlobal(b,c,"ajaxBeforeSend",[a,b])===!1)return!1;triggerGlobal(b,c,"ajaxSend",[a,b])}function ajaxSuccess(a,b,c){var d=c.context,e="success";c.success.call(d,a,e,b),triggerGlobal(c,d,"ajaxSuccess",[b,c,a]),ajaxComplete(e,b,c)}function ajaxError(a,b,c,d){var e=d.context;d.error.call(e,c,b,a),triggerGlobal(d,e,"ajaxError",[c,d,a]),ajaxComplete(b,c,d)}function ajaxComplete(a,b,c){var d=c.context;c.complete.call(d,b,a),triggerGlobal(c,d,"ajaxComplete",[b,c]),ajaxStop(c)}function empty(){}function mimeToDataType(a){return a&&(a=a.split(";",2)[0]),a&&(a==htmlType?"html":a==jsonType?"json":scriptTypeRE.test(a)?"script":xmlTypeRE.test(a)&&"xml")||"text"}function appendQuery(a,b){return(a+"&"+b).replace(/[&?]{1,2}/,"?")}function serializeData(a){a.processData&&a.data&&$.type(a.data)!="string"&&(a.data=$.param(a.data,a.traditional)),a.data&&(!a.type||a.type.toUpperCase()=="GET")&&(a.url=appendQuery(a.url,a.data))}function parseArguments(a,b,c,d){var e=!$.isFunction(b);return{url:a,data:e?b:undefined,success:e?$.isFunction(c)?c:undefined:b,dataType:e?d||c:c}}function serialize(a,b,c,d){var e,f=$.isArray(b);$.each(b,function(b,g){e=$.type(g),d&&(b=c?d:d+"["+(f?"":b)+"]"),!d&&f?a.add(g.name,g.value):e=="array"||!c&&e=="object"?serialize(a,g,c,b):a.add(b,g)})}var jsonpID=0,document=window.document,key,name,rscript=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,scriptTypeRE=/^(?:text|application)\/javascript/i,xmlTypeRE=/^(?:text|application)\/xml/i,jsonType="application/json",htmlType="text/html",blankRE=/^\s*$/;$.active=0,$.ajaxJSONP=function(a){if("type"in a){var b="jsonp"+ ++jsonpID,c=document.createElement("script"),d=function(){clearTimeout(g),$(c).remove(),delete window[b]},e=function(c){d();if(!c||c=="timeout")window[b]=empty;ajaxError(null,c||"abort",f,a)},f={abort:e},g;return ajaxBeforeSend(f,a)===!1?(e("abort"),!1):(window[b]=function(b){d(),ajaxSuccess(b,f,a)},c.onerror=function(){e("error")},c.src=a.url.replace(/=\?/,"="+b),$("head").append(c),a.timeout>0&&(g=setTimeout(function(){e("timeout")},a.timeout)),f)}return $.ajax(a)},$.ajaxSettings={type:"GET",beforeSend:empty,success:empty,error:empty,complete:empty,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript",json:jsonType,xml:"application/xml, text/xml",html:htmlType,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0},$.ajax=function(options){var settings=$.extend({},options||{});for(key in $.ajaxSettings)settings[key]===undefined&&(settings[key]=$.ajaxSettings[key]);ajaxStart(settings),settings.crossDomain||(settings.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(settings.url)&&RegExp.$2!=window.location.host),settings.url||(settings.url=window.location.toString()),serializeData(settings),settings.cache===!1&&(settings.url=appendQuery(settings.url,"_="+Date.now()));var dataType=settings.dataType,hasPlaceholder=/=\?/.test(settings.url);if(dataType=="jsonp"||hasPlaceholder)return hasPlaceholder||(settings.url=appendQuery(settings.url,"callback=?")),$.ajaxJSONP(settings);var mime=settings.accepts[dataType],baseHeaders={},protocol=/^([\w-]+:)\/\//.test(settings.url)?RegExp.$1:window.location.protocol,xhr=settings.xhr(),abortTimeout;settings.crossDomain||(baseHeaders["X-Requested-With"]="XMLHttpRequest"),mime&&(baseHeaders.Accept=mime,mime.indexOf(",")>-1&&(mime=mime.split(",",2)[0]),xhr.overrideMimeType&&xhr.overrideMimeType(mime));if(settings.contentType||settings.contentType!==!1&&settings.data&&settings.type.toUpperCase()!="GET")baseHeaders["Content-Type"]=settings.contentType||"application/x-www-form-urlencoded";settings.headers=$.extend(baseHeaders,settings.headers||{}),xhr.onreadystatechange=function(){if(xhr.readyState==4){xhr.onreadystatechange=empty,clearTimeout(abortTimeout);var result,error=!1;if(xhr.status>=200&&xhr.status<300||xhr.status==304||xhr.status==0&&protocol=="file:"){dataType=dataType||mimeToDataType(xhr.getResponseHeader("content-type")),result=xhr.responseText;try{dataType=="script"?(1,eval)(result):dataType=="xml"?result=xhr.responseXML:dataType=="json"&&(result=blankRE.test(result)?null:$.parseJSON(result))}catch(e){error=e}error?ajaxError(error,"parsererror",xhr,settings):ajaxSuccess(result,xhr,settings)}else ajaxError(null,xhr.status?"error":"abort",xhr,settings)}};var async="async"in settings?settings.async:!0;xhr.open(settings.type,settings.url,async);for(name in settings.headers)xhr.setRequestHeader(name,settings.headers[name]);return ajaxBeforeSend(xhr,settings)===!1?(xhr.abort(),!1):(settings.timeout>0&&(abortTimeout=setTimeout(function(){xhr.onreadystatechange=empty,xhr.abort(),ajaxError(null,"timeout",xhr,settings)},settings.timeout)),xhr.send(settings.data?settings.data:null),xhr)},$.get=function(a,b,c,d){return $.ajax(parseArguments.apply(null,arguments))},$.post=function(a,b,c,d){var e=parseArguments.apply(null,arguments);return e.type="POST",$.ajax(e)},$.getJSON=function(a,b,c){var d=parseArguments.apply(null,arguments);return d.dataType="json",$.ajax(d)},$.fn.load=function(a,b,c){if(!this.length)return this;var d=this,e=a.split(/\s/),f,g=parseArguments(a,b,c),h=g.success;return e.length>1&&(g.url=e[0],f=e[1]),g.success=function(a){d.html(f?$("<div>").html(a.replace(rscript,"")).find(f):a),h&&h.apply(d,arguments)},$.ajax(g),this};var escape=encodeURIComponent;$.param=function(a,b){var c=[];return c.add=function(a,b){this.push(escape(a)+"="+escape(b))},serialize(c,a,b),c.join("&").replace(/%20/g,"+")}}(Zepto),function(a){a.fn.serializeArray=function(){var b=[],c;return a(Array.prototype.slice.call(this.get(0).elements)).each(function(){c=a(this);var d=c.attr("type");this.nodeName.toLowerCase()!="fieldset"&&!this.disabled&&d!="submit"&&d!="reset"&&d!="button"&&(d!="radio"&&d!="checkbox"||this.checked)&&b.push({name:c.attr("name"),value:c.val()})}),b},a.fn.serialize=function(){var a=[];return this.serializeArray().forEach(function(b){a.push(encodeURIComponent(b.name)+"="+encodeURIComponent(b.value))}),a.join("&")},a.fn.submit=function(b){if(b)this.bind("submit",b);else if(this.length){var c=a.Event("submit");this.eq(0).trigger(c),c.defaultPrevented||this.get(0).submit()}return this}}(Zepto),function(a,b){function s(a){return t(a.replace(/([a-z])([A-Z])/,"$1-$2"))}function t(a){return a.toLowerCase()}function u(a){return d?d+a:t(a)}var c="",d,e,f,g={Webkit:"webkit",Moz:"",O:"o",ms:"MS"},h=window.document,i=h.createElement("div"),j=/^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i,k,l,m,n,o,p,q,r={};a.each(g,function(a,e){if(i.style[a+"TransitionProperty"]!==b)return c="-"+t(a)+"-",d=e,!1}),k=c+"transform",r[l=c+"transition-property"]=r[m=c+"transition-duration"]=r[n=c+"transition-timing-function"]=r[o=c+"animation-name"]=r[p=c+"animation-duration"]=r[q=c+"animation-timing-function"]="",a.fx={off:d===b&&i.style.transitionProperty===b,speeds:{_default:400,fast:200,slow:600},cssPrefix:c,transitionEnd:u("TransitionEnd"),animationEnd:u("AnimationEnd")},a.fn.animate=function(b,c,d,e){return a.isPlainObject(c)&&(d=c.easing,e=c.complete,c=c.duration),c&&(c=(typeof c=="number"?c:a.fx.speeds[c]||a.fx.speeds._default)/1e3),this.anim(b,c,d,e)},a.fn.anim=function(c,d,e,f){var g,h={},i,t="",u=this,v,w=a.fx.transitionEnd;d===b&&(d=.4),a.fx.off&&(d=0);if(typeof c=="string")h[o]=c,h[p]=d+"s",h[q]=e||"linear",w=a.fx.animationEnd;else{i=[];for(g in c)j.test(g)?t+=g+"("+c[g]+") ":(h[g]=c[g],i.push(s(g)));t&&(h[k]=t,i.push(k)),d>0&&typeof c=="object"&&(h[l]=i.join(", "),h[m]=d+"s",h[n]=e||"linear")}return v=function(b){if(typeof b!="undefined"){if(b.target!==b.currentTarget)return;a(b.target).unbind(w,v)}a(this).css(r),f&&f.call(this)},d>0&&this.bind(w,v),this.size()&&this.get(0).clientLeft,this.css(h),d<=0&&setTimeout(function(){u.each(function(){v.call(this)})},0),this},i=null}(Zepto) diff --git a/libraries/Bridge/examples/TimeCheck/TimeCheck.ino b/libraries/Bridge/examples/TimeCheck/TimeCheck.ino new file mode 100644 index 0000000..848ff25 --- /dev/null +++ b/libraries/Bridge/examples/TimeCheck/TimeCheck.ino @@ -0,0 +1,82 @@ + +/* + Time Check + + Gets the time from the linino processor via Bridge + then parses out hours, minutes and seconds for the Arduino + using an Arduino Yún. + + created 27 May 2013 + modified 21 June 2013 + By Tom Igoe + + This example code is in the public domain. + + */ + + +#include <Process.h> + +Process date; // process used to get the date +int hours, minutes, seconds; // for the results +int lastSecond = -1; // need an impossible value for comparison + +void setup() { + Bridge.begin(); // initialize Bridge + Serial.begin(9600); // initialize serial + + while(!Serial); // wait for Serial Monitor to open + Serial.println("Time Check"); // Title of sketch + + // run an initial date process. Should return: + // hh:mm:ss : + if (!date.running()) { + date.begin("date"); + date.addParameter("+%T"); + date.run(); + } +} + +void loop() { + + if(lastSecond != seconds) { // if a second has passed + // print the time: + if (hours <= 9) Serial.print("0"); // adjust for 0-9 + Serial.print(hours); + Serial.print(":"); + if (minutes <= 9) Serial.print("0"); // adjust for 0-9 + Serial.print(minutes); + Serial.print(":"); + if (seconds <= 9) Serial.print("0"); // adjust for 0-9 + Serial.println(seconds); + + // restart the date process: + if (!date.running()) { + date.begin("date"); + date.addParameter("+%T"); + date.run(); + } + } + + //if there's a result from the date process, parse it: + while (date.available()>0) { + // get the result of the date process (should be hh:mm:ss): + String timeString = date.readString(); + + // find the colons: + int firstColon = timeString.indexOf(":"); + int secondColon= timeString.lastIndexOf(":"); + + // get the substrings for hour, minute second: + String hourString = timeString.substring(0, firstColon); + String minString = timeString.substring(firstColon+1, secondColon); + String secString = timeString.substring(secondColon+1); + + // convert to ints,saving the previous second: + hours = hourString.toInt(); + minutes = minString.toInt(); + lastSecond = seconds; // save to do a time comparison + seconds = secString.toInt(); + } + +} diff --git a/libraries/Bridge/examples/WiFiStatus/WiFiStatus.ino b/libraries/Bridge/examples/WiFiStatus/WiFiStatus.ino new file mode 100644 index 0000000..5921b70 --- /dev/null +++ b/libraries/Bridge/examples/WiFiStatus/WiFiStatus.ino @@ -0,0 +1,50 @@ + +/* + WiFi Status + + This sketch runs a script called "pretty-wifi-info.lua" + installed on your Yún in folder /usr/bin. + It prints information about the status of your wifi connection. + + It uses Serial to print, so you need to connect your Yún to your + computer using a USB cable and select the appropriate port from + the Port menu + + created 18 June 2013 + By Federico Fissore + + This example code is in the public domain. + */ + +#include <Process.h> + +void setup() { + Serial.begin(9600); // initialize serial communication + while(!Serial); // do nothing until the serial monitor is opened + + Serial.println("Starting bridge...\n"); + pinMode(13,OUTPUT); + digitalWrite(13, LOW); + Bridge.begin(); // make contact with the linux processor + digitalWrite(13, HIGH); // Led on pin 13 turns on when the bridge is ready + + delay(2000); // wait 2 seconds +} + +void loop() { + Process wifiCheck; // initialize a new process + + wifiCheck.runShellCommand("/usr/bin/pretty-wifi-info.lua"); // command you want to run + + // while there's any characters coming back from the + // process, print them to the serial monitor: + while (wifiCheck.available() > 0) { + char c = wifiCheck.read(); + Serial.print(c); + } + + Serial.println(); + + delay(5000); +} + diff --git a/libraries/Bridge/examples/XivelyClient/XivelyClient.ino b/libraries/Bridge/examples/XivelyClient/XivelyClient.ino new file mode 100644 index 0000000..69f979c --- /dev/null +++ b/libraries/Bridge/examples/XivelyClient/XivelyClient.ino @@ -0,0 +1,110 @@ +/* + Xively sensor client with Strings + + This sketch connects an analog sensor to Xively, + using an Arduino Yún. + + created 15 March 2010 + updated 27 May 2013 + by Tom Igoe + + */ + +// include all Libraries needed: +#include <Process.h> +#include "passwords.h" // contains my passwords, see below + +/* + NOTE: passwords.h is not included with this repo because it contains my passwords. + You need to create it for your own version of this application. To do so, make + a new tab in Arduino, call it passwords.h, and include the following variables and constants: + + #define APIKEY "foo" // replace your pachube api key here + #define FEEDID 0000 // replace your feed ID + #define USERAGENT "my-project" // user agent is the project name + */ + + +// set up net client info: +const unsigned long postingInterval = 60000; //delay between updates to xively.com +unsigned long lastRequest = 0; // when you last made a request +String dataString = ""; + +void setup() { + // start serial port: + Bridge.begin(); + Serial.begin(9600); + + while(!Serial); // wait for Network Serial to open + Serial.println("Xively client"); + + // Do a first update immediately + updateData(); + sendData(); + lastRequest = millis(); +} + +void loop() { + // get a timestamp so you can calculate reading and sending intervals: + long now = millis(); + + // if the sending interval has passed since your + // last connection, then connect again and send data: + if (now - lastRequest >= postingInterval) { + updateData(); + sendData(); + lastRequest = now; + } +} + +void updateData() { + // convert the readings to a String to send it: + dataString = "Temperature,"; + dataString += random(10) + 20; + // add pressure: + dataString += "\nPressure,"; + dataString += random(5) + 100; +} + +// this method makes a HTTP connection to the server: +void sendData() { + // form the string for the API header parameter: + String apiString = "X-ApiKey: "; + apiString += APIKEY; + + // form the string for the URL parameter: + String url = "https://api.xively.com/v2/feeds/"; + url += FEEDID; + url += ".csv"; + + // Send the HTTP PUT request + + // Is better to declare the Process here, so when the + // sendData function finishes the resources are immediately + // released. Declaring it global works too, BTW. + Process xively; + Serial.print("\n\nSending data... "); + xively.begin("curl"); + xively.addParameter("-k"); + xively.addParameter("--request"); + xively.addParameter("PUT"); + xively.addParameter("--data"); + xively.addParameter(dataString); + xively.addParameter("--header"); + xively.addParameter(apiString); + xively.addParameter(url); + xively.run(); + Serial.println("done!"); + + // If there's incoming data from the net connection, + // send it out the Serial: + while (xively.available()>0) { + char c = xively.read(); + Serial.write(c); + } + +} + + + + diff --git a/libraries/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino b/libraries/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino new file mode 100644 index 0000000..faffd93 --- /dev/null +++ b/libraries/Bridge/examples/YunSerialTerminal/YunSerialTerminal.ino @@ -0,0 +1,78 @@ +/* + Arduino Yun USB-to-Serial + + Allows you to use the Yun's 32U4 processor as a + serial terminal for the linino processor. + + Upload this to an Arduino Yun via serial (not WiFi) + then open the serial monitor at 115200 to see the boot process + of the linino processor. You can also use the serial monitor + as a basic command line interface for the linino processor using + this sketch. + + From the serial monitor the following commands can be issued: + + '~' followed by '0' -> Set the UART speed to 57600 baud + '~' followed by '1' -> Set the UART speed to 115200 baud + '~' followed by '2' -> Set the UART speed to 250000 baud + '~' followed by '3' -> Set the UART speed to 500000 baud + '~' followeb by '~' -> Sends the bridge's shutdown command to + obtain the console. + + The circuit: + * Arduino Yun + + created March 2013 + by Massimo Banzi + modified by Cristian Maglie + + This example code is in the public domain. + */ + +long lininoBaud = 250000; + +void setup() { + Serial.begin(115200); // open serial connection via USB-Serial + Serial1.begin(lininoBaud); // open serial connection to Linino +} + +boolean commandMode = false; + +void loop() { + // copy from virtual serial line to uart and vice versa + if (Serial.available()) { // got anything from USB-Serial? + char c = (char)Serial.read(); // read from USB-serial + if (commandMode == false) { // if we aren't in command mode... + if (c == '~') { // Tilde '~' key pressed? + commandMode = true; // enter in command mode + } else { + Serial1.write(c); // otherwise write char to Linino + } + } else { // if we are in command mode... + if (c == '0') { // '0' key pressed? + Serial1.begin(57600); // set speed to 57600 + Serial.println("Speed set to 57600"); + } else if (c == '1') { // '1' key pressed? + Serial1.begin(115200); // set speed to 115200 + Serial.println("Speed set to 115200"); + } else if (c == '2') { // '2' key pressed? + Serial1.begin(250000); // set speed to 250000 + Serial.println("Speed set to 250000"); + } else if (c == '3') { // '3' key pressed? + Serial1.begin(500000); // set speed to 500000 + Serial.println("Speed set to 500000"); + } else if (c == '~') { + Serial1.write((uint8_t *)"\xff\0\0\x05XXXXX\x0d\xaf", 11); + Serial.println("Sending bridge's shutdown command"); + } else { // any other key pressed? + Serial1.write('~'); // write '~' to Linino + Serial1.write(c); // write char to Linino + } + commandMode = false; // in all cases exit from command mode + } + } + if (Serial1.available()) { // got anything from Linino? + char c = (char)Serial1.read(); // read from Linino + Serial.write(c); // write to USB-serial + } +}
\ No newline at end of file diff --git a/libraries/Bridge/keywords.txt b/libraries/Bridge/keywords.txt new file mode 100644 index 0000000..05453b8 --- /dev/null +++ b/libraries/Bridge/keywords.txt @@ -0,0 +1,85 @@ +####################################### +# Syntax Coloring Map For Bridge +####################################### + +####################################### +# Class (KEYWORD3) +####################################### + +Bridge KEYWORD3 +FileIO KEYWORD3 +FileSystem KEYWORD3 +Console KEYWORD3 +Process KEYWORD3 +Mailbox KEYWORD3 +HttpClient KEYWORD3 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +# methods names in commond +begin KEYWORD2 +end KEYWORD2 +available KEYWORD2 +read KEYWORD2 +peek KEYWORD2 +write KEYWORD2 +flush KEYWORD2 +bool KEYWORD2 + +# Bridge Class +transfer KEYWORD2 +put KEYWORD2 +get KEYWORD2 + +# Console Class +buffer KEYWORD2 +noBuffer KEYWORD2 +connected KEYWORD2 + +# FileIO Class +File KEYWORD2 +seek KEYWORD2 +position KEYWORD2 +size KEYWORD2 +close KEYWORD2 +name KEYWORD2 +isDirectory KEYWORD2 +openNextFile KEYWORD2 +rewindDirectory KEYWORD2 + +# Process Class +addParameter KEYWORD2 +runAsynchronously KEYWORD2 +run KEYWORD2 +running KEYWORD2 +exitValue KEYWORD2 +runShellCommand KEYWORD2 +runShellCommandAsynchronously KEYWORD2 + +# Mailbox Class +readMessage KEYWORD2 +writeMessage KEYWORD2 +writeJSON KEYWORD2 +message Available KEYWORD2 + +# HttpClient Class +getAsynchronously KEYWORD2 +ready KEYWORD2 +getResult KEYWORD2 + +# YunServer Class +accept KEYWORD2 +stop KEYWORD2 +connect KEYWORD2 +connected KEYWORD2 + + +####################################### +# Constants (LITERAL1) +####################################### + +FILE_READ LITERAL1 +FILE_WRITE LITERAL1 +FILE_APPEND LITERAL1 diff --git a/libraries/SpacebrewYun/SpacebrewYun.cpp b/libraries/SpacebrewYun/SpacebrewYun.cpp new file mode 100644 index 0000000..7c848e7 --- /dev/null +++ b/libraries/SpacebrewYun/SpacebrewYun.cpp @@ -0,0 +1,459 @@ +#include "SpacebrewYun.h" + + +SpacebrewYun::SpacebrewYun(const String& _name, const String& _description) { + name = _name; + description = _description; + subscribers = NULL; + publishers = NULL; + + server = "sandbox.spacebrew.cc"; + port = 9000; + + _connected = false; + _verbose = false; + _error_msg = false; + + sub_name = ""; + sub_msg = ""; + sub_type = ""; + + read_name = false; + read_msg = false; + + for ( int i = 0; i < pidLength; i++ ) { + pid [i] = '\0'; + } + + for ( int i = 0; i < sbPidsLen; i++ ) { + sbPids [i] = '\0'; + } + + Console.buffer(64); + +} + +int SpacebrewYun::sub_msg_int_max = 6; +int SpacebrewYun::sub_msg_bool_max = 5; +int SpacebrewYun::sub_msg_str_max = 50; +int SpacebrewYun::sub_name_max = 20; +SpacebrewYun::OnBooleanMessage SpacebrewYun::_onBooleanMessage = NULL; +SpacebrewYun::OnRangeMessage SpacebrewYun::_onRangeMessage = NULL; +SpacebrewYun::OnStringMessage SpacebrewYun::_onStringMessage = NULL; +SpacebrewYun::OnCustomMessage SpacebrewYun::_onCustomMessage = NULL; +SpacebrewYun::OnSBOpen SpacebrewYun::_onOpen = NULL; +SpacebrewYun::OnSBClose SpacebrewYun::_onClose = NULL; +SpacebrewYun::OnSBError SpacebrewYun::_onError = NULL; + +void SpacebrewYun::onOpen(OnSBOpen function){ + _onOpen = function; +} +void SpacebrewYun::onClose(OnSBClose function){ + _onClose = function; +} +void SpacebrewYun::onRangeMessage(OnRangeMessage function){ + _onRangeMessage = function; +} +void SpacebrewYun::onStringMessage(OnStringMessage function){ + _onStringMessage = function; +} +void SpacebrewYun::onBooleanMessage(OnBooleanMessage function){ + _onBooleanMessage = function; +} +void SpacebrewYun::onCustomMessage(OnCustomMessage function){ + _onCustomMessage = function; +} +void SpacebrewYun::onError(OnSBError function){ + _onError = function; +} + +void SpacebrewYun::addPublish(const String& name, const String& type) { + struct Publisher *p = new Publisher(); + p->name = createString(name.length() + 1); + p->type = createString(type.length() + 1); + p->confirmed = false; + p->time = 0; + if (type == "range") { + p->lastMsg = createString(sub_msg_int_max); + emptyString(p->lastMsg, sub_msg_int_max); + } + else if (type == "boolean") { + p->lastMsg = createString(sub_msg_bool_max); + emptyString(p->lastMsg, sub_msg_bool_max); + } + else { + p->lastMsg = createString(sub_msg_str_max); + emptyString(p->lastMsg, sub_msg_str_max); + } + name.toCharArray(p->name, name.length() + 1); + type.toCharArray(p->type, type.length() + 1); + + if (publishers == NULL){ + publishers = p; + } + else { + struct Publisher *curr = publishers; + int counter = 1; + while(curr->next != NULL){ + curr = curr->next; + counter++; + } + curr->next = p; + } + p->next = NULL; +} + +void SpacebrewYun::addSubscribe(const String& name, const String& type) { + Subscriber *s = new Subscriber(); + s->name = createString(name.length() + 1); + s->type = createString(type.length() + 1); + name.toCharArray(s->name, name.length() + 1); + type.toCharArray(s->type, type.length() + 1); + + if (subscribers == NULL){ + subscribers = s; + } + else { + struct Subscriber *curr = subscribers; + while(curr->next != NULL){ + curr = curr->next; + } + curr->next = s; + } +} + +void SpacebrewYun::connect(String _server, int _port) { + server = _server; + port = _port; + + killPids(); + + brew.begin("run-spacebrew"); // Process should launch the "curl" command + // brew.begin("python"); // Process should launch the "curl" command + // brew.addParameter("/usr/lib/python2.7/spacebrew/spacebrew.py"); // Process should launch the "curl" command + brew.addParameter("--server"); + brew.addParameter(server); + brew.addParameter("--port"); + brew.addParameter(String(port)); + brew.addParameter("-n"); + brew.addParameter(name); + brew.addParameter("-d"); + brew.addParameter(description); + + if (subscribers != NULL) { + struct Subscriber *curr = subscribers; + while(curr != NULL){ + if (_verbose) { + Serial.print(F("Creating subscribers: ")); + Serial.print(curr->name); + Serial.print(F(" of type: ")); + Serial.println(curr->type); + } + + brew.addParameter("-s"); // Add the URL parameter to "curl" + brew.addParameter(curr->name); // Add the URL parameter to "curl" + brew.addParameter(","); // Add the URL parameter to "curl" + brew.addParameter(curr->type); // Add the URL parameter to "curl" + + // if (curr->next == NULL) curr = NULL; + // else curr = curr->next; + + curr = curr->next; + } + } + if (publishers != NULL) { + struct Publisher *curr = publishers; + while(curr != NULL){ + if (_verbose) { + Serial.print(F("Creating publishers: ")); + Serial.print(curr->name); + Serial.print(F(" of type: ")); + Serial.println(curr->type); + } + brew.addParameter("-p"); // Add the URL parameter to "curl" + brew.addParameter(curr->name); // Add the URL parameter to "curl" + brew.addParameter(","); // Add the URL parameter to "curl" + brew.addParameter(curr->type); // Add the URL parameter to "curl" + + curr = curr->next; + } + } + + Console.begin(); + if (_verbose) { + Serial.println(F("Console started ")); + } + + brew.runAsynchronously(); + + if (_verbose) { + Serial.println(F("Brew started ")); + } + while (!Console) { ; } +} + +void SpacebrewYun::monitor() { + while (Console.available() > 0) { + char c = Console.read(); + + if (c == char(CONNECTION_START) && !_connected) { + if (_verbose) { + Serial.print(F("Connected to spacebrew server at: ")); + Serial.println(server); + Serial.print(F("Application name set to: ")); + Serial.println(name); + } + if (_onOpen != NULL){ + _onOpen(); + } + _connected = true; + } + else if (c == char(CONNECTION_END) && _connected) { + _connected = false; + if (_verbose) { + Serial.print(F("Disconnected from spacebrew server at: ")); + Serial.println(server); + } + if (_onClose != NULL){ + _onClose(); + } + } + + if (_verbose) { + if (c == char(CONNECTION_ERROR)) { + _error_msg = true; + Serial.println(F("ERROR :: with Spacebrew.py Connection ::")); + } + else if (_error_msg && c == char(MSG_END)) { + _error_msg = false; + Serial.println(); + } + if (_error_msg) { + Serial.print(c); + } + } + + if (_connected) { + if (c == char(MSG_START)) { + read_name = true; + } else if (c == char(MSG_DIV) || sub_name.length() > sub_name_max) { + read_name = false; + read_msg = true; + } else if (c == char(MSG_END) || sub_msg.length() > sub_msg_str_max) { + if (read_msg == true) { + read_msg = false; + onMessage(); + // delay(2); + } + if (read_confirm == true) { + read_confirm = false; + onConfirm(); + delay(2); + } + } else if (c == char(MSG_CONFIRM)) { + read_confirm = true; + } else { + if (read_name == true) { + sub_name += c; + } else if (read_confirm == true) { + sub_name += c; + } else if (read_msg == true) { + sub_msg += c; + } + else if (_verbose) { + Serial.print(c); + } + } + } + } + + if (publishers != NULL) { + struct Publisher *curr = publishers; + while((curr != NULL)){ + + if ( (curr->confirmed == 0) && ((millis() - curr->time) > 50) ) { + if (_verbose) { + Serial.print(F("resending msg: ")); + Serial.println(curr->name); + } + send(curr->name, curr->lastMsg); + } + curr = curr->next; + } + } + +} + +void SpacebrewYun::onConfirm() { + if (publishers != NULL) { + struct Publisher *curr = publishers; + while((curr != NULL)){ + if (sub_name.equals(curr->name) == true) { + curr->confirmed = true; + // if (_verbose) { + // Serial.print(F("confirmed ")); + // Serial.println(curr->name); + // } + break; + } + curr = curr->next; + } + } + + sub_name = ""; + sub_msg = ""; + sub_type = ""; +} + +boolean SpacebrewYun::connected() { + return SpacebrewYun::_connected; +} + +void SpacebrewYun::verbose(boolean verbose = true) { + _verbose = verbose; +} + +void SpacebrewYun::onMessage() { + if (subscribers != NULL) { + struct Subscriber *curr = subscribers; + while((curr != NULL) && (sub_type == "")){ + if (sub_name.equals(curr->name) == true) { + sub_type = curr->type; + } + curr = curr->next; + } + } + + if ( sub_type.equals("range") ) { + if (_onRangeMessage != NULL) { + _onRangeMessage( sub_name, int(sub_msg.toInt()) ); + } else { + Serial.println(F("ERROR :: Range message received, no callback method is registered")); + } + } else if ( sub_type.equals("boolean") ) { + if (_onBooleanMessage != NULL) { + _onBooleanMessage( sub_name, ( sub_msg.equals("false") ? false : true ) ); + } else { + Serial.println(F("ERROR :: Boolean message received, no callback method is registered")); + } + } else if ( sub_type.equals("string") ) { + if (_onStringMessage != NULL) { + _onStringMessage( sub_name, sub_msg ); + } else { + Serial.println(F("ERROR :: String message received, no callback method is registered")); + } + } else { + if (_onCustomMessage != NULL) { + _onCustomMessage( sub_name, sub_msg, sub_type ); + } else { + Serial.println(F("ERROR :: Custom message received, no callback method is registered")); + } + } + + sub_name = ""; + sub_msg = ""; + sub_type = ""; +} + + +void SpacebrewYun::send(const String& name, const String& value){ + if (publishers != NULL) { + + Console.print(char(29)); + Console.print(name); + Console.print(char(30)); + Console.print(value); + Console.print(char(31)); + Console.flush(); + + struct Publisher *curr = publishers; + while(curr != NULL){ + if (name.equals(curr->name) == true) { + int msg_len = 0; + + if (curr->type == "range") msg_len = sub_msg_int_max; + else if (curr->type == "boolean") msg_len = sub_msg_bool_max; + else msg_len = sub_msg_str_max; + + if (value.length() < msg_len) msg_len = value.length() + 1; + value.toCharArray(curr->lastMsg, msg_len); + + curr->confirmed = false; + curr->time = millis(); + + } + curr = curr->next; + } + } +} + + +/** + * method that gets the pid of all spacebrew.py instances running on the linino. + */ +void SpacebrewYun::getPids() { + + // request the pid of all python processes + // brew.begin("run-getsbpids"); // Process should launch the "curl" command + pids.begin("python"); + pids.addParameter("/usr/lib/python2.7/spacebrew/getprocpid.py"); // Process should launch the "curl" command + pids.run(); + + if (_verbose) { + Serial.println(F("Checking if spacebrew process already running")); + } + + int sbPidsIndex = 0; + int pidCharIndex = 0; + char c = '\0'; + + while ( pids.available() > 0 ) { + + c = pids.read(); + + if ( c >= '0' && c <= '9' ) { + pid[pidCharIndex] = c; + pidCharIndex = (pidCharIndex + 1) % pidLength; + } + + else if ( (c == ' ' || c == '\n') && pidCharIndex > 0) { + sbPids[sbPidsIndex] = atoi(pid); + if ( sbPidsIndex < (sbPidsLen - 1) ) sbPidsIndex = (sbPidsIndex + 1); + + for( int i = 0; i < pidLength; i++ ){ + pid[i] = '\0'; + pidCharIndex = 0; + } + } + } +} + +/** + * method that kills all of the spacebrew.py instances that are running + * on the linino. + */ +void SpacebrewYun::killPids() { + getPids(); + delay(400); + + for (int i = 0; i < sbPidsLen; i ++) { + if (sbPids[i] > 0) { + char * newPID = itoa(sbPids[i], pid, 10); + + if (_verbose) { + Serial.print(F("Stopping existing spacebrew processes with pids: ")); + Serial.println(newPID); + } + + Process p; + p.begin("kill"); + p.addParameter("-9"); + p.addParameter(newPID); // Process should launch the "curl" command + p.run(); // Run the process and wait for its termination + + delay(400); + } + } +} + + diff --git a/libraries/SpacebrewYun/SpacebrewYun.h b/libraries/SpacebrewYun/SpacebrewYun.h new file mode 100644 index 0000000..df608c1 --- /dev/null +++ b/libraries/SpacebrewYun/SpacebrewYun.h @@ -0,0 +1,137 @@ + +#ifndef YUNSPACEBREW_H +#define YUNSPACEBREW_H + +#include "Arduino.h" +#include <Bridge.h> +#include <Console.h> +#include <Process.h> + +enum SBmsg { + CONNECTION_START = char(28), + CONNECTION_END = char(27), + CONNECTION_ERROR = char(26), + MSG_CONFIRM = char(7), + MSG_START = char(29), + MSG_DIV = char(30), + MSG_END = char(31) +}; + +struct Publisher { + char *name; + char *type; + char *lastMsg; + Publisher *next; + int confirmed; + long time; +}; + +struct Subscriber{ + char *name; + char *type; + Subscriber *next; +}; + +int const pidLength = 6; +int const sbPidsLen = 4; + +class SpacebrewYun { + + public: + + SpacebrewYun(const String&, const String&); + void addPublish(const String&, const String&); + void addSubscribe(const String&, const String&); + + void connect(String, int); + void connect() { connect(server, port); }; + void connect(String _server) { connect(String(_server), port); }; + + void monitor(); + void onMessage(); + void onConfirm(); + + boolean connected(); + + void send(const String&, const String&); + void send(const String& name, char * value) { send(name, String(value)); } + void send(const String& name, bool value){ send(name, (value ? String("true") : String("false"))); }; + void send(const String& name, int value) { send(name, String(value)); }; + void send(const String& name, long value) { send(name, String(value)); }; + void send(const String& name, float value) { send(name, String(value)); }; + + void verbose(boolean); + + typedef void (*OnBooleanMessage)(String name, boolean value); + typedef void (*OnRangeMessage)(String name, int value); + typedef void (*OnStringMessage)(String name, String value); + typedef void (*OnCustomMessage)(String name, String value, String type); + typedef void (*OnSBOpen)(); + typedef void (*OnSBClose)(); + typedef void (*OnSBError)(int code, String message); + + void onOpen(OnSBOpen function); + void onClose(OnSBClose function); + void onRangeMessage(OnRangeMessage function); + void onStringMessage(OnStringMessage function); + void onBooleanMessage(OnBooleanMessage function); + void onCustomMessage(OnCustomMessage function); + void onError(OnSBError function); + + private: + + Process brew; + String name; + String server; + String description; + boolean _connected; + boolean _error_msg; + boolean _verbose; + int port; + + /**Output should be at least 5 cells**/ + static OnBooleanMessage _onBooleanMessage; + static OnRangeMessage _onRangeMessage; + static OnStringMessage _onStringMessage; + static OnCustomMessage _onCustomMessage; + static OnSBOpen _onOpen; + static OnSBClose _onClose; + static OnSBError _onError; + + Subscriber * subscribers; + Publisher * publishers; + String sub_name; + String sub_msg; + String sub_type; + + boolean read_name; + boolean read_msg; + boolean read_confirm; + static int sub_name_max; + static int sub_msg_str_max; + static int sub_msg_int_max; + static int sub_msg_bool_max; + // int sub_name_max; + // int sub_msg_str_max; + + Process pids; + char pid [6]; + int sbPids [4]; + + void killPids(); + void getPids(); + + static char * createString(int len){ + char * out = ( char * ) malloc ( len + 1 ); + return out; + } + + static void emptyString(char * str, int len){ + for (int i = 0; i < len; i++) { + str[i] = '\0'; + } + } + +}; + +#endif diff --git a/libraries/SpacebrewYun/keywords.txt b/libraries/SpacebrewYun/keywords.txt new file mode 100644 index 0000000..7d8667a --- /dev/null +++ b/libraries/SpacebrewYun/keywords.txt @@ -0,0 +1,15 @@ +SpacebrewYun KEYWORD1 +addPublish KEYWORD2 +addSubscribe KEYWORD2 +connect KEYWORD2 +verbose KEYWORD2 +monitor KEYWORD2 +onMessage KEYWORD2 +send KEYWORD2 +onRangeMessage KEYWORD2 +onStringMessage KEYWORD2 +onBooleanMessage KEYWORD2 +onCustomMessage KEYWORD2 +onOpen KEYWORD2 +onClose KEYWORD2 +onError KEYWORD2
\ No newline at end of file diff --git a/libraries/Temboo/Temboo.cpp b/libraries/Temboo/Temboo.cpp new file mode 100644 index 0000000..1e5e539 --- /dev/null +++ b/libraries/Temboo/Temboo.cpp @@ -0,0 +1,64 @@ +/* +############################################################################### +# +# Temboo Arduino Yun library +# +# Copyright 2013, Temboo Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +# +############################################################################### +*/ + +#include <Temboo.h> + +void TembooChoreo::begin() { + Process::begin("temboo"); +} + +void TembooChoreo::setAccountName(const String& accountName) { + addParameter("-a" + accountName); +} + +void TembooChoreo::setAppKeyName(const String& appKeyName) { + addParameter("-u" + appKeyName); +} + +void TembooChoreo::setAppKey(const String& appKey) { + addParameter("-p" + appKey); +} + +void TembooChoreo::setChoreo(const String& choreo) { + addParameter("-c" + choreo); +} + +void TembooChoreo::setCredential(const String& credentialName) { + addParameter("-e" + credentialName); +} + +void TembooChoreo::addInput(const String& inputName, const String& inputValue) { + addParameter("-i" + inputName + ":" + inputValue); +} + +void TembooChoreo::addOutputFilter(const String& outputName, const String& filterPath, const String& variableName) { + addParameter("-o" + outputName + ":" + filterPath + ":" + variableName); +} + +void TembooChoreo::setSettingsFileToWrite(const String& filePath) { + addParameter("-w" + filePath); +} + +void TembooChoreo::setSettingsFileToRead(const String& filePath) { + addParameter("-r" + filePath); +} + diff --git a/libraries/Temboo/Temboo.h b/libraries/Temboo/Temboo.h new file mode 100644 index 0000000..2420c86 --- /dev/null +++ b/libraries/Temboo/Temboo.h @@ -0,0 +1,44 @@ +/* +############################################################################### +# +# Temboo Arduino Yun library +# +# Copyright 2013, Temboo Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, +# either express or implied. See the License for the specific +# language governing permissions and limitations under the License. +# +############################################################################### +*/ + +#ifndef _TEMBOO_H +#define _TEMBOO_H +#include <Arduino.h> +#include <Process.h> + +class TembooChoreo : public Process { + + public: + void begin(); + void setAccountName(const String& accountName); + void setAppKeyName(const String& appKeyName); + void setAppKey(const String& appKey); + void setChoreo(const String& choreo); + void setCredential(const String& credentialName); + void addInput(const String& inputName, const String& inputValue); + void addOutputFilter(const String& filterName, const String& filterPath, const String& variableName); + void setSettingsFileToWrite(const String& filePath); + void setSettingsFileToRead(const String& filePath); + +}; + +#endif |