def switch_callback(bcmchanel):
    # Send change to the server immediatelly
    print("switch callback called")
    print("change: " + str(bcmchanel));
    value = getGPIOInput(bcmchanel);
    print(value);
    SharedInstances.static_commandProcessor.beginPostSwitchEvent(str(bcmchanel),value);
    def getPeripheralsStatus(self,peripheralcontroller):
        retval = [];
        for po in self._peripherals:
            if(po.ptype == self.PERI_TYPE_OUT_SAINTSMART_RELAY):
                status = peripheralcontroller.getPeripheralStatus(po.serialid)
                stat = {'' + self.ST_PERIPHERAL_ID + '':'' + po.devid
                + '',''+self.STATUS + '':'' + status+''}
                retval.append(stat)
            if(po.ptype == self.PERI_TYPE_OUT_PIFACE_RELAY):
                status = peripheralcontroller.getPeripheralStatus(po.serialid)
                stat = {'' + self.ST_PERIPHERAL_ID + '':'' + po.devid
                + '',''+self.STATUS + '':'' + status+''}
                retval.append(stat)                
            elif(po.ptype == self.PERI_TYPE_IN_PITHERMOMETER):
                tempc = get_temperature();
                stat = {''+self.ST_PERIPHERAL_ID + '':'' + po.devid
                + '',''+self.STATUS + '':'' + tempc+''}
                retval.append(stat)
            elif(po.ptype == self.PERI_TYPE_IN_BUTTON_SWITCH):
                onoff = getGPIOInput(po.pgpio)
                stat = {''+self.ST_PERIPHERAL_ID + '':'' + po.devid
                + '',''+self.STATUS + '':'' + onoff+''}
                retval.append(stat)
            elif(po.ptype == self.PERI_TYPE_IN_THERMOMETER):
                #onoff = getGPIOInput(po.pgpio)
                self.log.write("Get Peripheral status","digitemp");
                digtemp = read_dig_temp(int(po.serialid));
                stat = {''+self.ST_PERIPHERAL_ID + '':'' + po.devid
                + '',''+self.STATUS + '':'' + digtemp[0]+''}
                self.log.write("Get Peripheral status", stat);
                retval.append(stat)
                
                
                

        return retval;